Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/skybox/Media/materials/programs/instancingVp.glsl @ 2871

Last change on this file since 2871 was 390, checked in by landauf, 17 years ago

added materials

File size: 1007 bytes
Line 
1uniform vec4 worldMatrix3x4Array[240];
2uniform mat4 viewProjectionMatrix;
3uniform vec4 lightPos;
4uniform vec4 ambient;
5uniform vec4 lightDiffuseColour;
6
7void main()
8{
9
10        // transform by indexed matrix
11        // perform matrix multiplication manually since no 3x4 matrices
12        vec3 transformedPos;
13        vec3 transformedNorm;
14        int instanceOffset = int(gl_MultiTexCoord1.x) * 3;
15        for (int row = 0; row < 3; ++row)
16        {
17                vec4 matrixRow = worldMatrix3x4Array[instanceOffset + row];
18                transformedPos[row] = dot(matrixRow, gl_Vertex);
19#if SHADOW_CASTER
20#else
21                transformedNorm[row] = dot(matrixRow.xyz, gl_Normal);
22#endif
23               
24        }
25       
26        // view / projection
27        gl_Position = viewProjectionMatrix * vec4(transformedPos,1);
28        gl_TexCoord[0] = gl_MultiTexCoord0;
29    gl_FrontSecondaryColor = vec4(0);
30       
31#if SHADOW_CASTER
32        gl_FrontColor = ambient;
33#else
34        vec3 lightDir = normalize(
35                lightPos.xyz -  (transformedPos.xyz * lightPos.w));
36        gl_FrontColor = ambient + clamp(dot(lightDir, transformedNorm),0.0,1.0) * lightDiffuseColour;
37#endif
38       
39}
Note: See TracBrowser for help on using the repository browser.