Voxel Grid Visibility
cod.ifies.com·6h·
Flag this post

Background #

Suppose you’re making a game full of cubes in a voxel grid. To start, you simply render every cube with twelve triangles, two for each face. Helpfully, the GPU discards triangles that are facing away from the camera.

vistri=facingCamera \text{vis}_{\text{tri}} = \text{facingCamera}

Many faces are invisible because of an adjacent cube, so you stop rendering them.

vistri=neighborIsNotSolid∧facingCamera \text{vis}_{\text{tri}} = \text{neighborIsNotSolid} \land \text{facingCamera}

Drawing triangles individually is slow, so combine all the visible triangles in a 16×16×16 16 \times 16 \times 16 section into a buffer and render them together as a single mesh. To start, all sections are…

Similar Posts

Loading similar posts...