Search Unity

Will tangent space normal map cause issue for lighting along uv border?

Discussion in 'General Graphics' started by bobozzz, Oct 1, 2017.

  1. bobozzz

    bobozzz

    Joined:
    May 27, 2015
    Posts:
    38
    Hi!

    When I use tangent space vector displacement map, it causes a huge crack along the UV seam. I figured out it is because along the uv border, the vertices which share the same position have different tangent and bi-tangent directions, so if using tangent space vector displacement map, they are displaced in different direction.

    That makes me think of the tangent space normal map. If this is the nature of tangent space, that means tangent space normal map should cause some problems along uv border for specular highlight too. Because the vertex tangent is being used when I convert tangent space normal to world space normal, and the vertices with the same position have totally different tangent direction, and that will lead to different world space normal in the fragment shader.

    Theoretically that should cause huge problem for lighting, right? I wonder why I haven't seen too much problem for that.

    Thanks!
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Because when you use a tangent space normal map you're usually using either:
    • A tangent space normal map generated for that specific model which accounts for the tangent orientation. i.e.: Baking a high poly model's normals on to it's lower poly in-game model.
    • A mesh with no significant seams and/or uniform tangents. i.e.: A repeating texture on a floor, wall, or terrain.
    • A normal map as a detail normal just to add some extra texture and noise on top of another more defined normal map in which case the seams aren't as obvious.
    In reality, it does actually cause a problem even with normal maps generated for a specific model. This has to do with the precision of an 8 bit normal map and the lack of a true "0.0,0.0,1.0" in the 0-255 range (127 is ~0.498 and 128 is ~0.502). It also has the same problem any textures have on a seam due to the texel alignment likely not matching. The thing is these are rarely obvious as once you have an albedo texture on top of it. Plus for real time models people tend to be good about hiding the UV seams in places you wont see. They're also never going to be as obvious as the giant hole that vector displacement (or even basic tessellation) can cause.
     
    bobozzz likes this.
  3. bobozzz

    bobozzz

    Joined:
    May 27, 2015
    Posts:
    38
    Thank you! Another follow-up question, because tangent space vector displacement is causing a giant crack, I am thinking about object space vector displacement map. I wonder what's the difference between the two, other than tangent space vector displacement can be used on animated model and object space can only be used for static model. Is tangent space more accurate than object space? After converting to world space, are they generating the same vector?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Is it more accurate? Not really. Assuming you're using 8 bit per channel textures for this, tangent space maps could conceivably be better looking just because you're building off of the higher precision normals and tangents of the mesh. Accuracy is a bit of a wash though. Once converted to world space they won't be the same vector, but neither will necessarily be the same vector as the source. 8 bpc textures only have so much accuracy. If you're using 16 bit per channel textures then it doesn't really matter if you're using object or tangent space. 16 bit displacement maps are a bit more difficult to use in Unity though just because I don't think it treats them as linear data properly.
     
    bobozzz likes this.
  5. bobozzz

    bobozzz

    Joined:
    May 27, 2015
    Posts:
    38
    I am a little bit confused about this part. Why tangent looks better if using 8 bit per channel textures?
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Lets say you have a smooth curved mesh and are displacing that surface out by 1 unit along the normal.

    With a tangent space vector map, your map could just be a constant value, all of the "shape" is coming from the mesh's normals, so the result is just as smooth as the original mesh.

    With an object space vector map the direction you're offsetting is constantly changing, but you only have that 1/255 precision. The resulting mesh is smooth in some parts, but might have obvious "steps" in some places. Basically the banding in the texture can be apparent.

    It'll depend on how much you're displacing and the kinds of shapes you're using it on or to create for how obvious that banding from the precision would be visible.
     
    bobozzz likes this.
  7. bobozzz

    bobozzz

    Joined:
    May 27, 2015
    Posts:
    38
    Now I understand! Thanks a lot for the explanation! :)