Search Unity

Question Problem Transforming Normals out of View Space

Discussion in 'Shader Graph' started by Samuel_Herb, Jul 21, 2021.

  1. Samuel_Herb

    Samuel_Herb

    Joined:
    Jun 23, 2020
    Posts:
    8
    I'm trying to edit normals in view space before converting to tangent space. As you can see from the image- the result of the Transform node doesn't match the result coming out of the Normal Vector node. Infact- I can't transform from view space into world or object space correctly either! Any idea what's going on here?
     

    Attached Files:

  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,336
    Normals are ... weird. They're not handled like "a direction" is for ... reasons. They instead need to use the transpose inverse transform of whatever matrix would normally be used for transforming any other direction.

    The Transform nodes handle this properly ... at least when going from World to Tangent space. It looks like it's totally broken when going from View to Tangent space though! The work around is to do the View to World transform yourself, like this:
    upload_2021-7-23_23-44-43.png
     
  3. Samuel_Herb

    Samuel_Herb

    Joined:
    Jun 23, 2020
    Posts:
    8
    Thank you so much Bgolus! You're a saint.