Hi!
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 = clippingPlane.xyz;
clipPosition = -clippingPlane.w * clipNormal;
float amount = dot(clipNormal, (position.xyz - clipPosition)) / pixelWidth;
clipAmount = max(amount, clipAmount);
clipped = clipped && (amount <= 0.0);
}
if (clipped)
{
discard;
}
return clipAmount;
}
void main()
{
gltf_clip_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
Thanks