# Methods to remove horizontal world slices of voxels in a 3D voxel world

I've recently been working on a hobby voxel world recently.

I'm currently interested in ideas or solutions which would enable me to basically step up and down the Y-axis 1 horizontal block slice at a time, effectively making all upper horizontal slices transparent so that I can see objects/terrain/units under the earth.

[A quick visual attempt at describing the problem] I've done a bit of googling on the subject but perhaps I'm not describing the problem set correctly because I'm unable to find anything satisfactory.

Goals :
1.) I dont' want to have to recreate the chunk meshes across the entire world everytime I step up and down the Y-axis blocks. It would destroy performance and probably crash Unity.
2.) Reasonably optimized quick stepping up and down the Y-axis i.e. no perf drops.

I know that a few options must be out there as I've seen examples in other engines and games (Byte56's Age of Goblins tech demo and Gnomoria etc). I'm guessing an algorithm via some magic shader math would be perfect.

All ideas greatly appreciated!

When I implemented this, I had hoped to do it all via the shaders. I planned on just passing a global Y coordinate into the shader and having the geometry shader just flatten all the terrain geometry above that Y coordinate to flatness. This works great if your game doesn't have any overhangs or caves, though this is unlikely with a voxel terrain.

What I ended up doing was a combination of shader and new geometry. I used the shader to remove all the vertices above the "slice level". This leaves a hole in the terrain wherever terrain has been removed, which is where the new geometry comes in. Like you I didn't want to have to rebuild chunks, so I just built a cap. Each chunk was responsible for building a terrain cap at the slice level. This was much faster than recomputing and building a whole chunk since it only needs to happen at one layer.

The two steps are: