I am attempting to write a 3d voxel engine from scratch. I am rendering cubes using 6 planes, in chunks of 16x16x128, like the well known game, Minecraft. However, this results in about 10250 batchs, 94779 saved by batching, but where I think is a huge source of performance drop, is the 43574 shadow casters. Now, my idea to solve this is to simply disable the ‘renderer’ component on every part of a cube that is invisible to the camera, on all the cubes. Now, obviously, I can’t use this:
void OnBecameInvisible(){
GetComponent().enabled = false;
}
void OnBecameVisible(){
GetComponent().enabled = true;
}
If I try that, then the renderer is disabled as soon as you can’t see a face on a cube, however, when you can see it again, because the renderer component is disabled, you don’t get the ‘OnBecameVisible’ event passed, and therefore it won’t re-enable the renderer.
I figured this could turn into a discussion, so I put it on the forum instead of Answers.
So my question then, how can I only draw objects that are visible to the camera on the screen.
Note: I can’t use occlusion culling because the prefabs of blocks are instantiated at runtime.