'Culling' in a voxel world

531 Views Asked by At

I have a world full of voxels, lets say that my world is 320*320*96 voxels. My idea is to load that entire world into the ram of my videocard so that no peformance is lost in transferring new "chunks" to the GPU. The amount of faces generated to display that voxelworld should easyly fit into the memory of modern graphic cards.

However, the problem I am facing now it how to not display parts of that world, I want to limit the view of this world to (for example) 128*128*96 and shift the world or the camera around to show different parts.

To demonstrate my problem, have a look at a (simple) scene consisting of a ground with in white the "viewable" area, I am looking for the right WebGL/three.js functions to restrict the view to just the white part.

the voxelworld

1

There are 1 best solutions below

4
On

You could remove voxels you don't want to display from the scene.

scene.remove( mesh )

And add them to the scene when you do want to display them.

scene.add( mesh )

I recommend splitting your voxel world into chunks (like Minecraft) and making those chunks into meshes individually. Add the chunk meshes that you want visible to the scene and remove them when you want to hide them.