deeptwins-cesium-engine 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Returns the first parameter if it is defined, otherwise the second parameter.
3
+ *
4
+ * @param {*} a The object.
5
+ * @param {*} b The default value.
6
+ * @returns {*} Returns the first parameter if defined, otherwise the second parameter.
7
+ *
8
+ * @example
9
+ * param = Cesium.defaultValue(param, "default");
10
+ */
11
+ function defaultValue(a, b) {
12
+ if (a !== undefined && a !== null) {
13
+ return a;
14
+ }
15
+ return b;
16
+ }
17
+
18
+ defaultValue.EMPTY_OBJECT = Object.freeze({});
19
+
20
+ export default defaultValue;
@@ -0,0 +1,30 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "in vec4 v_pickColor;\n\
3
+ in vec4 v_color;\n\
4
+ in vec4 v_outlineColor;\n\
5
+ in float v_innerRadiusFrac;\n\
6
+ \n\
7
+ void main()\n\
8
+ {\n\
9
+ // Distance between fragment and point center, 0 to 0.5.\n\
10
+ float distanceToCenter = length(gl_PointCoord - vec2(0.5));\n\
11
+ float delta = fwidth(distanceToCenter);\n\
12
+ \n\
13
+ float outerLimit = 0.5;\n\
14
+ float innerLimit = 0.5 * v_innerRadiusFrac;\n\
15
+ \n\
16
+ float outerAlpha = 1.0 - smoothstep(max(0.0, outerLimit - delta), outerLimit, distanceToCenter);\n\
17
+ float innerAlpha = 1.0 - smoothstep(innerLimit - delta, innerLimit, distanceToCenter);\n\
18
+ \n\
19
+ vec4 color = vec4(mix(v_outlineColor.rgb, v_color.rgb, innerAlpha), outerAlpha);\n\
20
+ color.a *= mix(v_outlineColor.a, v_color.a, innerAlpha);\n\
21
+ \n\
22
+ if (color.a < 0.005) // matches 0/255 and 1/255\n\
23
+ {\n\
24
+ discard;\n\
25
+ }\n\
26
+ \n\
27
+ out_FragColor = czm_gammaCorrect(color);\n\
28
+ czm_writeLogDepth();\n\
29
+ }\n\
30
+ ";
@@ -0,0 +1,60 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "#ifdef USE_FLOAT64\n\
3
+ in vec3 positionHigh;\n\
4
+ in vec3 positionLow;\n\
5
+ #else\n\
6
+ in vec3 position;\n\
7
+ #endif\n\
8
+ in vec4 pickColor;\n\
9
+ in vec4 showPixelSizeColorAlpha;\n\
10
+ in vec3 outlineWidthColorAlpha;\n\
11
+ \n\
12
+ out vec4 v_pickColor;\n\
13
+ out vec4 v_color;\n\
14
+ out vec4 v_outlineColor;\n\
15
+ out float v_innerRadiusFrac;\n\
16
+ \n\
17
+ void main()\n\
18
+ {\n\
19
+ // Unpack attributes.\n\
20
+ float show = showPixelSizeColorAlpha.x;\n\
21
+ float pixelSize = showPixelSizeColorAlpha.y;\n\
22
+ vec4 color = czm_decodeRGB8(showPixelSizeColorAlpha.z);\n\
23
+ float alpha = showPixelSizeColorAlpha.w;\n\
24
+ float outlineWidth = outlineWidthColorAlpha.x;\n\
25
+ vec4 outlineColor = czm_decodeRGB8(outlineWidthColorAlpha.y);\n\
26
+ float outlineAlpha = outlineWidthColorAlpha.z;\n\
27
+ \n\
28
+ ///////////////////////////////////////////////////////////////////////////\n\
29
+ \n\
30
+ float innerRadius = 0.5 * pixelSize * czm_pixelRatio;\n\
31
+ float outerRadius = (0.5 * pixelSize + outlineWidth) * czm_pixelRatio;\n\
32
+ \n\
33
+ ///////////////////////////////////////////////////////////////////////////\n\
34
+ \n\
35
+ #ifdef USE_FLOAT64\n\
36
+ vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);\n\
37
+ vec4 positionEC = czm_modelViewRelativeToEye * p;\n\
38
+ #else\n\
39
+ vec4 positionEC = czm_modelView * vec4(position, 1.0);\n\
40
+ #endif\n\
41
+ \n\
42
+ ///////////////////////////////////////////////////////////////////////////\n\
43
+ \n\
44
+ gl_Position = czm_projection * positionEC;\n\
45
+ czm_vertexLogDepth();\n\
46
+ \n\
47
+ v_pickColor = pickColor / 255.0;\n\
48
+ \n\
49
+ v_color = color;\n\
50
+ v_color.a *= alpha * show;\n\
51
+ \n\
52
+ v_outlineColor = outlineColor;\n\
53
+ v_outlineColor.a *= outlineAlpha * show;\n\
54
+ \n\
55
+ v_innerRadiusFrac = innerRadius / outerRadius;\n\
56
+ \n\
57
+ gl_PointSize = 2.0 * outerRadius * show;\n\
58
+ gl_Position *= show;\n\
59
+ }\n\
60
+ ";
@@ -0,0 +1,15 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "in vec4 v_pickColor;\n\
3
+ in vec4 v_color;\n\
4
+ \n\
5
+ void main()\n\
6
+ {\n\
7
+ if (v_color.a < 0.005) // matches 0/255 and 1/255\n\
8
+ {\n\
9
+ discard;\n\
10
+ }\n\
11
+ \n\
12
+ out_FragColor = czm_gammaCorrect(v_color);\n\
13
+ czm_writeLogDepth();\n\
14
+ }\n\
15
+ ";
@@ -0,0 +1,41 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "#ifdef USE_FLOAT64\n\
3
+ in vec3 positionHigh;\n\
4
+ in vec3 positionLow;\n\
5
+ #else\n\
6
+ in vec3 position;\n\
7
+ #endif\n\
8
+ in vec4 pickColor;\n\
9
+ in vec3 showColorAlpha;\n\
10
+ \n\
11
+ out vec4 v_pickColor;\n\
12
+ out vec4 v_color;\n\
13
+ \n\
14
+ void main()\n\
15
+ {\n\
16
+ float show = showColorAlpha.x;\n\
17
+ vec4 color = czm_decodeRGB8(showColorAlpha.y);\n\
18
+ float alpha = showColorAlpha.z;\n\
19
+ \n\
20
+ ///////////////////////////////////////////////////////////////////////////\n\
21
+ \n\
22
+ #ifdef USE_FLOAT64\n\
23
+ vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);\n\
24
+ vec4 positionEC = czm_modelViewRelativeToEye * p;\n\
25
+ #else\n\
26
+ vec4 positionEC = czm_modelView * vec4(position, 1.0);\n\
27
+ #endif\n\
28
+ \n\
29
+ ///////////////////////////////////////////////////////////////////////////\n\
30
+ \n\
31
+ gl_Position = czm_projection * positionEC;\n\
32
+ czm_vertexLogDepth();\n\
33
+ \n\
34
+ v_pickColor = pickColor / 255.0;\n\
35
+ \n\
36
+ v_color = color;\n\
37
+ v_color.a *= alpha * show;\n\
38
+ \n\
39
+ gl_Position *= show;\n\
40
+ }\n\
41
+ ";
@@ -0,0 +1,15 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "in vec4 v_pickColor;\n\
3
+ in vec4 v_color;\n\
4
+ \n\
5
+ void main()\n\
6
+ {\n\
7
+ if (v_color.a < 0.005) // matches 0/255 and 1/255\n\
8
+ {\n\
9
+ discard;\n\
10
+ }\n\
11
+ \n\
12
+ out_FragColor = czm_gammaCorrect(v_color);\n\
13
+ czm_writeLogDepth();\n\
14
+ }\n\
15
+ ";
@@ -0,0 +1,65 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "#ifdef USE_FLOAT64\n\
3
+ in vec3 positionHigh;\n\
4
+ in vec3 positionLow;\n\
5
+ in vec3 prevPositionHigh;\n\
6
+ in vec3 prevPositionLow;\n\
7
+ in vec3 nextPositionHigh;\n\
8
+ in vec3 nextPositionLow;\n\
9
+ #else\n\
10
+ in vec3 position;\n\
11
+ in vec3 prevPosition;\n\
12
+ in vec3 nextPosition;\n\
13
+ #endif\n\
14
+ in vec4 pickColor;\n\
15
+ in vec4 showColorWidthAndTexCoord;\n\
16
+ in float alpha;\n\
17
+ \n\
18
+ out vec4 v_pickColor;\n\
19
+ out vec4 v_color;\n\
20
+ out vec2 v_st;\n\
21
+ out float v_width;\n\
22
+ out float v_polylineAngle;\n\
23
+ \n\
24
+ void main()\n\
25
+ {\n\
26
+ float show = showColorWidthAndTexCoord.x;\n\
27
+ vec4 color = czm_decodeRGB8(showColorWidthAndTexCoord.y);\n\
28
+ float width = showColorWidthAndTexCoord.z;\n\
29
+ float texCoord = showColorWidthAndTexCoord.w;\n\
30
+ \n\
31
+ ///////////////////////////////////////////////////////////////////////////\n\
32
+ \n\
33
+ bool usePrevious = texCoord == 1.0;\n\
34
+ float expandDir = gl_VertexID % 2 == 1 ? 1.0 : -1.0;\n\
35
+ float polylineAngle;\n\
36
+ \n\
37
+ #ifdef USE_FLOAT64\n\
38
+ vec4 positionEC = czm_translateRelativeToEye(positionHigh, positionLow);\n\
39
+ vec4 prevPositionEC = czm_translateRelativeToEye(prevPositionHigh, prevPositionLow);\n\
40
+ vec4 nextPositionEC = czm_translateRelativeToEye(nextPositionHigh, nextPositionLow);\n\
41
+ vec4 positionWC = getPolylineWindowCoordinates(positionEC, prevPositionEC, nextPositionEC, expandDir, width, usePrevious, polylineAngle);\n\
42
+ #else\n\
43
+ vec4 positionEC = czm_modelView * vec4(position, 1.0);\n\
44
+ vec4 prevPositionEC = czm_modelView * vec4(prevPosition, 1.0);\n\
45
+ vec4 nextPositionEC = czm_modelView * vec4(nextPosition, 1.0);\n\
46
+ // Positions are already in eye space; use the EC variant to skip the redundant transform.\n\
47
+ vec4 positionWC = getPolylineWindowCoordinatesEC(positionEC, prevPositionEC, nextPositionEC, expandDir, width, usePrevious, polylineAngle);\n\
48
+ #endif\n\
49
+ \n\
50
+ ///////////////////////////////////////////////////////////////////////////\n\
51
+ \n\
52
+ gl_Position = czm_viewportOrthographic * positionWC * show;\n\
53
+ \n\
54
+ v_pickColor = pickColor / 255.0;\n\
55
+ \n\
56
+ v_color = color;\n\
57
+ v_color.a *= alpha / 255.0 * show;\n\
58
+ \n\
59
+ v_st.s = texCoord;\n\
60
+ v_st.t = czm_writeNonPerspective(clamp(expandDir, 0.0, 1.0), gl_Position.w);\n\
61
+ \n\
62
+ v_width = width;\n\
63
+ v_polylineAngle = polylineAngle;\n\
64
+ }\n\
65
+ ";
@@ -0,0 +1,13 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "uniform mat3 u_cubeMapPanoramaTransform;\n\
3
+ \n\
4
+ in vec3 position;\n\
5
+ out vec3 v_texCoord;\n\
6
+ \n\
7
+ void main()\n\
8
+ {\n\
9
+ vec3 p = czm_viewRotation * (u_cubeMapPanoramaTransform * (czm_entireFrustum.y * position));\n\
10
+ gl_Position = czm_projection * vec4(p, 1.0);\n\
11
+ v_texCoord = position.xyz;\n\
12
+ }\n\
13
+ ";
@@ -0,0 +1,62 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "#ifdef HAS_CONSTANT_LOD\n\
3
+ \n\
4
+ vec4 constantLodTextureLookup(sampler2D textureSampler, vec3 constantLodParams) {\n\
5
+ bool atMaxClamp = v_constantLodUvCustom.z >= constantLodParams.y;\n\
6
+ bool atMinClamp = v_constantLodUvCustom.z <= constantLodParams.x;\n\
7
+ bool atClampBoundary = atMaxClamp || atMinClamp;\n\
8
+ \n\
9
+ float effectiveDistance = atMaxClamp ? constantLodParams.y : \n\
10
+ (atMinClamp ? constantLodParams.x : v_constantLodUvCustom.z);\n\
11
+ \n\
12
+ float logDepth = log2(effectiveDistance);\n\
13
+ logDepth = clamp(logDepth, -10.0, 20.0);\n\
14
+ \n\
15
+ float f = fract(logDepth);\n\
16
+ float p = floor(logDepth);\n\
17
+ \n\
18
+ if (atClampBoundary) {\n\
19
+ float clampedP = ceil(logDepth);\n\
20
+ vec2 tc = v_constantLodUvCustom.xy / pow(2.0, clampedP) * constantLodParams.z;\n\
21
+ return texture(textureSampler, tc);\n\
22
+ }\n\
23
+ \n\
24
+ vec2 tc1 = v_constantLodUvCustom.xy / pow(2.0, p) * constantLodParams.z;\n\
25
+ vec2 tc2 = v_constantLodUvCustom.xy / pow(2.0, p + 1.0) * constantLodParams.z;\n\
26
+ return mix(texture(textureSampler, tc1), texture(textureSampler, tc2), f);\n\
27
+ }\n\
28
+ \n\
29
+ vec4 constantLodTextureLookup(sampler2D textureSampler, vec3 constantLodParams, mat3 textureTransform) {\n\
30
+ bool atMaxClamp = v_constantLodUvCustom.z >= constantLodParams.y;\n\
31
+ bool atMinClamp = v_constantLodUvCustom.z <= constantLodParams.x;\n\
32
+ bool atClampBoundary = atMaxClamp || atMinClamp;\n\
33
+ \n\
34
+ float effectiveDistance = atMaxClamp ? constantLodParams.y : \n\
35
+ (atMinClamp ? constantLodParams.x : v_constantLodUvCustom.z);\n\
36
+ \n\
37
+ float logDepth = log2(effectiveDistance);\n\
38
+ logDepth = clamp(logDepth, -10.0, 20.0);\n\
39
+ \n\
40
+ float f = fract(logDepth);\n\
41
+ float p = floor(logDepth);\n\
42
+ \n\
43
+ if (atClampBoundary) {\n\
44
+ float clampedP = ceil(logDepth);\n\
45
+ vec2 tc = v_constantLodUvCustom.xy / pow(2.0, clampedP) * constantLodParams.z;\n\
46
+ // Apply texture transform to the final texture coordinates\n\
47
+ tc = czm_computeTextureTransform(tc, textureTransform);\n\
48
+ return texture(textureSampler, tc);\n\
49
+ }\n\
50
+ \n\
51
+ vec2 tc1 = v_constantLodUvCustom.xy / pow(2.0, p) * constantLodParams.z;\n\
52
+ vec2 tc2 = v_constantLodUvCustom.xy / pow(2.0, p + 1.0) * constantLodParams.z;\n\
53
+ \n\
54
+ // Apply texture transform to both LOD texture coordinates before mixing\n\
55
+ tc1 = czm_computeTextureTransform(tc1, textureTransform);\n\
56
+ tc2 = czm_computeTextureTransform(tc2, textureTransform);\n\
57
+ \n\
58
+ return mix(texture(textureSampler, tc1), texture(textureSampler, tc2), f);\n\
59
+ }\n\
60
+ \n\
61
+ #endif\n\
62
+ ";
@@ -0,0 +1,13 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "#ifdef HAS_CONSTANT_LOD\n\
3
+ // Extract model scale to compensate for minimumPixelSize scaling\n\
4
+ float modelScaleX = length(czm_model[0].xyz);\n\
5
+ float modelScaleY = length(czm_model[1].xyz);\n\
6
+ float modelScaleZ = length(czm_model[2].xyz);\n\
7
+ float modelScale = (modelScaleX + modelScaleY + modelScaleZ) / 3.0;\n\
8
+ \n\
9
+ // Transform model position through ENU but as direction only (w=0) to avoid position-dependent rotation\n\
10
+ vec3 enuDir = (u_constantLodWorldToEnu * czm_model * vec4(v_positionMC, 0.0)).xyz;\n\
11
+ v_constantLodUvCustom.xy = (enuDir.yx + u_constantLodOffset) / modelScale;\n\
12
+ v_constantLodUvCustom.z = u_constantLodDistance / modelScale;\n\
13
+ #endif";
@@ -0,0 +1,60 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "void edgeDetectionStage(inout vec4 color, inout FeatureIds featureIds) {\n\
3
+ if (u_isEdgePass) {\n\
4
+ return;\n\
5
+ }\n\
6
+ \n\
7
+ vec2 screenCoord = gl_FragCoord.xy / czm_viewport.zw;\n\
8
+ \n\
9
+ vec4 edgeColor = texture(czm_edgeColorTexture, screenCoord);\n\
10
+ vec4 edgeId = texture(czm_edgeIdTexture, screenCoord);\n\
11
+ \n\
12
+ // Packed window-space depth from edge pass (0..1)\n\
13
+ float edgeDepthWin = czm_unpackDepth(texture(czm_edgeDepthTexture, screenCoord));\n\
14
+ \n\
15
+ // Near / far for current frustum\n\
16
+ float n = czm_currentFrustum.x;\n\
17
+ float f = czm_currentFrustum.y;\n\
18
+ \n\
19
+ // geometry depth in eye coordinate\n\
20
+ vec4 geomEC = czm_windowToEyeCoordinates(gl_FragCoord);\n\
21
+ float geomDepthLinear = -geomEC.z;\n\
22
+ \n\
23
+ // Convert edge depth to linear depth\n\
24
+ float z_ndc_edge = edgeDepthWin * 2.0 - 1.0;\n\
25
+ float edgeDepthLinear = (2.0 * n * f) / (f + n - z_ndc_edge * (f - n));\n\
26
+ \n\
27
+ float d = abs(edgeDepthLinear - geomDepthLinear);\n\
28
+ \n\
29
+ // Adaptive epsilon using linear depth fwidth for robustness\n\
30
+ float pixelStepLinear = fwidth(geomDepthLinear);\n\
31
+ float rel = geomDepthLinear * 0.0005;\n\
32
+ float eps = max(n * 1e-4, max(pixelStepLinear * 1.5, rel));\n\
33
+ \n\
34
+ // If Edge isn't behind any geometry and the pixel has edge data\n\
35
+ if (d < eps && edgeId.r > 0.0) {\n\
36
+ #ifdef HAS_EDGE_FEATURE_ID\n\
37
+ float edgeFeatureId = edgeId.g;\n\
38
+ float currentFeatureId = float(featureIds.featureId_0);\n\
39
+ #endif\n\
40
+ float globeDepth = czm_unpackDepth(texture(czm_globeDepthTexture, screenCoord));\n\
41
+ // Background / sky / globe: always show edge\n\
42
+ bool isBackground = geomDepthLinear > globeDepth;\n\
43
+ bool drawEdge = isBackground;\n\
44
+ \n\
45
+ #ifdef HAS_EDGE_FEATURE_ID\n\
46
+ bool hasEdgeFeature = edgeFeatureId > 0.0;\n\
47
+ bool hasCurrentFeature = currentFeatureId > 0.0;\n\
48
+ bool featuresMatch = edgeFeatureId == currentFeatureId;\n\
49
+ \n\
50
+ drawEdge = drawEdge || !hasEdgeFeature || !hasCurrentFeature || featuresMatch;\n\
51
+ #else\n\
52
+ drawEdge = true;\n\
53
+ #endif\n\
54
+ \n\
55
+ if (drawEdge) {\n\
56
+ color = edgeColor;\n\
57
+ }\n\
58
+ }\n\
59
+ }\n\
60
+ ";
@@ -0,0 +1,70 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "// CESIUM_REDIRECTED_COLOR_OUTPUT flag is used to avoid color attachment conflicts\n\
3
+ // when shaders are processed by different rendering pipelines (e.g., OIT).\n\
4
+ // Only declare MRT outputs when not in a derived shader context.\n\
5
+ #if defined(HAS_EDGE_VISIBILITY_MRT) && !defined(CESIUM_REDIRECTED_COLOR_OUTPUT)\n\
6
+ layout(location = 1) out vec4 out_id; // edge id / metadata\n\
7
+ layout(location = 2) out vec4 out_edgeDepth; // packed depth\n\
8
+ #endif\n\
9
+ \n\
10
+ void edgeVisibilityStage(inout vec4 color, inout FeatureIds featureIds)\n\
11
+ {\n\
12
+ #ifdef HAS_EDGE_VISIBILITY\n\
13
+ \n\
14
+ if (!u_isEdgePass) {\n\
15
+ return;\n\
16
+ }\n\
17
+ \n\
18
+ float edgeTypeInt = v_edgeType * 255.0;\n\
19
+ \n\
20
+ if (edgeTypeInt < 0.5) {\n\
21
+ discard;\n\
22
+ }\n\
23
+ \n\
24
+ if (edgeTypeInt > 0.5 && edgeTypeInt < 1.5) { // silhouette candidate\n\
25
+ // Silhouette check done in vertex shader\n\
26
+ // v_shouldDiscard will be > 0.5 if this edge should be discarded\n\
27
+ if (v_shouldDiscard > 0.5) {\n\
28
+ discard;\n\
29
+ }\n\
30
+ }\n\
31
+ \n\
32
+ vec4 finalColor = color;\n\
33
+ #ifdef HAS_EDGE_COLOR_ATTRIBUTE\n\
34
+ if (v_edgeColor.a >= 0.0) {\n\
35
+ finalColor = v_edgeColor;\n\
36
+ }\n\
37
+ #endif\n\
38
+ \n\
39
+ #ifdef HAS_LINE_PATTERN\n\
40
+ // Pattern is 16-bit, each bit represents visibility at that position\n\
41
+ const float maskLength = 16.0;\n\
42
+ \n\
43
+ // Get the relative position within the dash from 0 to 1\n\
44
+ float dashPosition = fract(v_lineCoord / maskLength);\n\
45
+ // Figure out the mask index\n\
46
+ float maskIndex = floor(dashPosition * maskLength);\n\
47
+ // Test the bit mask\n\
48
+ float maskTest = floor(u_linePattern / pow(2.0, maskIndex));\n\
49
+ \n\
50
+ // If bit is 0 (gap), discard the fragment (use < 1.0 for better numerical stability)\n\
51
+ if (mod(maskTest, 2.0) < 1.0) {\n\
52
+ discard;\n\
53
+ }\n\
54
+ #endif\n\
55
+ color = finalColor;\n\
56
+ \n\
57
+ #if defined(HAS_EDGE_VISIBILITY_MRT) && !defined(CESIUM_REDIRECTED_COLOR_OUTPUT)\n\
58
+ // Write edge metadata\n\
59
+ out_id = vec4(0.0);\n\
60
+ out_id.r = edgeTypeInt; // Edge type (0-3)\n\
61
+ #ifdef HAS_EDGE_FEATURE_ID\n\
62
+ out_id.g = float(featureIds.featureId_0); // Feature ID if available\n\
63
+ #else\n\
64
+ out_id.g = 0.0;\n\
65
+ #endif\n\
66
+ // Pack depth into separate MRT attachment\n\
67
+ out_edgeDepth = czm_packDepth(gl_FragCoord.z);\n\
68
+ #endif\n\
69
+ #endif\n\
70
+ }";
@@ -0,0 +1,99 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "#ifdef HAS_EDGE_VISIBILITY\n\
3
+ void edgeVisibilityStageVS() {\n\
4
+ if (!u_isEdgePass) {\n\
5
+ return;\n\
6
+ }\n\
7
+ \n\
8
+ v_edgeType = a_edgeType;\n\
9
+ v_faceNormalAView = czm_normal * a_faceNormalA;\n\
10
+ v_faceNormalBView = czm_normal * a_faceNormalB;\n\
11
+ v_edgeOffset = a_edgeOffset;\n\
12
+ \n\
13
+ // Silhouette detection: check both endpoints of the edge\n\
14
+ v_shouldDiscard = 0.0;\n\
15
+ float edgeTypeInt = a_edgeType * 255.0;\n\
16
+ if (edgeTypeInt > 0.5 && edgeTypeInt < 1.5) {\n\
17
+ vec3 normalA = normalize(v_faceNormalAView);\n\
18
+ vec3 normalB = normalize(v_faceNormalBView);\n\
19
+ const float perpTol = 2.5e-4;\n\
20
+ \n\
21
+ // Check at current vertex (first endpoint)\n\
22
+ vec4 currentPosEC = czm_modelView * vec4(v_positionMC, 1.0);\n\
23
+ vec3 toEye1 = normalize(-currentPosEC.xyz);\n\
24
+ float dotA1 = dot(normalA, toEye1);\n\
25
+ float dotB1 = dot(normalB, toEye1);\n\
26
+ \n\
27
+ // Check at other vertex (second endpoint)\n\
28
+ vec4 otherPosEC = czm_modelView * vec4(a_edgeOtherPos, 1.0);\n\
29
+ vec3 toEye2 = normalize(-otherPosEC.xyz);\n\
30
+ float dotA2 = dot(normalA, toEye2);\n\
31
+ float dotB2 = dot(normalB, toEye2);\n\
32
+ \n\
33
+ // Discard if EITHER endpoint is non-silhouette\n\
34
+ if (dotA1 * dotB1 > perpTol || dotA2 * dotB2 > perpTol) {\n\
35
+ v_shouldDiscard = 1.0;\n\
36
+ }\n\
37
+ }\n\
38
+ \n\
39
+ #ifdef HAS_EDGE_FEATURE_ID\n\
40
+ v_featureId_0 = a_edgeFeatureId;\n\
41
+ #endif\n\
42
+ \n\
43
+ #ifdef HAS_EDGE_COLOR_ATTRIBUTE\n\
44
+ v_edgeColor = a_edgeColor;\n\
45
+ #endif\n\
46
+ \n\
47
+ #ifdef HAS_LINE_PATTERN\n\
48
+ #ifdef HAS_EDGE_CUMULATIVE_DISTANCE\n\
49
+ v_lineCoord = a_edgeCumulativeDistance * u_pixelsPerWorld;\n\
50
+ #else\n\
51
+ vec4 currentClip = czm_modelViewProjection * vec4(v_positionMC, 1.0);\n\
52
+ vec2 currentScreen = ((currentClip.xy / currentClip.w) * 0.5 + 0.5) * czm_viewport.zw;\n\
53
+ \n\
54
+ vec4 otherClip = czm_modelViewProjection * vec4(a_edgeOtherPos, 1.0);\n\
55
+ vec2 otherScreen = ((otherClip.xy / otherClip.w) * 0.5 + 0.5) * czm_viewport.zw;\n\
56
+ vec2 windowDir = otherScreen - currentScreen;\n\
57
+ \n\
58
+ const float textureCoordinateBase = 8192.0;\n\
59
+ if (abs(windowDir.x) > abs(windowDir.y)) {\n\
60
+ v_lineCoord = textureCoordinateBase + currentScreen.x;\n\
61
+ } else {\n\
62
+ v_lineCoord = textureCoordinateBase + currentScreen.y;\n\
63
+ }\n\
64
+ #endif\n\
65
+ #endif\n\
66
+ \n\
67
+ // Expand vertex to form quad\n\
68
+ vec4 posClip = gl_Position;\n\
69
+ \n\
70
+ if (length(a_edgeOtherPos) > 0.0 && abs(a_edgeOffset) > 0.0) {\n\
71
+ vec4 currentClip = posClip;\n\
72
+ vec4 otherClip = czm_modelViewProjection * vec4(a_edgeOtherPos, 1.0);\n\
73
+ \n\
74
+ vec2 currentNDC = currentClip.xy / currentClip.w;\n\
75
+ vec2 otherNDC = otherClip.xy / otherClip.w;\n\
76
+ \n\
77
+ vec2 edgeDirNDC = otherNDC - currentNDC;\n\
78
+ \n\
79
+ // Ensure consistent edge direction\n\
80
+ if (edgeDirNDC.x < 0.0 || (abs(edgeDirNDC.x) < 0.001 && edgeDirNDC.y < 0.0)) {\n\
81
+ edgeDirNDC = -edgeDirNDC;\n\
82
+ }\n\
83
+ \n\
84
+ edgeDirNDC = normalize(edgeDirNDC);\n\
85
+ vec2 perpNDC = vec2(-edgeDirNDC.y, edgeDirNDC.x);\n\
86
+ \n\
87
+ // Convert line width from pixels to clip space\n\
88
+ float lineWidthPixels = u_lineWidth;\n\
89
+ vec2 viewportSize = czm_viewport.zw;\n\
90
+ vec2 clipPerPixel = (2.0 / viewportSize) * currentClip.w;\n\
91
+ vec2 offsetClip = perpNDC * lineWidthPixels * clipPerPixel * 0.5 * a_edgeOffset;\n\
92
+ \n\
93
+ posClip.xy += offsetClip;\n\
94
+ }\n\
95
+ \n\
96
+ gl_Position = posClip;\n\
97
+ }\n\
98
+ #endif\n\
99
+ ";
@@ -0,0 +1,20 @@
1
+ //This file is automatically rebuilt by the Cesium build process.
2
+ export default "//\n\
3
+ // Fragment shader for Gaussian splats.\n\
4
+ // Renders a Gaussian splat within a quad, discarding fragments outside the unit circle.\n\
5
+ // Applies an approximate Gaussian falloff based on distance from the center and outputs\n\
6
+ // a color modulated by the alpha and Gaussian weight.\n\
7
+ //\n\
8
+ void main() {\n\
9
+ if (v_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;\n\
10
+ if (v_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;\n\
11
+ \n\
12
+ float A = -dot(v_vertPos, v_vertPos);\n\
13
+ if (A < -4.) {\n\
14
+ discard;\n\
15
+ }\n\
16
+ \n\
17
+ float B = exp(A * 4.) * v_splatColor.a ;\n\
18
+ out_FragColor = vec4(v_splatColor.rgb * B , B);\n\
19
+ }\n\
20
+ ";