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 clipping against the near plane. #7209

Merged
merged 5 commits into from
Nov 2, 2018
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
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Change Log
##### Additions :tada:
* Added `Scene.invertClassificationSupported` for checking if invert classification is supported.

##### Fixes :wrench:
* Fixed issue causing polyline to look wavy depending on the position of the camera [#7209](https://github.com/AnalyticalGraphicsInc/cesium/pull/7209)

### 1.51 - 2018-11-01

##### Additions :tada:
Expand Down
6 changes: 6 additions & 0 deletions Source/Scene/PolylineCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ define([
'../Core/destroyObject',
'../Core/DeveloperError',
'../Core/EncodedCartesian3',
'../Core/FeatureDetection',
'../Core/IndexDatatype',
'../Core/Intersect',
'../Core/Math',
Expand Down Expand Up @@ -52,6 +53,7 @@ define([
destroyObject,
DeveloperError,
EncodedCartesian3,
FeatureDetection,
IndexDatatype,
Intersect,
CesiumMath,
Expand Down Expand Up @@ -1182,6 +1184,10 @@ define([
defines.push('POLYLINE_DASH');
}

if (!FeatureDetection.isInternetExplorer()) {
defines.push('CLIP_POLYLINE');
}

var fs = new ShaderSource({
defines : defines,
sources : ['varying vec4 v_pickColor;\n', this.material.shaderSource, PolylineFS]
Expand Down
6 changes: 6 additions & 0 deletions Source/Scene/PolylineColorAppearance.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
define([
'../Core/defaultValue',
'../Core/defineProperties',
'../Core/FeatureDetection',
'../Core/VertexFormat',
'../Shaders/Appearances/PerInstanceFlatColorAppearanceFS',
'../Shaders/Appearances/PolylineColorAppearanceVS',
Expand All @@ -9,6 +10,7 @@ define([
], function(
defaultValue,
defineProperties,
FeatureDetection,
VertexFormat,
PerInstanceFlatColorAppearanceFS,
PolylineColorAppearanceVS,
Expand All @@ -19,6 +21,10 @@ define([
var defaultVertexShaderSource = PolylineCommon + '\n' + PolylineColorAppearanceVS;
var defaultFragmentShaderSource = PerInstanceFlatColorAppearanceFS;

if (!FeatureDetection.isInternetExplorer()) {
defaultVertexShaderSource = '#define CLIP_POLYLINE \n' + defaultVertexShaderSource;
}

/**
* An appearance for {@link GeometryInstance} instances with color attributes and
* {@link PolylineGeometry} or {@link GroundPolylineGeometry}.
Expand Down
6 changes: 6 additions & 0 deletions Source/Scene/PolylineMaterialAppearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define([
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
'../Core/FeatureDetection',
'../Core/VertexFormat',
'../Shaders/Appearances/PolylineMaterialAppearanceVS',
'../Shaders/PolylineCommon',
Expand All @@ -12,6 +13,7 @@ define([
defaultValue,
defined,
defineProperties,
FeatureDetection,
VertexFormat,
PolylineMaterialAppearanceVS,
PolylineCommon,
Expand All @@ -23,6 +25,10 @@ define([
var defaultVertexShaderSource = PolylineCommon + '\n' + PolylineMaterialAppearanceVS;
var defaultFragmentShaderSource = PolylineFS;

if (!FeatureDetection.isInternetExplorer()) {
defaultVertexShaderSource = '#define CLIP_POLYLINE \n' + defaultVertexShaderSource;
}

/**
* An appearance for {@link PolylineGeometry} that supports shading with materials.
*
Expand Down
4 changes: 3 additions & 1 deletion Source/Scene/Vector3DTilePolylines.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ define([
'../Core/defineProperties',
'../Core/destroyObject',
'../Core/Ellipsoid',
'../Core/FeatureDetection',
'../Core/IndexDatatype',
'../Core/Matrix4',
'../Core/Rectangle',
Expand Down Expand Up @@ -35,6 +36,7 @@ define([
defineProperties,
destroyObject,
Ellipsoid,
FeatureDetection,
IndexDatatype,
Matrix4,
Rectangle,
Expand Down Expand Up @@ -410,7 +412,7 @@ define([
var fsSource = batchTable.getFragmentShaderCallback()(PolylineFS, false, undefined);

var vs = new ShaderSource({
defines : ['VECTOR_TILE'],
defines : ['VECTOR_TILE', !FeatureDetection.isInternetExplorer() ? 'CLIP_POLYLINE' : ''],
sources : [PolylineCommon, vsSource]
});
var fs = new ShaderSource({
Expand Down
16 changes: 15 additions & 1 deletion Source/Shaders/PolylineCommon.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,25 @@ vec4 getPolylineWindowCoordinatesEC(vec4 positionEC, vec4 prevEC, vec4 nextEC, f
float expandWidth = width * 0.5;
vec2 direction;

#ifdef CLIP_POLYLINE
if (clipped)
{
if (prevEC.z - positionEC.z < 0.0)
{
direction = vec2(prevWC.y, -prevWC.x);
}
else
{
direction = vec2(-prevWC.y, prevWC.x);
}
}
else
#endif
if (czm_equalsEpsilon(prevEC.xyz - positionEC.xyz, vec3(0.0), czm_epsilon1) || czm_equalsEpsilon(prevWC, -nextWC, czm_epsilon1))
{
direction = vec2(-nextWC.y, nextWC.x);
}
else if (czm_equalsEpsilon(nextEC.xyz - positionEC.xyz, vec3(0.0), czm_epsilon1) || clipped)
else if (czm_equalsEpsilon(nextEC.xyz - positionEC.xyz, vec3(0.0), czm_epsilon1))
{
direction = vec2(prevWC.y, -prevWC.x);
}
Expand Down