diff --git a/CHANGES.md b/CHANGES.md index 525d4c83f74a..7e8642cf57cb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Change Log ##### Fixes :wrench: * Fixed several problems with polylines when the logarithmic depth buffer is enabled, which is the default on most systems. [#8706](https://github.com/CesiumGS/cesium/pull/8706) +* Fixed a bug with very long view ranges requiring multiple frustums even with the logarithmic depth buffer enabled. Previously, such scenes could resolve depth incorrectly. [#8727](https://github.com/CesiumGS/cesium/pull/8727) ### 1.68.0 - 2020-04-01 diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 95cada21c708..e1def3d8e2d1 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -1608,7 +1608,7 @@ import View from './View.js'; */ opaqueFrustumNearOffset : { get : function() { - return this._frameState.useLogDepth ? 0.9 : 0.9999; + return 0.9999; } } }); diff --git a/Source/Shaders/Builtin/Functions/vertexLogDepth.glsl b/Source/Shaders/Builtin/Functions/vertexLogDepth.glsl index bc5f6ed5101c..a840e4b5724e 100644 --- a/Source/Shaders/Builtin/Functions/vertexLogDepth.glsl +++ b/Source/Shaders/Builtin/Functions/vertexLogDepth.glsl @@ -36,7 +36,7 @@ vec4 czm_updatePositionDepth(vec4 coords) { void czm_vertexLogDepth() { #ifdef LOG_DEPTH - v_depthFromNearPlusOne = 1.0 - czm_currentFrustum.x + gl_Position.w; + v_depthFromNearPlusOne = (gl_Position.w - czm_currentFrustum.x) + 1.0; gl_Position = czm_updatePositionDepth(gl_Position); #endif } @@ -58,7 +58,7 @@ void czm_vertexLogDepth() void czm_vertexLogDepth(vec4 clipCoords) { #ifdef LOG_DEPTH - v_depthFromNearPlusOne = 1.0 - czm_currentFrustum.x + clipCoords.w; + v_depthFromNearPlusOne = (clipCoords.w - czm_currentFrustum.x) + 1.0; czm_updatePositionDepth(clipCoords); #endif }