PDA

View Full Version : How to Calculate tangent ?



PiouPiou
07-26-2013, 10:04 AM
Hello to all,

I try to understand the normal map

Problem, I try to calculate the tangent I have to send per vertex.

How to calculate it?

example with a triangle in front :






Position
Normal
Tangente


vertex 1
-1.0f, 1.0f, 1.0f,
0.0f, 0.0f, 1.0f,
?, ? , ?,


vertex 2
-1.0f,-1.0f, 1.0f,
0.0f, 0.0f, 1.0f,
?, ? , ?,


vertex 3
1.0f, -1.0f, 1.0f,
0.0f, 0.0f, 1.0f,
?, ? , ?,



Thanks in advance !

hlewin
07-26-2013, 06:15 PM
I can just give you a short description what needs to be done:
What you need to do is to find a mapping from the space defined by the triangle into the space used by the normalmap-texture - or better said: the other way around.
From the texture-coordinates at the vertices and the vertices themselves you can derive where along the X- and Y-axes of the normalmap-texture-space go in the triangle-texture-space.

thokra
07-27-2013, 03:12 AM
@PiouPiou: For the basics, check this (http://www.terathon.com/code/tangent.html)* out. When you got the basic math right, check this (http://www.crytek.com/cryengine/presentations/triangle-mesh-tangent-space-calculation) out.

* Lengyel, Eric. “Computing Tangent Space Basis Vectors for an Arbitrary Mesh”. Terathon Software 3D Graphics Library, 2001.

PiouPiou
07-27-2013, 03:32 AM
@PiouPiou: For the basics, check this (http://www.terathon.com/code/tangent.html)* out. When you got the basic math right, check this (http://www.crytek.com/cryengine/presentations/triangle-mesh-tangent-space-calculation) out.

* Lengyel, Eric. “Computing Tangent Space Basis Vectors for an Arbitrary Mesh”. Terathon Software 3D Graphics Library, 2001.

thank you I will read the paper. I would say to you if I understood or not;-)

PiouPiou
09-03-2013, 02:20 AM
many thanks to all after my holliday it' works ;-)