Search Unity

Resolved Baking light in HDRP is unusable

Discussion in 'Global Illumination' started by VincentAbert, Oct 13, 2020.

  1. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    123
    Hello !

    I have been trying to wrap my head around Unity's light baking, and so far I'm having a really hard time doing it. I have a basic scene I'm making to test it out : simple interior scene, a floor, some walls, a roof. It's enclosed, meaning I expect it to be absolutely pitch dark. That would be easy if it was only an 'inside level' -> no directional light, and not ambient sky. The thing is I want it to be seamlessly integrated in an environnement, like the inside is a house, very dark, but I can leave it and have some sun and ambient lighting outside.

    From my research, the way to do this is 1) baked lightmap (indirect only) for the static objects 2) light probes for the dynamic ones (otherwise they will receive the default ambient light).

    Now if I set the sun as baked, easy enough, i get the expected result (the roof is hidden on all images) :


    But the obvious way to do this is to set the sun as mixed right ? -> dynamic casting on dynamic objects, baked light on static objects.


    Nope. Much worse. From my understanding, it is because the baked walls stop casting any shadow (what you can see here is caused by the contact shadows post process, but the true shadow look like this (realtime) :


    So my question is why do the static objects stop casting shadow ?? I only bake indirect, and I see no real world situation where I would want this, I still need them to cast shadow on each other and dynamic objects, otherwise their baked indirect (for the static ones) and light probes (for the dynamic ones) don't have any effect.

    I really hope there's something I don't udnerstand, because I have been losing so much time over this...

    Thanks a lot for the help !
     
    RogueCode likes this.
  2. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    187
    Have you checked the game view? In scene view, if you hide an object, it's also removed from the list of shadow casters. So with the roof invisible, it won't cast a shadow anymore.
     
  3. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    123
    Thanks for the quick response !
    Yep, that has no impact whatsoever, since the roof doesn't cast shadow. Here is a very simple situation with the problem : two identical boxes, but the one that is set to "contribute GI" somehow stops casting shadows (when it is baked)


    I've tried to change a bunch of settings, but nothing seems to fix it, and I don't udnerstand why that would be default behaviour, so I'm thinking either bug (but then a pretty serious one) or I just have a wrong understanding of how this is supposed to work.
     
  4. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    187
    can you post a screenshot of the static meshes mesh renderer? Also, is the ground static or dynamic?
     
  5. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    123
    The ground is dynamic, but as you can see in this image, it makes no difference : red box is static (and it's not casting shadow either, as you can see) and the grey one is dynamic, but neither receive shadow from the static wall.
    You can also see my mesh renderer component in the screenshot :)

     
  6. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    187
    Have you been able to reproduce this with a new scene, using only the builtin Unity primitives?
     
  7. VincentAbert

    VincentAbert

    Joined:
    May 2, 2020
    Posts:
    123
    FOUND IT. Thanks a lot for your help ! Tried creating a new scene -> it seemed to mostly work (although the baking was very inconsistent, getting very strange artifacts half the time, but that's another problem). Tried to copy my volumes and light into this new scene -> problem again. It seems I had switched the shadowmask mode of the directional light to Shadowmask, instead of Distance shadowmask. I would have thought this would only impact the baked shadowmasks but it turns out it also influences the baked indirect.

    I'm so relieved, thanks again.
     
    thefranke likes this.