oolite/Resources/Shaders/oolite-default-planet.vertex

28 lines
744 B
Plaintext

// No vNormal, because normal is always 0,0,1 in tangent space.
varying vec3 vEyeVector;
varying vec2 vTexCoords;
varying vec3 vLight1Vector;
varying vec3 vCoords;
void main(void)
{
vCoords = gl_Vertex.xyz;
// Build tangent basis.
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
vec3 binormal = cross(normal, gl_NormalMatrix * vec3(0, 1, 0));
vec3 tangent = -cross(normal, binormal);
mat3 TBN = mat3(tangent, binormal, normal);
vec3 eyeVector = -vec3(gl_ModelViewMatrix * gl_Vertex);
vEyeVector = eyeVector * TBN;
vec3 light1Vector = gl_LightSource[1].position.xyz + eyeVector;
vLight1Vector = light1Vector * TBN;
vTexCoords = gl_MultiTexCoord0.st;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}