OpenGL UV-derivated tangent space normal mapping

This topic is 3626 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi all, I have problems with tangent space normal mapping in GLSL. The model is created in 3Dmax together with normal-height map baked from a high-poly model. I want to derivate tangent space from UV as described in: http://www.blacksmith-studios.dk/projects/downloads/tangent_matrix_derivation.php The tangent space is calculated for each fragment using (V, V+dFdx(V), V+dFdy(V)) as base triangle (with corresponding UV set) for the derivation formula. The problem is that the normal calculated may have wrong direction because of inverse UV set. In order to get the correct direction I need the original face normal. Those are my thoughts about that: 1. The face normal is nevertheless calculated during polygon rasterization in OpenGL because it's required for the face culling check. So why there's no gl_FaceNormal in GLSL predefined uniforms? Having such a value I could easily derivate the correct tangent space. 2. I use vertex,tex_coord & index VBOs to pass data to GPU. How can I pass per-face data using indexed vertexes? (if I could I'd precalculate face normals). 3. Do you know, what tangent space is used in 3Dmax for normal mapping? in Blender? If one uses triangle-based UV derivation, I'll get incorrect normals while trying to derivate tangent space per fragment using dFd? functions, right? Thanks in advance

Share on other sites
Found acceptable solution for (1-2).
As I render only front facing triangles, all I need to check is dot(calculated_normal, view_vector) >= 0. And multiply calculated_normal by -1 if dot()<0.

Anyway, my 3Ds model normal map doesn't look good. Question (3) remains open.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• Forum Statistics

• Total Topics
633705
• Total Posts
3013463
×