-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Polylines on terrain via Primitive API #6615
Changes from 1 commit
bc4a24a
cbd2eb7
b2ac735
bafa5f2
0371307
0c22456
ac29934
ad8d711
4f71916
612152b
fe4849e
5de9ded
9abaa8c
e6e2c18
fe3531f
02e7f22
6a51e44
63db595
9e39ecc
bed6ecf
fd903d2
071a636
4aebfa1
6ac0dd5
5ee4a47
436631a
d11829d
1d1850a
1bd9695
6147990
43dbae2
11d7bc4
7869029
eb95073
361c4cd
fa7075f
81a23c8
163d254
403e500
a822e15
3ec30e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- workspaces
- pre-template-literals
- pre-prettier-v3
- pre-prettier
- pre-let-const
- post-workspaces
- post-template-literals
- post-prettier-v3
- post-prettier
- post-let-const
- cesium-workspaces
- 1.125
- 1.124
- 1.123.1
- 1.123
- 1.122
- 1.121.1
- 1.121
- 1.120
- 1.119
- 1.118.2
- 1.118.1
- 1.118
- 1.117
- 1.116
- 1.115
- 1.114
- 1.113
- 1.112
- 1.111
- 1.111-release
- 1.110.1
- 1.110
- 1.109
- 1.108
- 1.107.2
- 1.107.1
- 1.107
- 1.106.1
- 1.106
- 1.105.2
- 1.105.1
- 1.105
- 1.104
- 1.103
- 1.102
- 1.101
- 1.100
- 1.99
- 1.98.1
- 1.98
- 1.97
- 1.96
- 1.95
- 1.94.3
- 1.94.2
- 1.94.1
- 1.94
- 1.93
- 1.92
- 1.91
- 1.90
- 1.89
- 1.88
- 1.87.1
- 1.87
- 1.86.1
- 1.86
- 1.85
- 1.84
- 1.83
- 1.82
- 1.81
- 1.80
- 1.79.1
- 1.79
- 1.78
- 1.77
- 1.76
- 1.75
- 1.74
- 1.73
- 1.72
- 1.71
- 1.70.1
- 1.70
- 1.69
- 1.68
- 1.67
- 1.66
- 1.65
- 1.64
- 1.63.1
- 1.63
- 1.62
- 1.61
- 1.60
- 1.59
- 1.58.1
- 1.58
- 1.57
- 1.56.1
- 1.56
- 1.55
- 1.54
- 1.53
- 1.52
- 1.51
- 1.50
- 1.49
- 1.48
- 1.47
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
#ifdef GL_EXT_frag_depth | ||
#extension GL_EXT_frag_depth : enable | ||
#endif | ||
|
||
varying vec4 v_startPlaneNormalEC_and_halfWidth; | ||
varying vec4 v_endPlaneNormalEC_and_batchId; | ||
varying vec4 v_startPlaneNormalEcAndHalfWidth; | ||
varying vec4 v_endPlaneNormalEcAndBatchId; | ||
varying vec4 v_rightPlaneEC; // Technically can compute distance for this here | ||
varying vec4 v_ecEnd_and_ecStart_X; | ||
varying vec4 v_texcoordNormalization_and_ecStart_YZ; | ||
varying vec4 v_endEcAndStartEcX; | ||
varying vec4 v_texcoordNormalizationAndStartEcYZ; | ||
|
||
#ifdef PER_INSTANCE_COLOR | ||
varying vec4 v_color; | ||
|
@@ -15,21 +11,21 @@ varying vec4 v_color; | |
void main(void) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At quick glance, fragment shader does not look that expensive...very good. Just overall fill rate will be the issue that we can address in the future. |
||
{ | ||
float logDepthOrDepth = czm_unpackDepth(texture2D(czm_globeDepthTexture, gl_FragCoord.xy / czm_viewport.zw)); | ||
vec3 ecStart = vec3(v_ecEnd_and_ecStart_X.w, v_texcoordNormalization_and_ecStart_YZ.zw); | ||
vec3 ecStart = vec3(v_endEcAndStartEcX.w, v_texcoordNormalizationAndStartEcYZ.zw); | ||
|
||
// Discard for sky | ||
bool shouldDiscard = logDepthOrDepth == 0.0; | ||
bool shouldDiscard = (logDepthOrDepth == 0.0); | ||
|
||
vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, logDepthOrDepth); | ||
eyeCoordinate /= eyeCoordinate.w; | ||
|
||
float halfMaxWidth = v_startPlaneNormalEC_and_halfWidth.w * czm_metersPerPixel(eyeCoordinate); | ||
float halfMaxWidth = v_startPlaneNormalEcAndHalfWidth.w * czm_metersPerPixel(eyeCoordinate); | ||
// Check distance of the eye coordinate against the right-facing plane | ||
float widthwiseDistance = czm_planeDistance(v_rightPlaneEC, eyeCoordinate.xyz); | ||
|
||
// Check eye coordinate against the mitering planes | ||
float distanceFromStart = czm_planeDistance(v_startPlaneNormalEC_and_halfWidth.xyz, -dot(ecStart, v_startPlaneNormalEC_and_halfWidth.xyz), eyeCoordinate.xyz); | ||
float distanceFromEnd = czm_planeDistance(v_endPlaneNormalEC_and_batchId.xyz, -dot(v_ecEnd_and_ecStart_X.xyz, v_endPlaneNormalEC_and_batchId.xyz), eyeCoordinate.xyz); | ||
float distanceFromStart = czm_planeDistance(v_startPlaneNormalEcAndHalfWidth.xyz, -dot(ecStart, v_startPlaneNormalEcAndHalfWidth.xyz), eyeCoordinate.xyz); | ||
float distanceFromEnd = czm_planeDistance(v_endPlaneNormalEcAndBatchId.xyz, -dot(v_endEcAndStartEcX.xyz, v_endPlaneNormalEcAndBatchId.xyz), eyeCoordinate.xyz); | ||
|
||
shouldDiscard = shouldDiscard || (abs(widthwiseDistance) > halfMaxWidth || distanceFromStart < 0.0 || distanceFromEnd < 0.0); | ||
|
||
|
@@ -40,14 +36,14 @@ void main(void) | |
vec3 alignedPlaneNormal; | ||
|
||
// start aligned plane | ||
alignedPlaneNormal = cross(v_rightPlaneEC.xyz, v_startPlaneNormalEC_and_halfWidth.xyz); | ||
alignedPlaneNormal = cross(v_rightPlaneEC.xyz, v_startPlaneNormalEcAndHalfWidth.xyz); | ||
alignedPlaneNormal = normalize(cross(alignedPlaneNormal, v_rightPlaneEC.xyz)); | ||
distanceFromStart = czm_planeDistance(alignedPlaneNormal, -dot(alignedPlaneNormal, ecStart), eyeCoordinate.xyz); | ||
|
||
// end aligned plane | ||
alignedPlaneNormal = cross(v_rightPlaneEC.xyz, v_endPlaneNormalEC_and_batchId.xyz); | ||
alignedPlaneNormal = cross(v_rightPlaneEC.xyz, v_endPlaneNormalEcAndBatchId.xyz); | ||
alignedPlaneNormal = normalize(cross(alignedPlaneNormal, v_rightPlaneEC.xyz)); | ||
distanceFromEnd = czm_planeDistance(alignedPlaneNormal, -dot(alignedPlaneNormal, v_ecEnd_and_ecStart_X.xyz), eyeCoordinate.xyz); | ||
distanceFromEnd = czm_planeDistance(alignedPlaneNormal, -dot(alignedPlaneNormal, v_endEcAndStartEcX.xyz), eyeCoordinate.xyz); | ||
|
||
shouldDiscard = shouldDiscard || distanceFromStart < -halfMaxWidth || distanceFromEnd < -halfMaxWidth; | ||
|
||
|
@@ -66,7 +62,7 @@ void main(void) | |
// Clamp - distance to aligned planes may be negative due to mitering, | ||
// so fragment texture coordinate might be out-of-bounds. | ||
float s = clamp(distanceFromStart / (distanceFromStart + distanceFromEnd), 0.0, 1.0); | ||
s = (s * v_texcoordNormalization_and_ecStart_YZ.x) + v_texcoordNormalization_and_ecStart_YZ.y; | ||
s = (s * v_texcoordNormalizationAndStartEcYZ.x) + v_texcoordNormalizationAndStartEcYZ.y; | ||
float t = (widthwiseDistance + halfMaxWidth) / (2.0 * halfMaxWidth); | ||
|
||
czm_materialInput materialInput; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
attribute vec3 position3DHigh; | ||
attribute vec3 position3DLow; | ||
|
||
attribute vec4 startHi_and_forwardOffsetX; | ||
attribute vec4 startLo_and_forwardOffsetY; | ||
attribute vec4 startNormal_and_forwardOffsetZ; | ||
attribute vec4 endNormal_and_textureCoordinateNormalizationX; | ||
attribute vec4 rightNormal_and_textureCoordinateNormalizationY; | ||
attribute vec4 startHiAndForwardOffsetX; | ||
attribute vec4 startLoAndForwardOffsetY; | ||
attribute vec4 startNormalAndForwardOffsetZ; | ||
attribute vec4 endNormalAndTextureCoordinateNormalizationX; | ||
attribute vec4 rightNormalAndTextureCoordinateNormalizationY; | ||
attribute vec4 startHiLo2D; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, +1 for removing these four (!) attributes for 3D only. |
||
attribute vec4 offsetAndRight2D; | ||
attribute vec4 startEndNormals2D; | ||
|
@@ -40,7 +40,7 @@ void main() | |
|
||
// Start position | ||
vec4 posRelativeToEye2D = czm_translateRelativeToEye(vec3(0.0, startHiLo2D.xy), vec3(0.0, startHiLo2D.zw)); | ||
vec4 posRelativeToEye3D = czm_translateRelativeToEye(startHi_and_forwardOffsetX.xyz, startLo_and_forwardOffsetY.xyz); | ||
vec4 posRelativeToEye3D = czm_translateRelativeToEye(startHiAndForwardOffsetX.xyz, startLoAndForwardOffsetY.xyz); | ||
vec4 posRelativeToEye = czm_columbusViewMorph(posRelativeToEye2D, posRelativeToEye3D, czm_morphTime); | ||
vec3 ecPos2D = (czm_modelViewRelativeToEye * posRelativeToEye2D).xyz; | ||
vec3 ecPos3D = (czm_modelViewRelativeToEye * posRelativeToEye3D).xyz; | ||
|
@@ -50,21 +50,21 @@ void main() | |
vec4 startPlane2D; | ||
vec4 startPlane3D; | ||
startPlane2D.xyz = czm_normal * vec3(0.0, startEndNormals2D.xy); | ||
startPlane3D.xyz = czm_normal * startNormal_and_forwardOffsetZ.xyz; | ||
startPlane3D.xyz = czm_normal * startNormalAndForwardOffsetZ.xyz; | ||
startPlane2D.w = -dot(startPlane2D.xyz, ecPos2D); | ||
startPlane3D.w = -dot(startPlane3D.xyz, ecPos3D); | ||
|
||
// Right plane | ||
vec4 rightPlane2D; | ||
vec4 rightPlane3D; | ||
rightPlane2D.xyz = czm_normal * vec3(0.0, offsetAndRight2D.zw); | ||
rightPlane3D.xyz = czm_normal * rightNormal_and_textureCoordinateNormalizationY.xyz; | ||
rightPlane3D.xyz = czm_normal * rightNormalAndTextureCoordinateNormalizationY.xyz; | ||
rightPlane2D.w = -dot(rightPlane2D.xyz, ecPos2D); | ||
rightPlane3D.w = -dot(rightPlane3D.xyz, ecPos3D); | ||
|
||
// End position | ||
posRelativeToEye2D = posRelativeToEye2D + vec4(0.0, offsetAndRight2D.xy, 0.0); | ||
posRelativeToEye3D = posRelativeToEye3D + vec4(startHi_and_forwardOffsetX.w, startLo_and_forwardOffsetY.w, startNormal_and_forwardOffsetZ.w, 0.0); | ||
posRelativeToEye3D = posRelativeToEye3D + vec4(startHiAndForwardOffsetX.w, startLoAndForwardOffsetY.w, startNormalAndForwardOffsetZ.w, 0.0); | ||
posRelativeToEye = czm_columbusViewMorph(posRelativeToEye2D, posRelativeToEye3D, czm_morphTime); | ||
ecPos2D = (czm_modelViewRelativeToEye * posRelativeToEye2D).xyz; | ||
ecPos3D = (czm_modelViewRelativeToEye * posRelativeToEye3D).xyz; | ||
|
@@ -74,7 +74,7 @@ void main() | |
vec4 endPlane2D; | ||
vec4 endPlane3D; | ||
endPlane2D.xyz = czm_normal * vec3(0.0, startEndNormals2D.zw); | ||
endPlane3D.xyz = czm_normal * endNormal_and_textureCoordinateNormalizationX.xyz; | ||
endPlane3D.xyz = czm_normal * endNormalAndTextureCoordinateNormalizationX.xyz; | ||
endPlane2D.w = -dot(endPlane2D.xyz, ecPos2D); | ||
endPlane3D.w = -dot(endPlane3D.xyz, ecPos3D); | ||
|
||
|
@@ -83,7 +83,7 @@ void main() | |
|
||
v_texcoordNormalization_and_halfWidth.xy = mix( | ||
vec2(abs(texcoordNormalization2D.x), texcoordNormalization2D.y), | ||
vec2(abs(endNormal_and_textureCoordinateNormalizationX.w), rightNormal_and_textureCoordinateNormalizationY.w), czm_morphTime); | ||
vec2(abs(endNormalAndTextureCoordinateNormalizationX.w), rightNormalAndTextureCoordinateNormalizationY.w), czm_morphTime); | ||
|
||
#ifdef PER_INSTANCE_COLOR | ||
v_color = czm_batchTable_color(batchId); | ||
|
@@ -119,7 +119,7 @@ void main() | |
vec3 normalEC = normalize(cross(planeDirection, upOrDown)); // In practice, the opposite seems to work too. | ||
|
||
// Determine if this vertex is on the "left" or "right" | ||
normalEC *= sign(endNormal_and_textureCoordinateNormalizationX.w); | ||
normalEC *= sign(endNormalAndTextureCoordinateNormalizationX.w); | ||
|
||
// A "perfect" implementation would push along normals according to the angle against forward. | ||
// In practice, just pushing the normal out by halfWidth is sufficient for morph views. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not do the same thing for projection?