mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-20 17:39:46 +00:00
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. |
||
|---|---|---|
| .. | ||
| coders | ||
| crypto | ||
| data | ||
| io | ||
| network | ||
| util | ||
| voxels | ||
| window | ||
| world/generator | ||
| CMakeLists.txt | ||