Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSLES/DepthShadowmapNormalMapReceiverVp.glsles @ 12091

Last change on this file since 12091 was 12091, checked in by wiesep, 5 years ago

Updated programs and adjusted Material to work with GLSL>150

File size: 1.3 KB
Line 
1#version 100
2precision highp int;
3precision highp float;
4
5attribute vec3 tangent;
6attribute vec4 position;
7attribute vec3 normal;
8
9uniform mat4 world;
10uniform mat4 worldViewProj;
11uniform mat4 texViewProj;
12uniform vec4 lightPosition; // object space
13uniform vec4 shadowDepthRange;
14
15varying vec3 tangentLightDir;
16varying vec4 vUv0;
17varying vec4 vUv1;
18
19attribute vec4 uv0;
20attribute vec4 uv1;
21
22void main()
23{
24        gl_Position = worldViewProj * position;
25       
26        vec4 worldPos = world * position;
27vec4 lightPos = vec4(300.0, 750.0, -700.0, 1.0);
28
29        // Get object space light direction
30    vec3 lightDir = normalize(lightPos.xyz -  (position.xyz * lightPos.w));
31
32        // calculate shadow map coords
33        vUv0 = texViewProj * worldPos;
34#if LINEAR_RANGE
35        // adjust by fixed depth bias, rescale into range
36        vUv0.z = (uv0.z - shadowDepthRange.x) * shadowDepthRange.w;
37#endif
38
39        vUv1 = uv1;
40
41        // Calculate the binormal (NB we assume both normal and tangent are
42        // already normalised)
43        vec3 binormal = cross(normal, tangent);
44
45        // Form a rotation matrix out of the vectors, column major for glsl es
46        mat3 rotation = mat3(vec3(tangent[0], binormal[0], normal[0]),
47                                                vec3(tangent[1], binormal[1], normal[1]),
48                                                vec3(tangent[2], binormal[2], normal[2]));
49   
50        // Transform the light vector according to this matrix
51        tangentLightDir = normalize(rotation * lightDir);
52}
Note: See TracBrowser for help on using the repository browser.