Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/trunk/shaders/mapped_water.vert @ 4065

Last change on this file since 4065 was 3824, checked in by patrick, 19 years ago

sharers moved again

File size: 1.2 KB
Line 
1varying vec4 refrCoords;
2varying vec4 normCoords;
3varying vec4 viewCoords;
4varying vec4 viewTangetSpace;
5varying vec4 lightTangetSpace;
6
7uniform vec4 lightPos, cameraPos;
8
9
10void main()
11{
12        // Because we have a flat plane for water we already know the vectors for tangent space
13        vec4 tangent = vec4(1.0, 0.0, 0.0, 0.0);
14        vec4 normal = vec4(0.0, 1.0, 0.0, 0.0);
15        vec4 biTangent = vec4(0.0, 0.0, 1.0, 0.0);
16
17        // Calculate the vector coming from the vertex to the camera
18        vec4 viewDir = cameraPos - gl_Vertex;
19
20        // Compute tangent space for the view direction
21        viewTangetSpace.x = dot(viewDir, tangent);
22        viewTangetSpace.y = dot(viewDir, biTangent);
23        viewTangetSpace.z = dot(viewDir, normal);
24        viewTangetSpace.w = 1.0;
25
26        // Calculate the vector that the light hits the vertex
27        vec4 lightDir = lightPos - gl_Vertex;
28
29        // Compute tangent space for the light direction
30        lightTangetSpace.x = dot(lightDir, tangent);
31        lightTangetSpace.y = dot(lightDir, biTangent);
32        lightTangetSpace.z = dot(lightDir, normal);
33        lightTangetSpace.w = 1.0;
34
35        refrCoords = gl_MultiTexCoord1;
36        normCoords = gl_MultiTexCoord2;
37
38        // This calculates our current projection coordinates
39        viewCoords = gl_ModelViewProjectionMatrix * gl_Vertex;
40
41        gl_Position = viewCoords;
42}
Note: See TracBrowser for help on using the repository browser.