ShadowFragShader.fsh 540 B

1234567891011121314151617181920
  1. uniform highp sampler2D sShadow;
  2. uniform sampler2D sTexture;
  3. varying highp vec4 projCoord;
  4. varying mediump vec2 texCoord;
  5. varying lowp vec3 LightIntensity;
  6. void main ()
  7. {
  8. // Subtract a small magic number to account for floating-point error
  9. highp float comp = (projCoord.z / projCoord.w) - 0.03;
  10. highp float depth = texture2DProj(sShadow, projCoord).r;
  11. lowp float val = comp <= depth ? 1.0 : 0.4;
  12. lowp vec3 color = texture2D(sTexture, texCoord).rgb * LightIntensity * val;
  13. gl_FragColor = vec4(color, 1.0);
  14. }