Here we’ll give the rundown of a new Cesium feature, clipping planes, that will be available in Cesium 1.40, as well as some performance enhancements that went into it.
Clipping planes selectively disable rendering on the outside of a plane. They provide a way to hide part of a 3D tileset, a glTF model, or the globe’s terrain. Some use cases are hiding terrain that intersects with a 3D tileset, showing models under the surface of terrain, or providing cross sections of BIM models.
We accomplish this in Cesium by modifying the fragment shader on the fly to
discard any fragments that are clipped by the list of planes.
3D Tileset Traversal Clipping Optimizations
3D tileset traversal uses spatial coherence in a spatial data structure to traverse a tileset. When a tile is fully visible, no culling checks are needed. When it is fully invisible, recursion stops. When it intersects a plane defining the bounds of the view, culling recursively continues. When clipping planes are used, the traversal can be optimized by culling the clipped tiles.
This means a tile can fall under one of the three following cases, determined by how the plane intersects with the tile’s bounding volume.
Case #1: A tile is completely culled
Tiles that are entirely on the outside of a clipping plane are hidden and therefore their children are not traversed, which means they are never requested even if they would had previously been loaded.
Case #2: A tile is completely visible
Tiles that are not clipped, or are entirely inside of the clipping plane are fully visible. This means we use the original “fast path” shader, and no additional clipping plane operation is performed.
Case #3: A tile intersects the clipping plane
Only tiles that intersect the clipping plane use the slower, modified shader, which uses the
discard keyword and therefore disables early-z tests.
Above, we can see a debug view of a BIM 3D tileset with each tile’s bounding volume drawn. As the clipping plane moves through the model, tiles are culled where the content is completely hidden by the clipping plane.
Because of the optimizations described above, clipping a 3D tileset improves performance. Included below is a comparison of the performance when the clipping optimization is enabled and when it is not. The left image is a view of a New York City buildings 3D tileset. On the right, we’ve added a clipping plane halfway across the bounds of the view, so the portion of the tileset on the left of the blue edge is clipped. Below, we’ve compared the number features (buildings) loaded, as well as the number of triangles across all buildings.
|View of New York 3D Tileset, Not Clipped||View of New York 3D Tileset, Clipped|
|Features selected: 4,750||Features selected: 2,428|
|Triangles selected: 405,560||Triangles selected: 229,280|