shadowMap.fragment.fx 769 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef FLOAT
  2. #include<packingFunctions>
  3. #endif
  4. varying float vDepthMetric;
  5. #ifdef ALPHATEST
  6. varying vec2 vUV;
  7. uniform sampler2D diffuseSampler;
  8. #endif
  9. uniform vec3 biasAndScale;
  10. uniform vec2 depthValues;
  11. #ifdef DEPTHCLAMP
  12. varying float z;
  13. #endif
  14. void main(void)
  15. {
  16. #ifdef ALPHATEST
  17. if (texture2D(diffuseSampler, vUV).a < 0.4)
  18. discard;
  19. #endif
  20. float depth = vDepthMetric;
  21. #ifdef DEPTHCLAMP
  22. depth = clamp(((z + depthValues.x) / (depthValues.y)) + biasAndScale.x, 0.0, 1.0);
  23. gl_FragDepth = depth;
  24. #endif
  25. #ifdef ESM
  26. depth = clamp(exp(-min(87., biasAndScale.z * depth)), 0., 1.);
  27. #endif
  28. #ifdef FLOAT
  29. gl_FragColor = vec4(depth, 1.0, 1.0, 1.0);
  30. #else
  31. gl_FragColor = pack(depth);
  32. #endif
  33. }