Search Unity

Question Does Gpu Instancing have a limit ???

Discussion in 'General Graphics' started by wolfgangmami, Jul 4, 2022.

  1. wolfgangmami

    wolfgangmami

    Joined:
    Jul 23, 2018
    Posts:
    11
    I have a simple scene with trees and I want to use Gpu Instancing. This option is powerful but no one mentioned is there a limit (Like object count or something). I assume it is limitless but I want to make sure
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,975
    I was just yesterday peeking into this subject. I could render a 48x48x48 cube of cubes using Graphics.RenderMeshInstanced at 90 fps (just using DrawMeshNow it was drawn at 8 fps and it took FBX Exporter about 15 minutes to save these 100k cubes to a file).

    I found another user’s test project where quads are drawn using a compute shader which threw a „something above 65535“ error when drawing just over 4 million quads. I think those limits are reasonably high.

    There‘s also an example without ComputeBuffer and with MaterialPropertyBlocks which had a limit of 1023 meshes in one call. This also ran a lot slower compared to ComputeBuffer, too, since data needs to be transferred to the GPU whereas ComputeBuffer creates the data with and on the GPU to begin with. However I don‘t know whether this works as well on limited hardware (mobile, VR, anything by Nintendo).

    This is the article, highly recommended: https://toqoz.fyi/thousands-of-meshes.html
    Link to github project is at the very end.