From 567a110033a39ff8b6717a5e5982f03d27e57664 Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Thu, 15 Feb 2018 17:01:20 -0500 Subject: [PATCH] Fix disable depth test distance. --- Source/Shaders/BillboardCollectionVS.glsl | 3 ++- Source/Shaders/PointPrimitiveCollectionVS.glsl | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Shaders/BillboardCollectionVS.glsl b/Source/Shaders/BillboardCollectionVS.glsl index e6bce42c8828..80a2ca42f2f8 100644 --- a/Source/Shaders/BillboardCollectionVS.glsl +++ b/Source/Shaders/BillboardCollectionVS.glsl @@ -258,7 +258,7 @@ void main() 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); - v_inverse_depth = -1.0 / positionEC.z; + v_inverse_depth = 1.0 / (czm_modelViewProjectionRelativeToEye * p).w; v_textureCoordinates = textureCoordinates; #ifdef DISABLE_DEPTH_DISTANCE @@ -277,6 +277,7 @@ void main() { // Position z on the near plane. gl_Position.z = -gl_Position.w; + v_inverse_depth = 1.0 / czm_currentFrustum.x; } } #endif diff --git a/Source/Shaders/PointPrimitiveCollectionVS.glsl b/Source/Shaders/PointPrimitiveCollectionVS.glsl index abf8f86761d3..a8f4de6f371d 100644 --- a/Source/Shaders/PointPrimitiveCollectionVS.glsl +++ b/Source/Shaders/PointPrimitiveCollectionVS.glsl @@ -151,6 +151,7 @@ void main() vec4 positionWC = czm_eyeToWindowCoordinates(positionEC); gl_Position = czm_viewportOrthographic * vec4(positionWC.xy, -positionWC.z, 1.0); + v_inverse_depth = 1.0 / (czm_modelViewProjectionRelativeToEye * p).w; #ifdef DISABLE_DEPTH_DISTANCE float disableDepthTestDistance = distanceDisplayConditionAndDisableDepth.z; @@ -168,6 +169,7 @@ void main() { // Position z on the near plane. gl_Position.z = -gl_Position.w; + v_inverse_depth = 1.0 / czm_currentFrustum.x; } } #endif @@ -181,8 +183,6 @@ void main() v_pixelDistance = 2.0 / totalSize; gl_PointSize = totalSize; - v_inverse_depth = 1.0 / (czm_modelViewProjectionRelativeToEye * p).w; - #ifdef RENDER_FOR_PICK v_pickColor = pickColor; #endif