Search Unity

Help Wanted [BUG] Shader Graph normals differ from URP Lit.

Discussion in 'Shader Graph' started by hippocoder, Feb 5, 2020.

  1. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,182
    As per topic, I'd like to know why normals are different in shadergraph (urp 7.1.8) and the urp lit shader. The only node I am using is Sample Texture 2D set to Type Normal with space tangent. This is then plugged into Normal.

    This isn't rocket science but there are subtle issues such as being able to slightly see topology.

    Is this a known issue? I think it is, according to google and I'm wondering if anyone has data or workarounds please.

    URP Lit:
    upload_2020-2-5_18-20-14.png

    Shadergraph:
    upload_2020-2-5_18-21-3.png

    Shadergraph nodes:
    upload_2020-2-5_18-21-38.png
     
    Last edited: Feb 5, 2020
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,182
  3. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,182
    upload_2020-2-5_18-26-34.png

    Sample seems blue and not shaded (as expected for unpacking) so URP Lit must be doing something else that shadergraph is not. Does the platform matter? I am targeting WebGL for testing but eventual platforms will be basically all of them.

    Any ideas? It's stopping us from using shadergraph and is a ship stopper with a build required by our partners soon... :(
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,096
    Heh.

    I just wrote a whole article on a similar topic, though I leave out the current state of Shader Graph. Maybe I should mention it...

    Unity is in the middle of converting the SRPs from MikkTSpace tangent space with per vertex binormal reconstruction (which is what Unity's built-in rendering paths use, and xNormal defaults to), to MikkTSpace tangent space with per pixel binormal reconstruction, which is what the HDRP uses, along with UE4, Blender, Marmoset, Knald, 3DCoat, Houdini, Modo, and most other applications that use MikkTSpace default to.

    In the 7.2.0+ release of the SRPs, all Shader Graph shaders will use the per pixel version, but URP's built in materials are still per vertex. That will be fixed at some future date.

    In all version before 7.2.0, Shader Graph's normal map calculation is flat out wrong. There's no fix you can do on your side. Technically they fixed it in LWRP 2.0.8 to at least match the default URP & built-in pipelines as I mentioned in the other thread, then immediately broke it again in LWRP 3.0.0.



    TLDR: Shader Graph's support of normal maps has always been totally broken, but will be fixed for 7.2.0, at which point the URP built-in and Shader Graph shaders still won't match.
     
    Korindian and hippocoder like this.
  5. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,182
    Wow that's pretty surprising Unity's shadergraph would be this broken. Thank you for clarification, it's at least saved a fair amount of hair loss..

    I don't mind if the URP shaders won't match, so long as shadergraph's version will be correct. If I read you right, that will happen in 7.2.0+

    Thanks for the help!
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,096
    Yep. At which point you'll need to generate your normal maps with per pixel binormals/bitangents. Most tools default to that, and those that don't (Substance & xNormal) have an option to switch to it.
     
    hippocoder likes this.
  7. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,096
    Also, I should note, HDRP's Shader Graph shaders do seem to work correctly, at least in 6.9.0, so presumably those have either always worked or got fixed back around the 2.0.8 / 3.3.0 versions, but the fix didn't stick for LWRP for some reason.
     
    hippocoder likes this.
unityunity