Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/GLSL150/GrassReceiverVp.glsl @ 12115

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

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

File size: 1.6 KB
Line 
1#version 150
2
3uniform mat4 world;
4uniform mat4 worldViewProj;
5uniform mat4 texViewProj;
6uniform vec4 camObjPos;
7uniform vec4 objSpaceLight;
8uniform vec4 lightColour;
9uniform vec4 offset;
10
11in vec4 position;
12in vec4 normal;
13in vec4 uv0;
14
15out vec4 oShadowUV;
16out vec3 oUv0;
17out vec4 oColour;
18
19//////////////////////// GRASS SHADOW RECEIVER
20void main()
21{           
22        vec4 mypos = position;
23        vec4 factor = vec4(1.0, 1.0, 1.0, 1.0) - uv0.yyyy;
24        mypos = mypos + offset * factor;
25        gl_Position = worldViewProj * mypos;
26        oUv0.xy = uv0.xy;   
27    // Transform position to world space
28        vec4 worldPos = world * mypos;
29        // calculate shadow map coords
30        oShadowUV = texViewProj * worldPos;
31       
32    // Make vec from vertex to camera
33    vec4 EyeVec = camObjPos - mypos;
34    // Dot the v to eye and the normal to see if they point
35    // in the same direction or opposite
36    float alignedEye = dot(normal, EyeVec); // -1..1
37    // If aligned is negative, we need to flip the normal
38        vec4 myNormal = normal;
39    if (alignedEye < 0.0)
40        myNormal = -normal;
41    //oNormal = normal;
42   
43        // get vertex light direction (support directional and point)
44        vec3 lightVec = normalize(objSpaceLight.xyz - (mypos.xyz * objSpaceLight.w).xyz);
45    // Dot the v to light and the normal to see if they point
46    // in the same direction or opposite
47    float alignedLight = dot(myNormal.xyz, lightVec); // -1..1
48    // If aligned is negative, shadowing/lighting is not possible.
49    oUv0.z = (alignedLight < 0.0) ? 0.0 : 1.0 ;
50         
51    float diffuseFactor = max(alignedLight, 0.0);
52        //oColour = diffuseFactor * lightColour;   
53        oColour = lightColour;   
54}
Note: See TracBrowser for help on using the repository browser.