From 6e9fc3e6446e5b261f6e943859f867c54bc6269d Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Mon, 9 Apr 2018 09:13:06 -0400 Subject: [PATCH] Use eye coordinates instead of window coordinates in the billboard vertex shader. --- Source/Shaders/BillboardCollectionVS.glsl | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/Shaders/BillboardCollectionVS.glsl b/Source/Shaders/BillboardCollectionVS.glsl index cf0f97840e3d..039bd3323928 100644 --- a/Source/Shaders/BillboardCollectionVS.glsl +++ b/Source/Shaders/BillboardCollectionVS.glsl @@ -71,23 +71,23 @@ vec4 computePositionWindowCoordinates(vec4 positionEC, vec2 imageSize, float sca positionEC.xy += halfSize; } - vec4 positionWC = czm_eyeToWindowCoordinates(positionEC); + float mpp = czm_metersPerPixel(positionEC); - if (sizeInMeters) + if (!sizeInMeters) { - originTranslate /= czm_metersPerPixel(positionEC); + originTranslate *= mpp; } - positionWC.xy += originTranslate; + positionEC.xy += originTranslate; if (!sizeInMeters) { - positionWC.xy += halfSize; + positionEC.xy += halfSize * mpp; } - positionWC.xy += translate; - positionWC.xy += (pixelOffset * czm_resolutionScale); + positionEC.xy += translate * mpp; + positionEC.xy += (pixelOffset * czm_resolutionScale) * mpp; - return positionWC; + return positionEC; } void main() @@ -255,14 +255,14 @@ void main() } #endif -#ifdef LOG_DEPTH - czm_vertexLogDepth(czm_projection * positionEC); -#endif - vec4 positionWC = computePositionWindowCoordinates(positionEC, imageSize, scale, direction, origin, translate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters); - gl_Position = czm_viewportOrthographic * vec4(positionWC.xy, -positionWC.z, 1.0); + gl_Position = czm_projection * positionWC; v_textureCoordinates = textureCoordinates; +#ifdef LOG_DEPTH + czm_vertexLogDepth(); +#endif + #ifdef DISABLE_DEPTH_DISTANCE float disableDepthTestDistance = distanceDisplayConditionAndDisableDepth.z; if (disableDepthTestDistance == 0.0 && czm_minimumDisableDepthTestDistance != 0.0)