Optimization
The voxel shader employs various optimization techniques to make it render fast.
Disabling or tweaking these parameters will cause a dip in performance!
Discard Coefficient
As the grid size of the voxel decreases, voxels that are small and haven't been snapped to grid will naturally tend to overlap with other voxels and cause overdraw, z-fighting and wasted work.
So we want to remove these small voxels as soon as we can!
This discard coefficient controls what the shader considers a 'small' voxel for a given grid size that we should discard.
- Larger values will result in more voxels being considered small and therefore deleted.
- Smaller values will result in less voxels being considered small, keeping more of them.
- Zero disables this small voxel discard and below 0 don't do anything special.
Optimization Data
Stores the optimization bake data.
More information about grid optimization bake can be found here
Cull Back Faces
On a typical shader, the triangles that are not facing the viewer will not be drawn. This is done by a process called back face culling.
However in a voxel shader, the triangles are first turned into triangles on a cube. This naturally increases the amount of triangles that will be facing the viewer BUT they will still not be visible! So we'll be wasting processing time creating triangles that are not even seen!
The cull back faces feature tries to detect these triangles and remove them. It works by detecting triangles that are not facing the viewer very early and removes them entirely so that they aren't voxelized. This is a major performance booster.
Threshold
This determines the sensitivity of what the shader considers to be a triangle that is not facing the viewer.
Values closer to 0 will be more aggresive as to what constitutes a triangle that isn't facing the viewer, which may cause voxels to snap in and out of existance at the edges. In practice this is fine though as people will not see voxels materializing in and out of existance at the edges due to all the other voxels that they can see.
Positive values will start to hide the voxels that people will usually be able to see.
Values closer to -1 will make the culling be less aggresive. -1 will effectively disable the culling entirelyx.
Invert
Turning this on will make the back face cull turn into a front face cull. So first we'll hide the voxels we can see and lastly the voxel we usually can't see. So the threshold slider meanings will be inverted.
Random Discard
When grid snapping is turned on, some generated voxels will end up overlapping with other voxels and occupying the same space. We don't want this so we need to remove overlapping voxels. We don't have adjacency information about the voxels so we can't know which voxels are next to each other and discard them that way, we only have access to a single voxel at a time.
With some observation we can see that the grid size decreases, the likelihood of any one voxel overlapping with another increases. With this in mind we can employ a heuristic that randomly removes voxels as the grid size decreases.
What we do is we just start picking random voxels to remove as the grid size decreases until eventually we just end up removing all voxels.
Currently this heuristic kicks in at a grid size of 32 and uses a few fine tuned variables to make it work well.
These variables cannot be tweaked as of this time.