Search Unity

Terrain: Shader wants tangents, but the mesh doesn't have them

Discussion in 'Shaders' started by DaReign, Nov 13, 2013.

  1. DaReign

    DaReign

    Joined:
    Apr 12, 2013
    Posts:
    79
    Hi everyone
    I did everything like in this video tutorial http://www.youtube.com/watch?v=Ra3ug5NWZq8. I Read many posts in this forum and as I see unity terrain doesn't have tangents by default, I must calculate tangents manually but I completly don't know how to do this. I just want't to use normal map with my cliff layer and use Nature > Terrain > Bumped Specular shader like in this video.
     
  2. bricevdm

    bricevdm

    Joined:
    Nov 4, 2009
    Posts:
    34
    I don't think you need tangents for terrains, since they are all positionned in the same way in the world. The tangent and bitangent is thus just a swizzle of the normal vector (swapping its components and using minus signs).
     
  3. jamesflowerdew

    jamesflowerdew

    Joined:
    Apr 29, 2009
    Posts:
    10
    Yes, but how to get rid of the error?
    Is there a way of saying "no, you can't have tagents, but you look great anyway" to the shader or "Unity terrain give yourself tangents so my shader will shut up".
    It is not an accessible mesh so you can't add and calculate them.
     
  4. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    You'll have to adjust the shader so that it doesn't need model tangents. Instead use tangents generated in the shader as B.Vandemoortele says.