Search Unity

Question Any recipe for a URP "Normals-Only" Decal SG? No Base Color. Is it bugged?

Discussion in 'Shader Graph' started by halley, Jan 14, 2024.

  1. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    [ Unity 2022.3.14f1 URP 14.0.9 MacOS Metal ]

    I have been trying to put together a URP Shader Graph which takes in a Normal Map, and blends it without affecting the existing color. The documentation for the Decal Shader Graph hints that you should be able to turn off "Affects Base Color" and leave on the "Affects Normals" + "Blend" to apply dents to a surface, but I've had no luck so far.

    If the Graph Settings' "Affects Base Color" is on, of course the input image affects the surface color. I can reduce the impact by lowering the input image's alpha, but that also diminishes the impact of the Normal I am trying to blend in.

    If the Graph Settings' "Affects Base Color" is off, then the master node has no alpha. (During editing, it may be visible at first, but disables any wire going into that socket, and if you delete the wire, the alpha goes away.) And this essentially takes away all impact of base color, but also takes away all impact of Normal.

    If I were to use a screen-results-captured render texture, then the base color would be lit twice. I guess that's really the answer-- there's no way for the Decal pass to remember what the color of the surface it's about to draw on looked like before lighting.
     
    Last edited: Jan 14, 2024
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,307
    Unity 2022.3.6, there is "normal alpha" output to control how normals are blended with background, so if you don't have it I would assume it's a bug.
    upload_2024-1-15_2-48-56.png

    upload_2024-1-15_2-50-24.png
     
  3. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    Yup, I have the Normal Alpha. Has no effect on this situation, have tried any number of inputs, constant 1, constant 0, from the same image, from a separate image's alpha channel, nothing. If "Affect BaseColor" is off, I get no dented surface. If it's on, I have to supply a color.
     
  4. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,307
    I mean, this is what you want correct?
    GIF 15.01.2024 14-55-21.gif

    I am changing material alpha property here. My setup:
    upload_2024-1-15_14-54-4.png

    upload_2024-1-15_14-56-36.png

    // Edit: Are you casting decal on standard lit shader surface?
     
  5. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,433
    That was the sauce. I had to switch Technique to "Automatic" instead of "Screen Space" (in the Render Feature in the URP Render Data Asset). Thanks!

    Edit: it looks like URP doesn't have additive normals like HDRP; the normals I supply in the decal overwrite the normals of the surface, but I think this will do for my purposes.
     
    Last edited: Jan 15, 2024