Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/GLSL150/GrassReceiverFp.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: 1.0 KB
Line 
1#version 150
2
3uniform float fixedDepthBias;
4uniform float gradientClamp;
5uniform float gradientScaleBias;
6uniform sampler2D shadowMap;
7uniform sampler2D diffuseMap;
8uniform vec4 vertexLight;
9
10in vec4 oUv0;
11in vec4 oShadowUV;
12
13out vec4 fragColour;
14
15//////////////////////// GRASS SHADOW RECEIVER
16void main()
17{
18    if (oShadowUV.z > 0.0)
19    {
20       vec4 diffuse = texture(diffuseMap, oUv0.xy);
21       if (diffuse.a > 0.001)
22       {
23            fragColour = vec4(0.0);
24       }
25       else
26       {
27            vec4 normShadowUV = oShadowUV / oShadowUV.w;
28            vec4 shadowDepths = texture(shadowMap, normShadowUV.xy);
29
30            float gradientFactor = gradientClamp * gradientScaleBias;
31            float depthAdjust = gradientFactor + fixedDepthBias * shadowDepths.x;
32            float centerdepth = shadowDepths.x + depthAdjust;
33
34            fragColour = (centerdepth > normShadowUV.z) ? vec4(vertexLight.rgb, diffuse.a) : vec4(0.0, 0.0, 0.0, diffuse.a);
35       }
36    }
37    else
38    {
39        fragColour = vec4(0.0);
40    }
41}
Note: See TracBrowser for help on using the repository browser.