Search Unity

Need to efficiently render a very large number of cubes

Discussion in 'General Graphics' started by hyperdead, Feb 17, 2021.

  1. hyperdead

    hyperdead

    Joined:
    Apr 25, 2018
    Posts:
    1
    I'm trying to use Unity for scientific research purposes - the goal is to be able to render a chromosome in 3D in Unity. I have chromosomal coordinate data (basically just a huge file of Vector3s) and I render the chromosome by spawning cubes and adjusting their transform so they connect to each other. I have about 50k cubes I render this way.

    I then have gene coordinate data, which I render as more cubes (with a material that makes them appear green). That's another 50k. Overall, it adds up to about 100k cubes total. Here's what that looks like:

    upload_2021-2-17_11-59-53.png

    Unsurprisingly, this is not very fast. I have a pretty good computer and I only get about 10fps.

    upload_2021-2-17_12-2-50.png

    I address this with unity's built in LODGroups right now. I have thousands of LODGroups and each one contains both a single, very stretched cube (for when you're viewing from far away) or the genes in full detail (when you're up close).
    upload_2021-2-17_12-8-53.png

    upload_2021-2-17_12-9-47.png

    Thing is, this isn't a very good experience because for performance reasons I have to simplify so much that it looks like the genes are jumping around when you zoom in. It also makes other things I want to add much more difficult. For example, I have lines that connect different sections of the chromosome (that represent predicted chromatid interaction areas), but I connect them to the full-detail area which means they look like they connect to nothing when you're viewing it in low detail.

    So, I would really like to be able to render all this without doing LOD stuff at all. Does anyone know of a good way to do this? I'm using the default render pipeline right now, and I have instancing turned on, which makes it render in 365 batches (this improved performance a lot when I figured out how to turn it on). Is there a more advanced instancing process I can do that will be able to handle 100k cubes all at once? Or does anyone have any other ideas for how to efficiently render this, maybe using a geometry shader?
     

    Attached Files:

  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285