Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix polyline regression with log depth #8703

Merged
merged 6 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 0 additions & 4 deletions Source/Shaders/Appearances/PolylineColorAppearanceVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 0 additions & 4 deletions Source/Shaders/Appearances/PolylineMaterialAppearanceVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
19 changes: 13 additions & 6 deletions Source/Shaders/PolylineCommon.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 0 additions & 4 deletions Source/Shaders/PolylineVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}