2 // ambient+diffuse+specular+normalmap+attenuation+cubemap+fog shader
3 // written by Forest 'LordHavoc' Hale
5 // use half floats if available for math performance
18 uniform vec3 LightPosition;
20 varying vec2 TexCoord;
21 varying myhvec3 CubeVector;
22 varying vec3 LightVector;
24 #if defined(USESPECULAR) || defined(USEFOG) || defined(USEOFFSETMAPPING)
25 uniform vec3 EyePosition;
26 varying vec3 EyeVector;
29 // TODO: get rid of tangentt (texcoord2) and use a crossproduct to regenerate it from tangents (texcoord1) and normal (texcoord3)
33 // copy the surface texcoord
34 TexCoord = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0);
36 // transform vertex position into light attenuation/cubemap space
37 // (-1 to +1 across the light box)
38 CubeVector = vec3(gl_TextureMatrix[3] * gl_Vertex);
40 // transform unnormalized light direction into tangent space
41 // (we use unnormalized to ensure that it interpolates correctly and then
42 // normalize it per pixel)
43 vec3 lightminusvertex = LightPosition - gl_Vertex.xyz;
44 LightVector.x = -dot(lightminusvertex, gl_MultiTexCoord1.xyz);
45 LightVector.y = -dot(lightminusvertex, gl_MultiTexCoord2.xyz);
46 LightVector.z = -dot(lightminusvertex, gl_MultiTexCoord3.xyz);
48 #if defined(USESPECULAR) || defined(USEFOG) || defined(USEOFFSETMAPPING)
49 // transform unnormalized eye direction into tangent space
50 vec3 eyeminusvertex = EyePosition - gl_Vertex.xyz;
51 EyeVector.x = -dot(eyeminusvertex, gl_MultiTexCoord1.xyz);
52 EyeVector.y = -dot(eyeminusvertex, gl_MultiTexCoord2.xyz);
53 EyeVector.z = -dot(eyeminusvertex, gl_MultiTexCoord3.xyz);
56 // transform vertex to camera space, using ftransform to match non-VS
58 gl_Position = ftransform();