Search Unity

Question Shader Graphs don't work with Distance Shadowmask baking?

Discussion in 'Global Illumination' started by LucasForcinaSD, Jan 18, 2022.

  1. LucasForcinaSD

    LucasForcinaSD

    Joined:
    Sep 13, 2021
    Posts:
    18
    Hey there, I'm trying to bake in distance shadowmask mode, but while it works perfectly using Unity's default URP/Lit, it does strange things when using a default Lit Shader Graph, here's a visual demonstration :

    Using Unity 2021.2.5f, latest version of URP (12.1.2)
    (by the way, I'm using Bakery GPU Lightmapper, but I don't think that's an issue? Correct me if I'm wrong)

    URP/Lit, inside dynamic shadow range : Dynamic shadows for everything
    upload_2022-1-18_10-27-17.png

    URP/Lit, outside of dynamic shadow range : Shadow map is applied (intended behaviour)
    upload_2022-1-18_10-27-47.png

    =============================

    ShaderGraph/Default Lit Graph, inside dynamic shadow range :
    upload_2022-1-18_10-29-12.png

    ShaderGraph/Default Lit Graph, outside of dynamic shadow range : Shadow map seems to be applied but covers everything (it actually fades to shadow when I move the camera back and forth)
    upload_2022-1-18_10-30-31.png


    So I'm not really good with shader code, but I tried comparing shader graph default generated code and URP Lit to find what could be different but there are so much keywords I can't find anything.

    Does anyone know how to make this work ? Should I use a custom function to compute my shadow map inside my shader graph ?

    Thanks in advance !
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,789
    Try the progressive lightmapper as well (just to rule out bakery having anything to do with this).

    Otherwise, it seems like a bug with shadergraph.
     
  3. LucasForcinaSD

    LucasForcinaSD

    Joined:
    Sep 13, 2021
    Posts:
    18
    Thanks for your answer
    I tried baking with the progressive GPU in the meantime, but the result is the same (URP Lit works as intended, but shader graphs are covering everything with shadows once out of the dynamic range) :
    upload_2022-1-18_10-51-30.png
     
  4. LucasForcinaSD

    LucasForcinaSD

    Joined:
    Sep 13, 2021
    Posts:
    18
    Update

    After some research on the URP documentartion, I found out Shadowmask was badly supported when using Deferred Rendering (which I'm using)
    Switching back to Forward Renderer fixes the problem

    So to be clear:
    URP/Lit works with Shadowmask in both Deferred and Forward Rendering
    Shader Graphs work with Shadowmask only in Forward Rendering

    Hope this is a WIP and will be patched in the current version because we would really need both Deferred and Shadowmask baking :(
    I made a bug report without adressing the Deferred vs Forward issue earlier.
     
    Beauque and KEngelstoft like this.