So I’m an intermediate unity programmer and for the life of me, I can’t get an efficient voxel engine going. here is what I have so far(sorry no code):
world controller that spawns world chunks
world chunks that spawn individual cubes(very slow by the way)
block controller that determines what kind of block it is and what will happen when activated
So what i need is a way to:
not render a chunk when the player is far away
not render unseen blocks
change all of my algorithms and start from scratch(I don’t like this one)
so if anyone could suggest a way to do this (without marching cubes if at all possible) that would be great, and if not possible, please tell me because i am clueless
Rendering visible cubes.
Write a shader that applies to voxel objects. Normal shaders will draw from back to front and handle transparency but you can try to write something that will draw front to back and ignore any object that isn’t seen. This is a general idea to look into.
Another idea is to divide your generated map into regions (spatial partitioning). Use an algorithm that finds all the voxel objects that are edges. Draw only the edges. If an edge is broken, remove it from the list and add whatever new voxel(s) that became visible into the list.
The best option is to render each chunk as its own mesh. The mesh will only show the outer layer of blocks, thus will only render the seen block faces.