/**
* Translates a position (or any vec3
) that was encoded with {@link EncodedCartesian3},
* and then provided to the shader as separate high
and low
bits to
* be relative to the eye. As shown in the example, the position can then be transformed in eye
* or clip coordinates using {@link czm_modelViewRelativeToEye} or {@link czm_modelViewProjectionRelativeToEye},
* respectively.
*
* This technique, called GPU RTE, eliminates jittering artifacts when using large coordinates as * described in {@link http://help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm|Precisions, Precisions}. *
* * @name czm_translateRelativeToEye * @glslFunction * * @param {vec3} high The position's high bits. * @param {vec3} low The position's low bits. * @returns {vec3} The position translated to be relative to the camera's position. * * @example * attribute vec3 positionHigh; * attribute vec3 positionLow; * * void main() * { * vec4 p = czm_translateRelativeToEye(positionHigh, positionLow); * gl_Position = czm_modelViewProjectionRelativeToEye * p; * } * * @see czm_modelViewRelativeToEye * @see czm_modelViewProjectionRelativeToEye * @see czm_computePosition * @see EncodedCartesian3 */ vec4 czm_translateRelativeToEye(vec3 high, vec3 low) { vec3 highDifference = high - czm_encodedCameraPositionMCHigh; vec3 lowDifference = low - czm_encodedCameraPositionMCLow; return vec4(highDifference + lowDifference, 1.0); }