writeDepthClamp.glsl 526 B

12345678910111213141516171819202122232425
  1. // emulated noperspective
  2. #ifndef LOG_DEPTH
  3. varying float v_WindowZ;
  4. #endif
  5. /**
  6. * Clamps a vertex to the far plane by writing the fragments depth.
  7. * <p>
  8. * The shader must enable the GL_EXT_frag_depth extension.
  9. * </p>
  10. *
  11. * @name czm_writeDepthClamp
  12. * @glslFunction
  13. *
  14. * @example
  15. * gl_FragColor = color;
  16. * czm_writeDepthClamp();
  17. *
  18. * @see czm_depthClamp
  19. */
  20. void czm_writeDepthClamp()
  21. {
  22. #if defined(GL_EXT_frag_depth) && !defined(LOG_DEPTH)
  23. gl_FragDepthEXT = clamp(v_WindowZ * gl_FragCoord.w, 0.0, 1.0);
  24. #endif
  25. }