Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Shader Graph - Check angle of face

Discussion in 'Shaders' started by whidzee, Mar 23, 2019.

  1. whidzee

    whidzee

    Joined:
    Nov 20, 2012
    Posts:
    161
    Hey gang, I am building a river shader and i have worked out how to get a tiling texture to work. so my river looks ok, but i want it to speed up or slow down based upon the angle of the river, and i want it to turn into a waterfall if i make it quite steep.

    what node should I use in order to get the angle of the polygon? I feel once i get this i should be able to work out the rest
     
  2. Necronomicron

    Necronomicron

    Joined:
    Mar 4, 2015
    Posts:
    108
    I'm not expert in shaders yet but try to search for "normal". I mean face normal, not normal map.
     
  3. whidzee

    whidzee

    Joined:
    Nov 20, 2012
    Posts:
    161
    I managed to solve it. I used a Normal Vector node, connected to an Absolute node and then multiplied it by itsself.

    This gives you x y and z directions from your mesh. As I was only needing the Y direction I used a split node to get the G channel and i can then plug that into a blend node or wherever else you need it.

    upload_2019-3-23_11-54-39.png
     
  4. BmxGrilled

    BmxGrilled

    Joined:
    Jan 27, 2014
    Posts:
    238
    Hey I know this post is old, but I just have to say however different your end goal was to mine, I find this extremely helpful in fixing a custom triplanar blend node to work better, so thank you for posting this!
     
  5. davidrochin

    davidrochin

    Joined:
    Dec 17, 2015
    Posts:
    72
    Thank you for posting the answer. It would be cool if someone could explain why we have to multiply the absolute normals by themselves. I can't understand that part.