Sha256: 3fa84654fd5bf7e4d281494c63be6b2785948dc6ad8365f331ae729a364f9077

Contents?: true

Size: 1.49 KB

Versions: 8

Compression:

Stored size: 1.49 KB

Contents

/**
 * Translates a position (or any <code>vec3</code>) that was encoded with {@link EncodedCartesian3},
 * and then provided to the shader as separate <code>high</code> and <code>low</code> 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.
 * <p>
 * This technique, called GPU RTE, eliminates jittering artifacts when using large coordinates as
 * described in <a href="http://blogs.agi.com/insight3d/index.php/2008/09/03/precisions-precisions/">Precisions, Precisions</a>.
 * </p>
 *
 * @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);
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cesium-0.25.0 app/assets/javascripts/Shaders/Builtin/Functions/translateRelativeToEye.glsl
cesium-0.24.1 app/assets/javascripts/Shaders/Builtin/Functions/translateRelativeToEye.glsl
cesium-0.24.0 app/assets/javascripts/Shaders/Builtin/Functions/translateRelativeToEye.glsl
cesium-0.23.0 app/assets/javascripts/Shaders/Builtin/Functions/translateRelativeToEye.glsl
cesium-0.22.0 app/assets/javascripts/Shaders/Builtin/Functions/translateRelativeToEye.glsl
cesium-0.21.1 app/assets/javascripts/Shaders/Builtin/Functions/translateRelativeToEye.glsl
cesium-0.21 app/assets/javascripts/Shaders/Builtin/Functions/translateRelativeToEye.glsl
cesium-0.20.0 app/assets/javascripts/Shaders/Builtin/Functions/translateRelativeToEye.glsl