Search Unity

GPU Instancing for Light Probes

Discussion in 'Global Illumination' started by joshuacwilde, Jul 18, 2020.

  1. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    731
    Is there a particular reason GPU instancing doesn't work when light probes are involved? I would think this could be solved with MaterialPropertyBlocks, right? Just pass in each light probe data set to the property blocks and GPU instancing would work.

    It is odd also because in my game view before I hit play, I have ~270 draw calls. However when I hit play, it suddenly goes up to over 1000, and the reason it says is that the objects can't be GPU instanced because they use different light probes. There is no difference in the scene before and after I hit play as far as hierarchy or additional meshes.

    Almost like when not playing it can instance them (or atleast it is reporting so), but when playing it cannot.

    Any thoughts would be so much appreciated. Thanks!
     
    laurentlavigne likes this.
  2. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    731
    Actually it appears when not in play mode it also gives the reason for using different light probes, it just happens a lot less / is more successful at instancing the renderers.
     
  3. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    731
    After further research, it appears the discrepancy before and after hitting play was because of static batching. I had to turn it off for instanced objects.

    However I still don't know why some objects give a reason of not being able to instance when they share the same mesh. It says they are using different light probes, but that doesn't seem to be a problem other places.
     
  4. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    731
    Ah! I think this is a bug. It appears that spot lights break instancing, even if they are baked. Once I disabled them all, the materials instanced fine. I just baked lighting so I don't see any reason any of them wouldn't be baked. They were marked to be baked and appear to have taken effect in the lightmaps.
     
  5. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,365
    if you think it's a bug, report it and add the # in this thread so the unity folks can have a look
     
  6. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    What about Light Proxies?
     
  7. frbrz

    frbrz

    Joined:
    May 10, 2016
    Posts:
    76
    Maybe you are in forward mode. Instancing does not support multiple lights in Forward mode.
     
    laurentlavigne likes this.
  8. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,365
    Since GI sub forum is pretty dead people might stumble on this thread so I'll paste over what's been found:

    objects inside different probe tetrahedra break up in multiple instance batches in builtin.

    LPPV is a solution as @Bordeaux_Fox hinted earlier.
    Spreading apart probes is another solution.

    URP doesn't break up batches but they're not instances anyway unless you turn off SRP batching or use the API for direct draw instance.
     
    blueivy likes this.