Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Resolved Water puddle decal fade on angled slopes

Discussion in 'High Definition Render Pipeline' started by cecarlsen, Nov 22, 2021.

  1. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    874
    How do I read the screen normal buffer from a node in Shader Graph (HDRP)?

    I am patching a decal shader that needs to check the normal it is projected onto. I am making water puddles, so I only want to effect surfaces that point upwards in world space.

    There is a SceneDepthNode but I see no SceneNormalNode.

    Any hints are very welcome.

    ALTERNATIVELY: How to I modify the HDRP decal shader? It seems the action happens in "High Definition RP/Runtime/Material/Decal/DecalNormalBuffer.shader". But this is a hidden shader, and I'm not sure how to point to a modified copy only for the relevant water puddle decal projectors (or materials).
     
    Last edited: Nov 22, 2021
  2. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    874
    [SOLVED]

    AH! So what I wanted to achive is possible with the default setup. BUT only if you enable "Decal Layers". That is when the "Angle Fade" property becomes available, and I can make my water puddles fade out on sloped surafes.

    But why? Why would I have to enable "Decal Layers" to enable the "Angle Fade" feature. Why? o_O
     
    Last edited: Nov 22, 2021
    Ruchir likes this.
  3. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    808
    The short answer is: memory footprint and optimization.

    Longer answer is, for angle fade feature to work we need vertex normal of the surface you are applying decal on. BUT, by default, we don't have this information, we only have the depth buffer.
    However, when activating decal layer, HDRP allocates a new 32bits buffer but using only 24bits leaving 8 bits of free space to store the much needed vertex normals for angle fade to work, so now angle fade can work properly.

    That's the reason behind why we can't just enable angle fade without decal layers because there's just no buffer available to store that data.
     
    sqallpl and cecarlsen like this.
  4. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    874
    Ah, optimisation, the enemy of UX. I see there is a tooltip for AngleFade explaining the oddity.

    I am just getting into the groove with HDRP so there is much to learn. Is there no shared deferred normal buffer to sample from? That would expain why there is no SceneNormalNode in Shader Graph.
     
    Last edited: Nov 25, 2021