Last change
on this file since 12302 was
12115,
checked in by wiesep, 6 years ago
|
Changed folder structure, deletet some unused files and cleaned up code
|
File size:
1007 bytes
|
Line | |
---|
1 | uniform vec4 worldMatrix3x4Array[240]; |
---|
2 | uniform mat4 viewProjectionMatrix; |
---|
3 | uniform vec4 lightPos; |
---|
4 | uniform vec4 ambient; |
---|
5 | uniform vec4 lightDiffuseColour; |
---|
6 | |
---|
7 | void 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.