Search Unity

Rendering voxel chunks: bad performance when using small chunks but same amount of total triangles

Discussion in 'General Graphics' started by captainspaceman, Mar 7, 2021.

  1. captainspaceman

    captainspaceman

    Joined:
    Jul 14, 2017
    Posts:
    42
    Basic cubic voxels. I want my game to have fast destruction, I've found that using smaller chunk sizes is better for this, but for some reason, it makes it much harder on rendering.

    I don't understand this completely, it's the same amount of vertices and triangles and whatnot, just spread out over more Unity objects. Is there any way I can get the best of both worlds? That is to say, have small chunks but also have fast rendering?



    If you want more explanation, my chunks right now are 3D, so they can be as small as possible, I've found I get great mesh editing performance (mainly in recalculating the physics collider) with 5x5x5 chunks. But the rendering is horrendous. When I make the chunks larger, such as 16x16x256, such as in Minecraft, the rendering is fine, pretty much as good as Mincraft's, and really even the mesh editing is fine too, it's just that my game needs FAST destruction, so when you destroy many cubes is quick succession, the game drops to like 5 fps.

    I have tried using my own physics system so I could use that instead of Unity's PhysX.Bake thing and have larger chunks, but it turned out collision response is extremely difficult haha. The problem is getting an object to settle into place, as in not stand up and seemingly balance on a corner, AND have it not jitter around like crazy when resting after it settles. I sort of figured it out but it looked horrible and I did some tests and it actually wasn't a whole lot faster than Unity's colliders but way more complex for me as a developer so I switched back to using Unity's rigidbodys.

    I've experimented with other things too such as using the cube data itself for the destruction collision detection and loading in the colliders one at a time frame by frame which helps a lot but nothing helps more than having smaller chunks.
     
  2. captainspaceman

    captainspaceman

    Joined:
    Jul 14, 2017
    Posts:
    42
    Oh I'll use Unity's CombineMeshes method and switch back and only use the chunk meshes during actual destruction.