diff --git a/CHANGES.md b/CHANGES.md index 30a67b3ca88e..8285d7115cff 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Change Log * Fixed `replaceState` bug that was causing the `CesiumViewer` demo application to crash in Safari and iOS * Fixed issue where `Model` and `BillboardCollection` would throw an error if the globe is undefined [#5638](https://github.com/AnalyticalGraphicsInc/cesium/issues/5638) * Fixed issue where the `Model` glTF cache loses reference to the model's buffer data. [#5720](https://github.com/AnalyticalGraphicsInc/cesium/issues/5720) +* Fixed some issues with `disableDepthTestDistance` [#5501](https://github.com/AnalyticalGraphicsInc/cesium/issues/5501) [#5331](https://github.com/AnalyticalGraphicsInc/cesium/issues/5331) [#5621](https://github.com/AnalyticalGraphicsInc/cesium/issues/5621) ### 1.36 - 2017-08-01 diff --git a/Source/Shaders/BillboardCollectionVS.glsl b/Source/Shaders/BillboardCollectionVS.glsl index aa4c4e15baae..b7dede3a6d20 100644 --- a/Source/Shaders/BillboardCollectionVS.glsl +++ b/Source/Shaders/BillboardCollectionVS.glsl @@ -265,11 +265,12 @@ void main() if (disableDepthTestDistance != 0.0) { - gl_Position.z = min(gl_Position.z, gl_Position.w); - - bool clipped = gl_Position.z < -gl_Position.w || gl_Position.z > gl_Position.w; + // Don't try to "multiply both sides" by w. Greater/less-than comparisons won't work for negative values of w. + float zclip = gl_Position.z / gl_Position.w; + bool clipped = (zclip < -1.0 || zclip > 1.0); if (!clipped && (disableDepthTestDistance < 0.0 || (lengthSq > 0.0 && lengthSq < disableDepthTestDistance))) { + // Position z on the near plane. gl_Position.z = -gl_Position.w; } } diff --git a/Source/Shaders/PointPrimitiveCollectionVS.glsl b/Source/Shaders/PointPrimitiveCollectionVS.glsl index cdb0fa4faf4c..05c576606b8d 100644 --- a/Source/Shaders/PointPrimitiveCollectionVS.glsl +++ b/Source/Shaders/PointPrimitiveCollectionVS.glsl @@ -160,11 +160,12 @@ void main() if (disableDepthTestDistance != 0.0) { - gl_Position.z = min(gl_Position.z, gl_Position.w); - - bool clipped = gl_Position.z < -gl_Position.w || gl_Position.z > gl_Position.w; + // Don't try to "multiply both sides" by w. Greater/less-than comparisons won't work for negative values of w. + float zclip = gl_Position.z / gl_Position.w; + bool clipped = (zclip < -1.0 || zclip > 1.0); if (!clipped && (disableDepthTestDistance < 0.0 || (lengthSq > 0.0 && lengthSq < disableDepthTestDistance))) { + // Position z on the near plane. gl_Position.z = -gl_Position.w; } }