unpackDepth.glsl 497 B

12345678910111213141516
  1. /**
  2. * Unpacks a vec4 depth value to a float in [0, 1) range.
  3. *
  4. * @name czm_unpackDepth
  5. * @glslFunction
  6. *
  7. * @param {vec4} packedDepth The packed depth.
  8. *
  9. * @returns {float} The floating-point depth in [0, 1) range.
  10. */
  11. float czm_unpackDepth(vec4 packedDepth)
  12. {
  13. // See Aras Pranckevičius' post Encoding Floats to RGBA
  14. // http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/
  15. return dot(packedDepth, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));
  16. }