Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/data_extern/programs/GLSL/DepthShadowmapNormalMapReceiverVp.glsl @ 12202

Last change on this file since 12202 was 12115, checked in by wiesep, 6 years ago

Changed folder structure, deletet some unused files and cleaned up code

File size: 988 bytes
Line 
1#version 120
2
3uniform mat4 world;
4uniform mat4 worldViewProj;
5uniform mat4 texViewProj;
6uniform vec4 lightPosition; // object space
7
8attribute vec4 vertex;
9attribute vec3 normal;
10attribute vec3 tangent;
11attribute vec4 uv0;
12
13varying vec3 tangentLightDir;
14varying vec4 oUv;
15varying vec2 oUv2;
16
17void main()
18{
19        vec4 worldPos = world * vertex;
20
21        // Get object space light direction
22    vec3 lightDir = normalize(lightPosition.xyz -  (vertex.xyz * lightPosition.w));
23
24        // calculate shadow map coords
25        oUv = texViewProj * worldPos;
26
27        // pass the main uvs straight through unchanged
28        oUv2 = uv0.xy;
29
30        // Calculate the binormal (NB we assume both normal and tangent are
31        // already normalised)
32        vec3 binormal = cross(normal, tangent); 
33
34        // Form a rotation matrix out of the vectors
35        mat3 rotation = mat3(tangent, binormal, normal); 
36   
37        // Transform the light vector according to this matrix
38        tangentLightDir = normalize(rotation * lightDir); 
39       
40        gl_Position = worldViewProj * vertex;
41}
42
Note: See TracBrowser for help on using the repository browser.