Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/skybox/Media/materials/programs/DepthShadowmapNormalMapReceiverVp.glsl @ 2243

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

added materials

File size: 1.1 KB
Line 
1attribute vec3 tangent;
2
3uniform mat4 world;
4uniform mat4 worldViewProj;
5uniform mat4 texViewProj;
6uniform vec4 lightPosition; // object space
7uniform vec4 shadowDepthRange;
8
9varying vec3 tangentLightDir;
10
11
12void 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.