For the past few months, I’ve been developing a procedural 10x10x10 chunk-generation system. Think of it like other voxel games: as you walk around the chunks are generated and removed constantly. Though the generation is relatively fast, the framerate of rendering it is not. I’ve tried multiple items: Making a chunk share materials between blocks, making chunks share materials across ALL rendered chunks, removing any vertices within the mesh that you can’t see, reducing texture size by only the single texture the block appears as, etc., etc. What should be my next form of approach? Let me know any questions you may need answered. Thanks.
There are 2 things I notice.
First the batches. Is dynamic batching enabled and do you use a single material? (For the second bit, think of a texture atlas, that will save a lot)
Second the shadow casters. Try to make the chunks 1 bigger mesh or a few big meshes to drive this all the way down to a handful of casters. You can test if this is the bottleneck by simply disabling shadows
Dynamic batching didn’t seem to change the results. In addition, the lights don’t seem to be the issue either. Though, I do believe Texture Atlas is the way to go. My color and texture packs are comprised of 100 colors and images each, which essentially means that there could be maximum 10,000 materials in the scene at once. Hopefully, Atlas will be able to reduce this. I’ll give an update later once resolved. Thanks!
What does the profiler show for a frame?
How big are your chunks?
You mentioned you’re removing vertices, however you have 10M vertices for 178k triangles which is 50-100x more than I would expect, so I’d check that’s working correctly. Anything over 3x the triangles means there are unused vertices.
Optimising materials isn’t going to help unless you make the chunks bigger, because you will need a draw call for each chunk so that’s your limiting factor. You could also use a 2d texture array for combining materials for a chunk.
Cut to half a year later, the concept of the texture atlas was the way to go! Though, instead of any built-in Unity texture atlas, I developed a script that combines the 100-color pack and 100-texture pack, into a 10,000-tile pack that holds all possible combinations of materials. In addition, I learned a lot about Unity DOTS and have rebuilt the entire voxel framework using ECS to help manage all of the chunks. In addition, the chunks are now 20x20x20. Now with over 4 million triangles on screen with nearly 60 FPS and plenty of optimizing to go! Thanks so much for the help.