Jump to content
  • Advertisement
Sign in to follow this  
kvark

OpenGL UV-derivated tangent space normal mapping

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!