Search Unity

Question Wrong Shader Graph slope calculation on a spherical planet mesh

Discussion in 'Shader Graph' started by -DarkTiger-, Sep 6, 2020.

  1. -DarkTiger-

    -DarkTiger-

    Joined:
    May 6, 2015
    Posts:
    8
    Hello,
    I have a problem with shader graph and slope calculation on a spherical planet mesh.
    My shader do a dot between triangle normal and normalized subtraction beetween triangle position and center of the planet, but it doesn't work, the dot operation output wrong values...

    What I wrong on this?

    Thanks for the help!

     

    Attached Files:

  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Hi,
    Your own graph is almost correct, but you should calculate a vector so that it points from the center of your planet to the current surface point. i.e. something like this:

    planet_1.PNG

    Which would result to something like this:
    planet_2.PNG
    I think this looks somewhat correct. Didn't have time to test it much and I'm a bit tired. :)
     
  3. -DarkTiger-

    -DarkTiger-

    Joined:
    May 6, 2015
    Posts:
    8
    Hello Olmi, thanks for the reply!
    I have tried the Vector 3 0,0,0 change, but with no success, I get all planet green :-(

     

    Attached Files:

  4. -DarkTiger-

    -DarkTiger-

    Joined:
    May 6, 2015
    Posts:
    8
    I have solved! My procedural mesh needed normals recalculation.
    Thanks! ;)
     
    Last edited: Sep 17, 2020