Last change
on this file since 76 was
44,
checked in by bknecht, 17 years ago
|
merge from tutorial branche to trunk
|
File size:
758 bytes
|
Line | |
---|
1 | uniform mat4 world; |
---|
2 | uniform mat4 worldIT; |
---|
3 | uniform mat4 worldViewProj; |
---|
4 | uniform mat4 texViewProj; |
---|
5 | uniform vec4 lightPosition; |
---|
6 | uniform vec4 lightColour; |
---|
7 | uniform vec4 shadowDepthRange; |
---|
8 | |
---|
9 | |
---|
10 | void main() |
---|
11 | { |
---|
12 | gl_Position = ftransform(); |
---|
13 | |
---|
14 | vec4 worldPos = world * gl_Vertex; |
---|
15 | |
---|
16 | vec3 worldNorm = (worldIT * vec4(gl_Normal, 1)).xyz; |
---|
17 | |
---|
18 | // calculate lighting (simple vertex lighting) |
---|
19 | vec3 lightDir = normalize( |
---|
20 | lightPosition.xyz - (worldPos.xyz * lightPosition.w)); |
---|
21 | |
---|
22 | gl_FrontColor = lightColour * max(dot(lightDir, worldNorm), 0.0); |
---|
23 | |
---|
24 | // calculate shadow map coords |
---|
25 | gl_TexCoord[0] = texViewProj * worldPos; |
---|
26 | #if LINEAR_RANGE |
---|
27 | // adjust by fixed depth bias, rescale into range |
---|
28 | gl_TexCoord[0].z = (gl_TexCoord[0].z - shadowDepthRange.x) * shadowDepthRange.w; |
---|
29 | #endif |
---|
30 | |
---|
31 | } |
---|
32 | |
---|
Note: See
TracBrowser
for help on using the repository browser.