3 * \brief Bump mapping vertex shader.
14 const int MAX_NUMBER_OF_LIGHTS = 10;
21 vec4 halfVector; // used as vec3, expected as normalized
22 vec4 spotDirection; // used as vec3, expected as normalized
27 layout(std140) uniform LightBlock {
28 Light lights[MAX_NUMBER_OF_LIGHTS];
32 uniform mat4 modelViewMatrix;
33 uniform mat4 projectionMatrix;
34 uniform mat4 mvpMatrix;
35 uniform mat3 normalMatrix;
36 uniform mat4 textureMatrix;
38 smooth out vec3 ecVertex;
39 smooth out vec4 texCoord0;
40 smooth out vec3 tcView;
41 smooth out vec3 tcSource[MAX_NUMBER_OF_LIGHTS];
45 // transform vertex position, normal, tangent, and binormal into eye coordinates
46 ecVertex = (modelViewMatrix * vVertex).xyz;
47 vec3 ecNormal = normalMatrix * vNormal;
48 vec3 ecTangent = normalMatrix * vTangent;
49 vec3 ecBinormal = normalMatrix * vBinormal;
51 // create transformation to tangent space
52 vec3 ecN = normalize(ecNormal);
53 vec3 ecT = normalize(ecTangent);
54 vec3 ecB = normalize(ecBinormal);
55 mat3 ec2tcTrans = mat3(
58 ecT.z, ecB.z, ecN.z );
60 // transform view direction to tangent space
61 tcView = ec2tcTrans * (-ecVertex);
63 // transform light source directions to tangent space
64 for (int i = 0; i < nLights; ++i) {
65 if (lights[i].position.w < 0.001) {
67 tcSource[i] = ec2tcTrans * lights[i].position.xyz;
70 // point or spot light
71 tcSource[i] = ec2tcTrans * (lights[i].position.xyz - ecVertex);
76 gl_Position = mvpMatrix * vVertex;
77 texCoord0 = textureMatrix * vTexCoord0;