How to use ClippingPlane To flatten 3dTiles


I am modifying Cesium’s ClippingPlanes source code to implement the functions shown in the figure below, but I have encountered some problems.The picture is implemented by others using cesium.

float clip(vec4 fragCoord, sampler2D clippingPlanes, mat4 clippingPlanesMatrix)
    bool clipped = true;
    vec4 position = czm_windowToEyeCoordinates(fragCoord);
    vec3 clipNormal = vec3(0.0);
    vec3 clipPosition = vec3(0.0);
    float clipAmount = 0.0;
    float pixelWidth = czm_metersPerPixel(position);
    for (int i = 0; i < 1; ++i)
        vec4 clippingPlane = getClippingPlane(clippingPlanes, i, clippingPlanesMatrix);
        clipNormal =;
        clipPosition = -clippingPlane.w * clipNormal;
        float amount = dot(clipNormal, ( - clipPosition)) / pixelWidth;
        clipAmount = max(amount, clipAmount);
        clipped = clipped && (amount <= 0.0);
    if (clipped)
    return clipAmount;
void main() 
    float clipDistance = clip(gl_FragCoord, gltf_clippingPlanes, gltf_clippingPlanesMatrix); 
    vec4 clippingPlanesEdgeColor = vec4(1.0, 0.0, 0.0, 1.0); 
    float clippingPlanesEdgeWidth = gltf_clippingPlanesEdgeStyle.a; 
    if (clipDistance > 0.0 && clipDistance < clippingPlanesEdgeWidth) 
        gl_FragColor = clippingPlanesEdgeColor;

I hope to pass the normal plane coordinates to the vertex shader and let it modify the 3dtiles
Height to realize the function in the picture.

Please forgive me, my English is not enough for me to express what I want to say, so the above words are from google translation


1 Like

Welcome to the Cesium Community!

What kinds of problem are you running into?

Hi, I wonder if you have any progress? I am also working on this problem but have no idea how to do next.