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 for dynamic polylines with polyline dash material #5681

Merged
merged 4 commits into from
Jul 27, 2017
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 @@ -32,6 +32,7 @@ Change Log
* Added `FrustumGeometry` and `FrustumOutlineGeometry`. [#5649](https://github.com/AnalyticalGraphicsInc/cesium/pull/5649)
* Added an `options` parameter to the constructors of `PerspectiveFrustum`, `PerspectiveOffCenterFrustum`, `OrthographicFrustum`, and `OrthographicOffCenterFrustum` to set properties. [#5649](https://github.com/AnalyticalGraphicsInc/cesium/pull/5649)
* Added `ClassificationPrimitive` which defines a volume and draws the intersection of the volume and terrain or 3D Tiles. [#5625](https://github.com/AnalyticalGraphicsInc/cesium/pull/5625)
* Fix for dynamic polylines with polyline dash material [#5681](https://github.com/AnalyticalGraphicsInc/cesium/pull/5681)

### 1.35.2 - 2017-07-11

Expand Down
14 changes: 11 additions & 3 deletions Source/Scene/PolylineCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -1144,14 +1144,22 @@ define([
}

var defines = ['DISTANCE_DISPLAY_CONDITION'];

var fs = new ShaderSource({
sources : [this.material.shaderSource, PolylineFS]
});

// Check for use of v_polylineAngle in material shader
if (this.material.shaderSource.search(/varying\s+float\s+v_polylineAngle;/g) !== -1) {
defines.push('POLYLINE_DASH');
}

var vsSource = batchTable.getVertexShaderCallback()(PolylineVS);
var vs = new ShaderSource({
defines : defines,
sources : [PolylineCommon, vsSource]
});
var fs = new ShaderSource({
sources : [this.material.shaderSource, PolylineFS]
});

var fsPick = new ShaderSource({
sources : fs.sources,
pickColorQualifier : 'varying'
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/PolylineMaterialAppearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ define([
vertexShaderSource : {
get : function() {
var vs = this._vertexShaderSource;
if (this.material.shaderSource.search(/varying\s+float\s+v_angle;/g) !== -1) {
if (this.material.shaderSource.search(/varying\s+float\s+v_polylineAngle;/g) !== -1) {
vs = '#define POLYLINE_DASH\n' + vs;
}
return vs;
Expand Down
4 changes: 2 additions & 2 deletions Source/Shaders/Appearances/PolylineMaterialAppearanceVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ attribute float batchId;

varying float v_width;
varying vec2 v_st;
varying float v_angle;
varying float v_polylineAngle;

void main()
{
Expand All @@ -25,6 +25,6 @@ void main()
v_width = width;
v_st = st;

vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, v_angle);
vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, v_polylineAngle);
gl_Position = czm_viewportOrthographic * positionWC;
}
4 changes: 2 additions & 2 deletions Source/Shaders/Materials/PolylineDashMaterial.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ uniform vec4 color;
uniform vec4 gapColor;
uniform float dashLength;
uniform float dashPattern;
varying float v_angle;
varying float v_polylineAngle;

const float maskLength = 16.0;

Expand All @@ -19,7 +19,7 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
{
czm_material material = czm_getDefaultMaterial(materialInput);

vec2 pos = rotate(v_angle) * gl_FragCoord.xy;
vec2 pos = rotate(v_polylineAngle) * gl_FragCoord.xy;

// Get the relative position within the dash from 0 to 1
float dashPosition = fract(pos.x / dashLength);
Expand Down
4 changes: 2 additions & 2 deletions Source/Shaders/PolylineVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ attribute vec4 texCoordExpandAndBatchIndex;
varying vec2 v_st;
varying float v_width;
varying vec4 czm_pickColor;
varying float v_angle;
varying float v_polylineAngle;

void main()
{
Expand Down Expand Up @@ -90,7 +90,7 @@ void main()
}
#endif

vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, v_angle);
vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, v_polylineAngle);
gl_Position = czm_viewportOrthographic * positionWC * show;

v_st = vec2(texCoord, clamp(expandDir, 0.0, 1.0));
Expand Down