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.
Sources:
- https://www.geeks3d.com/20091019/shader-library-bump-mapping-shader-with-multiple-lights-glsl/
- http://probesys.blogspot.com/2011/01/tbn-matrix-explained_02.html?m=1
/Sources
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;