Search Unity

Question Height based color | SHADER GRAPH

Discussion in 'Shader Graph' started by Kulkejszyn, Nov 24, 2020.

  1. Kulkejszyn

    Kulkejszyn

    Joined:
    Feb 21, 2019
    Posts:
    6
    Hello everyone.
    I am creating decal shader graph which should change color of texture based on vertex Y position position.
    For height comparsion I am using absolute world postion and some input height..
    In this position color changes, but when I rotate the player's camera, the texture of the decal also changes and looks like it has some kind of depth.
    upload_2020-11-24_17-12-33.png

    What i want to achieve is paint only these vertices that are at concrete position range from input point, without any affect from camera. Here is my shader graph.

    upload_2020-11-24_17-6-28.png
    Thank you in advance for any help
     
  2. Oxeren

    Oxeren

    Joined:
    Aug 14, 2013
    Posts:
    121
    Decal's vertices and pixels are not actually located on the surface it is projected on, and Position node gives you coordinates from decal's own geometry (and AFAIK a decal is just a box - you can see it's corners on your screenshots). To get world position of surface that the decal is projected on you need to reconstruct world position from depth texture (I think this thread should help).
     
    Kulkejszyn likes this.
  3. Kulkejszyn

    Kulkejszyn

    Joined:
    Feb 21, 2019
    Posts:
    6
    I have tried doing it this way but it looks the same way - camera dependent. Could you look at this graph and tell me what am i doing wrong? upload_2020-11-27_13-3-35.png