Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/GLSL150/DepthShadowmapNormalMapReceiverVp.glsl @ 12302

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

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

File size: 1.2 KB
RevLine 
[12115]1#version 150
2
3in vec3 tangent;
4in vec3 normal;
5in vec4 vertex;
6in vec4 uv1;
7
8uniform mat4 world;
9uniform mat4 worldViewProj;
10uniform mat4 texViewProj;
11uniform vec4 lightPosition; // object space
12uniform vec4 shadowDepthRange;
13
14out vec3 tangentLightDir;
15out vec4 oUv0;
16out vec4 oUv1;
17
18void main()
19{
20        gl_Position = worldViewProj * vertex;
21       
22        vec4 worldPos = world * vertex;
23
24        // Get object space light direction
25    vec3 lightDir = normalize(lightPosition.xyz - (vertex.xyz * lightPosition.w));
26
27        // calculate shadow map coords
28        oUv0 = texViewProj * worldPos;
29#if LINEAR_RANGE
30        // adjust by fixed depth bias, rescale into range
31        oUv0.z = (oUv0.z - shadowDepthRange.x) * shadowDepthRange.w;
32#endif
33
34        // pass the main uvs straight through unchanged
35        oUv1 = uv1;
36
37        // Calculate the binormal (NB we assume both normal and tangent are
38        // already normalised)
39        vec3 binormal = cross(normal, tangent); 
40
41        // Form a rotation matrix out of the vectors
42        mat3 rotation = mat3(tangent, binormal, normal); 
43//      mat3 rotation = mat3(vec3(tangent[0], binormal[0], normal[0]),
44//                                              vec3(tangent[1], binormal[1], normal[1]),
45//                                              vec3(tangent[2], binormal[2], normal[2]));
46
47        // Transform the light vector according to this matrix
48        tangentLightDir = normalize(rotation * lightDir); 
49}
50
Note: See TracBrowser for help on using the repository browser.