In the glext.h header there is the group of functions with the prefix glTangent. It has signatures similar to the glVertex and glNormal function groups (it contains functions for each type and glTangentPointer). I guess it is an vertex attribute as the normal, the color, etc...

But what meaning does the tangent attribute have? And in which context is it used?

Edit: The term Tangent does make sense to me. But when the normal vector is already given, why also give the tangent vector?

My approach to answer my own question:

The glTangent allows to add a tangent vector to a vertex. It has no special meaning in classic rendering and does not replace normals. But it is used to implement bump maps. The shader brings the attribute into scope through the following GLSL declaration:

attribute vec4 glTangent4f;

The following sources only focus on the shader code and only mention, that the attribute is given by an engine. I guess that the engine itself calls one of the glTangent-functions.


  1. https://www.geeks3d.com/20091019/shader-library-bump-mapping-shader-with-multiple-lights-glsl/
  2. http://probesys.blogspot.com/2011/01/tbn-matrix-explained_02.html?m=1


The following code snipped I found sets up the shader variables. It names the tangent vector variable GLTangent. It also sets up more common variables like GLVertex or GLColor.

glBindAttribLocation(p, VETYPE_TANGENT, "GLTangent");

Then the variable is accessed through

attribute vec4 GLTangent;
  • \$\begingroup\$ Adding the tangent vector makes no sense to me, when you already have the normal vectors of a model. \$\endgroup\$
    – cmdLP
    Jul 19, 2019 at 16:54
  • \$\begingroup\$ If you're doing tangent space effects like normal mapping, parallax occlusion mapping, etc. then you need a tangent vector to specify which one tangent space to apply the effect in. Without this, you have an infinite number of tangents you could choose for a given normal, and only one of them will correctly match the layout/channel conventions of your maps. This is the difference between a normal map showing highlights facing toward the light, or getting them backwards so the faces curving away from the light get brighter. \$\endgroup\$
    – DMGregory
    Jul 19, 2019 at 17:53

1 Answer 1


Tangent is a regular math term. As google describes it:

a straight line or plane that touches a curve or curved surface at a point, but if extended does not cross it at that point.

enter image description here

It's always perpendicular with the normal vector.

It can be calculated from the normal vector alone, but since there are infinitely many tangents to any 3d vector, it's not always ideal to let OpenGL do it. It's used to create a 3d coordinate system where the normal always points upward (with two perpendicular axes, there can only be one, that's perpendicular to both). Illustration from http://www.opengl-tutorial.org/hu/intermediate-tutorials/tutorial-13-normal-mapping/:

enter image description here

Vector based coordinate systems are great, because we can create matrices, that transform arbitary vectors from the global coordinate system into the one we defined (in this case, into the tangent space) and vice-versa.

OpenGL probably uses the tangents to do normal mapping, since normals maps (almost) always contain the vectors in a local coordinate system. You need to transform them from the tangent space back to global space for them to be useful.


Not the answer you're looking for? Browse other questions tagged .