diff --git a/CHANGES.md b/CHANGES.md index bdb953e9f767..4ee5a483352b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,7 @@ Change Log * Fixed ground atmosphere rendering when using a samller ellipsoid. [#8683](https://github.com/CesiumGS/cesium/issues/8683) * Fixed globe incorrectly occluding objects when using a smaller ellipsoid. [#7124](https://github.com/CesiumGS/cesium/issues/7124) * Fixed a regression introduced in 1.67 which caused overlapping colored ground geometry to have visual artifacts. [#8694](https://github.com/CesiumGS/cesium/pull/8694) +* Fixed a clipping problem when viewing a polyline up close with the logarithmic depth buffer enabled, which is the default on most systems. [#8703](https://github.com/CesiumGS/cesium/pull/8703) ### 1.67.0 - 2020-03-02 diff --git a/Source/Shaders/Appearances/PolylineColorAppearanceVS.glsl b/Source/Shaders/Appearances/PolylineColorAppearanceVS.glsl index 17ce3ec48e27..5bb9d0188828 100644 --- a/Source/Shaders/Appearances/PolylineColorAppearanceVS.glsl +++ b/Source/Shaders/Appearances/PolylineColorAppearanceVS.glsl @@ -25,8 +25,4 @@ void main() float angle; vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, angle); gl_Position = czm_viewportOrthographic * positionWC; - -#ifdef LOG_DEPTH - czm_vertexLogDepth(czm_modelViewProjectionRelativeToEye * p); -#endif } diff --git a/Source/Shaders/Appearances/PolylineMaterialAppearanceVS.glsl b/Source/Shaders/Appearances/PolylineMaterialAppearanceVS.glsl index bdfae0e27569..6b61f09369c6 100644 --- a/Source/Shaders/Appearances/PolylineMaterialAppearanceVS.glsl +++ b/Source/Shaders/Appearances/PolylineMaterialAppearanceVS.glsl @@ -27,8 +27,4 @@ void main() vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, v_polylineAngle); gl_Position = czm_viewportOrthographic * positionWC; - -#ifdef LOG_DEPTH - czm_vertexLogDepth(czm_modelViewProjectionRelativeToEye * p); -#endif } diff --git a/Source/Shaders/PolylineCommon.glsl b/Source/Shaders/PolylineCommon.glsl index d4a4e89a402d..cfdd87cca723 100644 --- a/Source/Shaders/PolylineCommon.glsl +++ b/Source/Shaders/PolylineCommon.glsl @@ -3,7 +3,8 @@ void clipLineSegmentToNearPlane( vec3 p1, out vec4 positionWC, out bool clipped, - out bool culledByNearPlane) + out bool culledByNearPlane, + out vec4 clippedPositionEC) { culledByNearPlane = false; clipped = false; @@ -18,7 +19,7 @@ void clipLineSegmentToNearPlane( { culledByNearPlane = true; } - else if (endPoint0Distance < 0.0 && abs(denominator) > czm_epsilon7) + else if (endPoint0Distance < 0.0) { // t = (-plane distance - dot(plane normal, ray origin)) / dot(plane normal, ray direction) float t = (czm_currentFrustum.x + p0.z) / denominator; @@ -33,7 +34,8 @@ void clipLineSegmentToNearPlane( } } - positionWC = czm_eyeToWindowCoordinates(vec4(p0, 1.0)); + clippedPositionEC = vec4(p0, 1.0); + positionWC = czm_eyeToWindowCoordinates(clippedPositionEC); } vec4 getPolylineWindowCoordinatesEC(vec4 positionEC, vec4 prevEC, vec4 nextEC, float expandDirection, float width, bool usePrevious, out float angle) @@ -61,9 +63,14 @@ vec4 getPolylineWindowCoordinatesEC(vec4 positionEC, vec4 prevEC, vec4 nextEC, f angle = floor(angle / czm_piOverFour + 0.5) * czm_piOverFour; #endif - clipLineSegmentToNearPlane(prevEC.xyz, positionEC.xyz, p0, clipped, culledByNearPlane); - clipLineSegmentToNearPlane(nextEC.xyz, positionEC.xyz, p1, clipped, culledByNearPlane); - clipLineSegmentToNearPlane(positionEC.xyz, usePrevious ? prevEC.xyz : nextEC.xyz, endPointWC, clipped, culledByNearPlane); + vec4 clippedPositionEC; + clipLineSegmentToNearPlane(prevEC.xyz, positionEC.xyz, p0, clipped, culledByNearPlane, clippedPositionEC); + clipLineSegmentToNearPlane(nextEC.xyz, positionEC.xyz, p1, clipped, culledByNearPlane, clippedPositionEC); + clipLineSegmentToNearPlane(positionEC.xyz, usePrevious ? prevEC.xyz : nextEC.xyz, endPointWC, clipped, culledByNearPlane, clippedPositionEC); + +#ifdef LOG_DEPTH + czm_vertexLogDepth(czm_projection * clippedPositionEC); +#endif if (culledByNearPlane) { diff --git a/Source/Shaders/PolylineVS.glsl b/Source/Shaders/PolylineVS.glsl index 818272033561..972e0862fb17 100644 --- a/Source/Shaders/PolylineVS.glsl +++ b/Source/Shaders/PolylineVS.glsl @@ -96,8 +96,4 @@ void main() v_st = vec2(texCoord, clamp(expandDir, 0.0, 1.0)); v_width = width; v_pickColor = pickColor; - -#ifdef LOG_DEPTH - czm_vertexLogDepth(czm_modelViewProjectionRelativeToEye * p); -#endif }