Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Updated programs and adjusted Material to work with GLSL>150

File size: 1.2 KB
Line 
1#version 100
2
3precision mediump int;
4precision mediump float;
5
6uniform float fixedDepthBias;
7uniform float gradientClamp;
8uniform float gradientScaleBias;
9uniform sampler2D shadowMap;
10uniform sampler2D diffuseMap;
11uniform vec4 vertexLight;
12
13varying vec4 oUv0;
14varying vec4 oShadowUV;
15
16//////////////////////// GRASS SHADOW RECEIVER
17void main()
18{
19    if (oShadowUV.z > 0.0)
20    {
21       vec4 diffuse = texture2D(diffuseMap, oUv0.xy);
22       if (diffuse.a > 0.001)
23       {
24            // Do manual alpha rejection because it is not built into OpenGL ES 2
25            if (diffuse.a < 0.588)
26            {
27                discard;
28            }
29            gl_FragColor = vec4(0.0);
30       }
31       else
32       {
33            vec4 normShadowUV = oShadowUV / oShadowUV.w;
34            vec4 shadowDepths = texture2D(shadowMap, normShadowUV.xy);
35
36            float gradientFactor = gradientClamp * gradientScaleBias;
37            float depthAdjust = gradientFactor + fixedDepthBias * shadowDepths.x;
38            float centerdepth = shadowDepths.x + depthAdjust;
39
40            gl_FragColor = (centerdepth > normShadowUV.z) ? vec4(vertexLight.rgb, diffuse.a) : vec4(0.0, 0.0, 0.0, diffuse.a);
41       }
42    }
43    else
44    {
45        gl_FragColor = vec4(0.0);
46    }
47}
Note: See TracBrowser for help on using the repository browser.