Search Unity

GPU instancing and lightmaps (and static batching)

Discussion in 'General Graphics' started by papercult, Oct 23, 2019.

  1. papercult

    papercult

    Joined:
    May 10, 2018
    Posts:
    9
    Hey all!
    From what I've read around, GPU instancing should support lightmaps since 2018.1 (we are on 2018.4.8)

    The thing is, it USED to work, and now it doesn't? The frame debugger says "Objects are lightmapped", but they were lightmapped before also and batching correctly (I think?). We are using custom lightmaps parameters with an assigned baked tag, and the baked lightmaps seems to have split them properly (multiple smaller lightmaps VS 2 big ones). I've also tried using the System Tag (to no change) but that seems to be only for Realtime? Documentation is unclear.

    In the frame debugger, they do share the same lightmap texture. The only differing value is "unity_lightmapST". I thought this was supported ? Am I wrong? Or do I need an additionnal step?

    According to Unity docs:
    Joined my setup and frame debugger window. The to red objects should be the ones batching together in this case, but I do have other cases with hundreds of objects where none of them are instanced properly.

    https://i.imgur.com/XWlIKBi.png
    https://i.imgur.com/e3Hsrc2.png
    https://i.imgur.com/SnFfL4o.png



    Different question but might as well: I was under the impression that static batching didn't care about lightmaps/lightmap groups, but I'm seeing behaviour that suggests it does break a batch? Is that right? I could bake large maps (1024 right now), but then on some of our levels, it just never finishes, even at low res (>24 hours before I stopped it, 2048)
     
  2. papercult

    papercult

    Joined:
    May 10, 2018
    Posts:
    9
    So I kinda answered my own questions.
    - GPU instancing does work with lightmaps, just need to assign a baked tag and make sure lights baked properly (it was fine after a couple rebakes for some reason).

    - For Static Batching, it is indeed affected by lightmaps, so bigger the better for that case (if you can build bigger lightmaps, which I'll have to monitor each level to see which cause a crash. I tried giving more space to the GI cache, we'll see.)

    The only thing "left" is GPU instancing still breaks stuff into different batches. I see the limit is settable through forcemaxcount:batchSize and maxcount:batchSize but setting anything other than 500 (default according to documentation) throws an error that says it's bigger than the constant buffer.

    Guess it'll have to do.
     
    FM-Productions and PunkDrifteR like this.