Skip to content

Commit 9a1da37

Browse files
authored
Merge pull request CesiumGS#5681 from jasonbeverage/dynamicdash
Fix for dynamic polylines with polyline dash material
2 parents 769b09a + eaabada commit 9a1da37

6 files changed

+19
-10
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Change Log
3232
* Added `FrustumGeometry` and `FrustumOutlineGeometry`. [#5649](https://github.com/AnalyticalGraphicsInc/cesium/pull/5649)
3333
* Added an `options` parameter to the constructors of `PerspectiveFrustum`, `PerspectiveOffCenterFrustum`, `OrthographicFrustum`, and `OrthographicOffCenterFrustum` to set properties. [#5649](https://github.com/AnalyticalGraphicsInc/cesium/pull/5649)
3434
* 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)
35+
* Fix for dynamic polylines with polyline dash material [#5681](https://github.com/AnalyticalGraphicsInc/cesium/pull/5681)
3536

3637
### 1.35.2 - 2017-07-11
3738

Source/Scene/PolylineCollection.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -1144,14 +1144,22 @@ define([
11441144
}
11451145

11461146
var defines = ['DISTANCE_DISPLAY_CONDITION'];
1147+
1148+
var fs = new ShaderSource({
1149+
sources : [this.material.shaderSource, PolylineFS]
1150+
});
1151+
1152+
// Check for use of v_polylineAngle in material shader
1153+
if (this.material.shaderSource.search(/varying\s+float\s+v_polylineAngle;/g) !== -1) {
1154+
defines.push('POLYLINE_DASH');
1155+
}
1156+
11471157
var vsSource = batchTable.getVertexShaderCallback()(PolylineVS);
11481158
var vs = new ShaderSource({
11491159
defines : defines,
11501160
sources : [PolylineCommon, vsSource]
11511161
});
1152-
var fs = new ShaderSource({
1153-
sources : [this.material.shaderSource, PolylineFS]
1154-
});
1162+
11551163
var fsPick = new ShaderSource({
11561164
sources : fs.sources,
11571165
pickColorQualifier : 'varying'

Source/Scene/PolylineMaterialAppearance.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ define([
106106
vertexShaderSource : {
107107
get : function() {
108108
var vs = this._vertexShaderSource;
109-
if (this.material.shaderSource.search(/varying\s+float\s+v_angle;/g) !== -1) {
109+
if (this.material.shaderSource.search(/varying\s+float\s+v_polylineAngle;/g) !== -1) {
110110
vs = '#define POLYLINE_DASH\n' + vs;
111111
}
112112
return vs;

Source/Shaders/Appearances/PolylineMaterialAppearanceVS.glsl

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ attribute float batchId;
1010

1111
varying float v_width;
1212
varying vec2 v_st;
13-
varying float v_angle;
13+
varying float v_polylineAngle;
1414

1515
void main()
1616
{
@@ -25,6 +25,6 @@ void main()
2525
v_width = width;
2626
v_st = st;
2727

28-
vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, v_angle);
28+
vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, v_polylineAngle);
2929
gl_Position = czm_viewportOrthographic * positionWC;
3030
}

Source/Shaders/Materials/PolylineDashMaterial.glsl

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ uniform vec4 color;
22
uniform vec4 gapColor;
33
uniform float dashLength;
44
uniform float dashPattern;
5-
varying float v_angle;
5+
varying float v_polylineAngle;
66

77
const float maskLength = 16.0;
88

@@ -19,7 +19,7 @@ czm_material czm_getMaterial(czm_materialInput materialInput)
1919
{
2020
czm_material material = czm_getDefaultMaterial(materialInput);
2121

22-
vec2 pos = rotate(v_angle) * gl_FragCoord.xy;
22+
vec2 pos = rotate(v_polylineAngle) * gl_FragCoord.xy;
2323

2424
// Get the relative position within the dash from 0 to 1
2525
float dashPosition = fract(pos.x / dashLength);

Source/Shaders/PolylineVS.glsl

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ attribute vec4 texCoordExpandAndBatchIndex;
1515
varying vec2 v_st;
1616
varying float v_width;
1717
varying vec4 czm_pickColor;
18-
varying float v_angle;
18+
varying float v_polylineAngle;
1919

2020
void main()
2121
{
@@ -90,7 +90,7 @@ void main()
9090
}
9191
#endif
9292

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

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

0 commit comments

Comments
 (0)