VoxelVoxel Terrain can be seen in games as Minecraft or StarMade.
Voxels are 3D
pixels. The size is (often) 1x1x1 in current coordinate system.
The map itself is stored in 2D array of (unsigned) integers which are height. It can (and probably will) also have another 2D array for
material(color / texture) of the voxel.
To use the terrain, we need to generate a mesh for it.
The question is - where do we place rounded coordinate. We have 2 choices - center and corner. Because of optimization (using modulo), we will use the second option - corner.
Negative CoordinatesIn best case, we would use modulo but in most languages modulo operator
%returns negative values for negative input.
|Value||Modulo 4||% 4|