translateRelativeToEye.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "/**\n\
  3. * Translates a position (or any <code>vec3</code>) that was encoded with {@link EncodedCartesian3},\n\
  4. * and then provided to the shader as separate <code>high</code> and <code>low</code> bits to\n\
  5. * be relative to the eye. As shown in the example, the position can then be transformed in eye\n\
  6. * or clip coordinates using {@link czm_modelViewRelativeToEye} or {@link czm_modelViewProjectionRelativeToEye},\n\
  7. * respectively.\n\
  8. * <p>\n\
  9. * This technique, called GPU RTE, eliminates jittering artifacts when using large coordinates as\n\
  10. * described in {@link http://help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm|Precisions, Precisions}.\n\
  11. * </p>\n\
  12. *\n\
  13. * @name czm_translateRelativeToEye\n\
  14. * @glslFunction\n\
  15. *\n\
  16. * @param {vec3} high The position's high bits.\n\
  17. * @param {vec3} low The position's low bits.\n\
  18. * @returns {vec3} The position translated to be relative to the camera's position.\n\
  19. *\n\
  20. * @example\n\
  21. * in vec3 positionHigh;\n\
  22. * in vec3 positionLow;\n\
  23. *\n\
  24. * void main()\n\
  25. * {\n\
  26. * vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);\n\
  27. * gl_Position = czm_modelViewProjectionRelativeToEye * p;\n\
  28. * }\n\
  29. *\n\
  30. * @see czm_modelViewRelativeToEye\n\
  31. * @see czm_modelViewProjectionRelativeToEye\n\
  32. * @see czm_computePosition\n\
  33. * @see EncodedCartesian3\n\
  34. */\n\
  35. vec4 czm_translateRelativeToEye(vec3 high, vec3 low)\n\
  36. {\n\
  37. vec3 highDifference = high - czm_encodedCameraPositionMCHigh;\n\
  38. vec3 lowDifference = low - czm_encodedCameraPositionMCLow;\n\
  39. \n\
  40. return vec4(highDifference + lowDifference, 1.0);\n\
  41. }\n\
  42. ";