depthClamp.js 792 B

1234567891011121314151617181920212223242526272829
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "// emulated noperspective\n\
  3. #ifndef LOG_DEPTH\n\
  4. varying float v_WindowZ;\n\
  5. #endif\n\
  6. \n\
  7. /**\n\
  8. * Clamps a vertex to the near and far planes.\n\
  9. *\n\
  10. * @name czm_depthClamp\n\
  11. * @glslFunction\n\
  12. *\n\
  13. * @param {vec4} coords The vertex in clip coordinates.\n\
  14. * @returns {vec4} The vertex clipped to the near and far planes.\n\
  15. *\n\
  16. * @example\n\
  17. * gl_Position = czm_depthClamp(czm_modelViewProjection * vec4(position, 1.0));\n\
  18. *\n\
  19. * @see czm_writeDepthClamp\n\
  20. */\n\
  21. vec4 czm_depthClamp(vec4 coords)\n\
  22. {\n\
  23. #ifndef LOG_DEPTH\n\
  24. v_WindowZ = (0.5 * (coords.z / coords.w) + 0.5) * coords.w;\n\
  25. coords.z = clamp(coords.z, -coords.w, +coords.w);\n\
  26. #endif\n\
  27. return coords;\n\
  28. }\n\
  29. ";