Commit graph

18 commits

Author SHA1 Message Date
ostermine
89bdadd6aa render the world relative to an origin near the camera
World coordinates were passed to GPU as floats: u_model of a chunk and
of a model had the world translation, vertices of translucent blocks,
particles, precipitation, block wrappers, lines and 3D texts were built
in the world space, and the camera position was subtracted in shaders.
The float step grows with the distance from the world origin (6 cm at
1M blocks, 2 m at 30M): blocks got skewed, then stuck together.

Camera::getOrigin() is an integer point near the camera (X and Z are
rounded to 1024 blocks, Y is 0). Camera::getView() is relative to it,
and every position passed to GPU is "world - origin" calculated on CPU,
so the shaders keep working with small numbers and do not change:
u_cameraPos, a_modelpos, u_inverseView and the shadows matrices are in
the same space as before, shifted by the origin. Matrices of a shadow
map are converted from the origin of its camera to the origin of the
player camera. The clouds shader gets the origin wrapped by the period
of its waves, the waves stay bound to the world.

Vertices of translucent blocks are local to the chunk now, as vertices
of opaque ones, and drawn with u_model of the chunk.
2026-11-12 10:05:06 +03:00
MihailRis
dbeeef90a8 cleanup a bit 2026-09-16 23:31:37 +03:00
MihailRis
ae082abaa2 feat: allow passing rgba color to entity skeletons and block wraps 2026-09-16 23:28:03 +03:00
MihailRis
5b868ae857 fix graphics settings & reduce extra GL calls 2026-07-14 19:03:32 +03:00
MihailRis
163a0a8c93 rename ImageFormat enum items 2025-12-21 19:05:14 +03:00
MihailRis
c47432c979 add gfx.blockwraps.set_tints 2025-12-21 16:44:12 +03:00
MihailRis
dfdc7ebf6b add 'emission' block wrap property 2025-12-20 23:51:22 +03:00
MihailRis
561fb0fb58 feat: naive texture-faces support for blockwraps implementation 2025-12-19 22:08:07 +03:00
MihailRis
a585b52aa2 fix particles normals 2025-07-07 20:42:30 +03:00
MihailRis
e357a4eb9f remove Mesh constructor 'attrs' argument & format Mesh.hpp 2025-04-27 01:13:44 +03:00
REDxEYE
1ffbeb8148 Refactor mesh handling to use templated vertex structures for improved type safety and flexibility 2025-04-13 17:14:28 +03:00
MihailRis
495e444d1f fix MainBatch::cube 2024-11-19 13:30:52 +03:00
MihailRis
5240fe6226 rename vattr to VertexAttribute 2024-11-17 01:00:27 +03:00
MihailRis
5a431ed898 add custom-models in hand support 2024-11-04 18:02:42 +03:00
MihailRis
7abb1a88c7 add particles lighting 2024-11-03 02:23:37 +03:00
MihailRis
217176f74f add particles (WIP) 2024-11-02 20:40:40 +03:00
MihailRis
a0f885e26a add missing include 2024-11-02 19:41:35 +03:00
MihailRis
bbd13f1825 add MainBatch & refactor ModelBatch, Batch3D 2024-11-02 19:37:39 +03:00