Skip to content

Commit 86820f6

Browse files
committed
Removes old sdf-based clipping logic from Globe classes
1 parent 512656d commit 86820f6

4 files changed

Lines changed: 0 additions & 108 deletions

File tree

packages/engine/Source/Scene/GlobeSurfaceShaderSet.js

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,6 @@ class GlobeSurfaceShaderSet {
263263
);
264264
}
265265

266-
// Need to go before GlobeFS
267-
if (currentClippingPolygonsShaderState !== 0) {
268-
fs.sources.unshift(getPolygonClippingFunction(frameState.context));
269-
vs.sources.unshift(getUnpackClippingFunction(frameState.context));
270-
}
271-
272266
vs.defines.push(quantizationDefine);
273267
fs.defines.push(
274268
`TEXTURE_UNITS ${numberOfDayTextures}`,
@@ -364,20 +358,10 @@ class GlobeSurfaceShaderSet {
364358

365359
if (enableClippingPolygons) {
366360
fs.defines.push("ENABLE_CLIPPING_POLYGONS");
367-
vs.defines.push("ENABLE_CLIPPING_POLYGONS");
368361

369362
if (clippingPolygons.inverse) {
370363
fs.defines.push("CLIPPING_INVERSE");
371364
}
372-
373-
fs.defines.push(
374-
// @ts-expect-error Missing types.
375-
`CLIPPING_POLYGON_REGIONS_LENGTH ${clippingPolygons.extentsCount}`,
376-
);
377-
vs.defines.push(
378-
// @ts-expect-error Missing types.
379-
`CLIPPING_POLYGON_REGIONS_LENGTH ${clippingPolygons.extentsCount}`,
380-
);
381365
}
382366

383367
if (colorCorrect) {
@@ -542,41 +526,6 @@ function getPositionMode(sceneMode) {
542526
return positionMode;
543527
}
544528

545-
/**
546-
* @param {Context} context
547-
* @ignore
548-
*/
549-
function getPolygonClippingFunction(context) {
550-
// return a noop for webgl1
551-
// @ts-expect-error Missing types.
552-
if (!context.webgl2) {
553-
return `void clipPolygons(highp sampler2D clippingDistance, int regionsLength, vec2 clippingPosition, int regionIndex) {
554-
}`;
555-
}
556-
557-
return `void clipPolygons(highp sampler2D clippingDistance, int regionsLength, vec2 clippingPosition, int regionIndex) {
558-
czm_clipPolygons(clippingDistance, regionsLength, clippingPosition, regionIndex);
559-
}`;
560-
}
561-
562-
/**
563-
* @param {Context} context
564-
* @ignore
565-
*/
566-
function getUnpackClippingFunction(context) {
567-
// return a noop for webgl1
568-
// @ts-expect-error Missing types.
569-
if (!context.webgl2) {
570-
return `vec4 unpackClippingExtents(highp sampler2D extentsTexture, int index) {
571-
return vec4();
572-
}`;
573-
}
574-
575-
return `vec4 unpackClippingExtents(highp sampler2D extentsTexture, int index) {
576-
return czm_unpackClippingExtents(extentsTexture, index);
577-
}`;
578-
}
579-
580529
/**
581530
* @param {boolean} useWebMercatorProjection
582531
* @returns {string}

packages/engine/Source/Scene/GlobeSurfaceTileProvider.js

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,6 @@ class GlobeSurfaceTileProvider {
479479
if (defined(clippingPolygons) && clippingPolygons.enabled) {
480480
// @ts-expect-error Missing types.
481481
clippingPolygons.update(frameState);
482-
// @ts-expect-error Missing types.
483-
clippingPolygons.queueCommands(frameState);
484482
}
485483

486484
this._usedDrawCommands = 0;
@@ -2026,22 +2024,6 @@ function createTileUniformMap(frameState, globeSurfaceTileProvider) {
20262024
style.alpha = this.properties.clippingPlanesEdgeWidth;
20272025
return style;
20282026
},
2029-
u_clippingDistance: function () {
2030-
const texture =
2031-
globeSurfaceTileProvider._clippingPolygons.clippingTexture;
2032-
if (defined(texture)) {
2033-
return texture;
2034-
}
2035-
return frameState.context.defaultTexture;
2036-
},
2037-
u_clippingExtents: function () {
2038-
// @ts-expect-error Missing types.
2039-
const texture = globeSurfaceTileProvider._clippingPolygons.extentsTexture;
2040-
if (defined(texture)) {
2041-
return texture;
2042-
}
2043-
return frameState.context.defaultTexture;
2044-
},
20452027
u_minimumBrightness: function () {
20462028
return frameState.fog.minimumBrightness;
20472029
},
@@ -2588,7 +2570,6 @@ function addDrawCommandsForTile(tileProvider, tile, frameState) {
25882570
) {
25892571
// Vector polygon clipping samples three textures: edges, per-edge
25902572
// primitive indices, and the grid cell index header.
2591-
// TODO: remove the two decrements above when removing old clipping implementation.
25922573
maxTextures -= 3;
25932574
}
25942575

packages/engine/Source/Shaders/GlobeFS.glsl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,6 @@ uniform mat4 u_clippingPlanesMatrix;
7777
uniform vec4 u_clippingPlanesEdgeStyle;
7878
#endif
7979

80-
#ifdef ENABLE_CLIPPING_POLYGONS
81-
uniform highp sampler2D u_clippingDistance;
82-
in vec2 v_clippingPosition;
83-
flat in int v_regionIndex;
84-
#endif
85-
8680
#if defined(GROUND_ATMOSPHERE) || defined(FOG) && defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))
8781
uniform float u_minimumBrightness;
8882
#endif

packages/engine/Source/Shaders/GlobeVS.glsl

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ out vec3 v_atmosphereMieColor;
4646
out float v_atmosphereOpacity;
4747
#endif
4848

49-
#ifdef ENABLE_CLIPPING_POLYGONS
50-
uniform highp sampler2D u_clippingExtents;
51-
out vec2 v_clippingPosition;
52-
flat out int v_regionIndex;
53-
#endif
54-
5549
// These functions are generated at runtime.
5650
vec4 getPosition(vec3 position, float height, vec2 textureCoordinates);
5751
float get2DYPositionFraction(vec2 textureCoordinates);
@@ -214,32 +208,6 @@ void main()
214208
v_normalEC = czm_normal3D * v_normalMC;
215209
#endif
216210

217-
#ifdef ENABLE_CLIPPING_POLYGONS
218-
vec2 sphericalLatLong = czm_approximateSphericalCoordinates(position3DWC);
219-
sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);
220-
221-
vec2 minDistance = vec2(czm_infinity);
222-
v_clippingPosition = vec2(czm_infinity);
223-
v_regionIndex = -1;
224-
225-
for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) {
226-
vec4 extents = unpackClippingExtents(u_clippingExtents, regionIndex);
227-
vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;
228-
229-
vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));
230-
vec2 distance = abs(rectUv - clamped) * extents.wz;
231-
232-
float threshold = 0.01;
233-
if (minDistance.x > distance.x || minDistance.y > distance.y) {
234-
minDistance = distance;
235-
v_clippingPosition = rectUv;
236-
if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {
237-
v_regionIndex = regionIndex;
238-
}
239-
}
240-
}
241-
#endif
242-
243211
#if defined(FOG) || (defined(GROUND_ATMOSPHERE) && !defined(PER_FRAGMENT_GROUND_ATMOSPHERE))
244212

245213
bool dynamicLighting = false;

0 commit comments

Comments
 (0)