Last change
on this file since 76 was
44,
checked in by bknecht, 17 years ago
|
merge from tutorial branche to trunk
|
File size:
1.1 KB
|
Line | |
---|
1 | attribute vec3 tangent; |
---|
2 | |
---|
3 | uniform mat4 world; |
---|
4 | uniform mat4 worldViewProj; |
---|
5 | uniform mat4 texViewProj; |
---|
6 | uniform vec4 lightPosition; // object space |
---|
7 | uniform vec4 shadowDepthRange; |
---|
8 | |
---|
9 | varying vec3 tangentLightDir; |
---|
10 | |
---|
11 | |
---|
12 | void main() |
---|
13 | { |
---|
14 | gl_Position = ftransform(); |
---|
15 | |
---|
16 | vec4 worldPos = world * gl_Vertex; |
---|
17 | |
---|
18 | // Get object space light direction |
---|
19 | vec3 lightDir = normalize(lightPosition.xyz - (gl_Vertex.xyz * lightPosition.w)); |
---|
20 | |
---|
21 | // calculate shadow map coords |
---|
22 | gl_TexCoord[0] = texViewProj * worldPos; |
---|
23 | #if LINEAR_RANGE |
---|
24 | // adjust by fixed depth bias, rescale into range |
---|
25 | gl_TexCoord[0].z = (gl_TexCoord[0].z - shadowDepthRange.x) * shadowDepthRange.w; |
---|
26 | #endif |
---|
27 | |
---|
28 | // pass the main uvs straight through unchanged |
---|
29 | gl_TexCoord[1] = gl_MultiTexCoord0; |
---|
30 | |
---|
31 | // Calculate the binormal (NB we assume both normal and tangent are |
---|
32 | // already normalised) |
---|
33 | vec3 binormal = cross(gl_Normal, tangent); |
---|
34 | |
---|
35 | // Form a rotation matrix out of the vectors |
---|
36 | mat3 rotation = mat3(tangent, binormal, gl_Normal); |
---|
37 | |
---|
38 | // Transform the light vector according to this matrix |
---|
39 | tangentLightDir = normalize(rotation * lightDir); |
---|
40 | |
---|
41 | } |
---|
42 | |
---|
Note: See
TracBrowser
for help on using the repository browser.