packDepth.js 704 B

1234567891011121314151617181920
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "/**\n\
  3. * Packs a depth value into a vec3 that can be represented by unsigned bytes.\n\
  4. *\n\
  5. * @name czm_packDepth\n\
  6. * @glslFunction\n\
  7. *\n\
  8. * @param {float} depth The floating-point depth.\n\
  9. * @returns {vec3} The packed depth.\n\
  10. */\n\
  11. vec4 czm_packDepth(float depth)\n\
  12. {\n\
  13. // See Aras Pranckevičius' post Encoding Floats to RGBA\n\
  14. // http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/\n\
  15. vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;\n\
  16. enc = fract(enc);\n\
  17. enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n\
  18. return enc;\n\
  19. }\n\
  20. ";