-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow users to define clipping regions with polygons #11750
Conversation
Hi @ggetz Your implementation could greatly enhance the way users interact with external 3D integration into 3Dtileset. This is why your contribution is viewed as a key feature for us and the community. We found a glitch with shadows where the hidden part always casts shadows, which is quite annoying when we want to do a shadow analysis of an integrated CAD or BIM model. Looking forward to your thoughts and any further actions you deem necessary to bring this PR to completion. Let's make this amazing feature available to everyone in the CesiumJS community! |
Very interesting tool! @cesiumgs-admin do you know when will be avalaible? |
Thanks @tbenazzi and @Masty88 for the interest! We are reviewing some performance impact of this feature currently, and I'm aiming to get it into the March 1 release.
This is a good point. We will evaluate whether its possible to include in this iteration. If not, we will certainly open a feature request for it. Thanks for the idea! |
Hi, |
@saadatali48 Sorry for the delay. This PR is next on my list, and ideally will go out with the next release. Thanks for the interest! |
@jjhembd This should be ready for a first pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ggetz, I'm still reviewing, but here's a few minor comments / questions from what I've read so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more comments & questions on the code.
packages/engine/Source/Shaders/Model/ModelClippingPolygonsStageFS.glsl
Outdated
Show resolved
Hide resolved
packages/engine/Source/Shaders/Builtin/Functions/clipPolygons.glsl
Outdated
Show resolved
Hide resolved
@jjhembd Thanks for pointing this out. Was this the only polygon in the scene or were there multiple? |
Thanks for pointing this out @jjhembd. I think this should be resolved now.
Something seems to be very different about the behavior of root tiles on Google P3DT. I'm looking into that now. |
Thanks for the thorough review @jjhembd! I believe I've addressed all of you feedback and this is ready for another look. |
Thanks @ggetz, the code is looking good, and the issue with large polygons is fixed. I have two more smaller comments on the Sandcastles. AEC Clipping SandcastleThis one works well, and it's a very interesting demo! Clipping Regions SandcastleThe clipping polygon seems to lose resolution when zooming out to a lower LOD in the underlying data. For example, here I clipped out part of Michigan: But when I zoom out, one point in the polygon appears to be lost: Zooming out further leaves only 4 points in the polygon, and the original shape is gone: This aggressive polygon simplification is similar in both Terrain and 3D Tiles. |
Thanks @jjhembd! I believe I've addressed your feedback. You can now see 1) a better view of the AEC clipping region, and 2) Michigan at scale. |
@jjhembd I've made some additional adjustments based on your feedback.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ggetz, this looks good to me! I am now not able to break it, even with many large and complex polygons.
Super thank you! |
Is clippingPolygon supported for VoxelPrimitive? |
@catnuko Not presently, but we can open a feature request for this. Would you mind giving us a few details about your use case? |
Hi there, Thanks a lot for this feature, which we have been waiting for a long time in CesiumJS. We tried to use in our applications, and it works great. We just have one issue, regarding performance, which doesn't allow us to use this feature in production : As soon as a clippingPolygon is created and enabled, the FPS of our app drops from 60 FPS to approx. 10-15 FPS. This only happens if the user is looking at the clippingPolygon directly, The further the viewer is from the clippingPolygon, the higher the FPS gets. I attached a video to give an example, where I first try to integrate a BIM model in a Photomesh using a clippingPolygon, which corresponds to the footprint of the BIM model. I then switch tabs to show you our production app, where we cut out the photomesh manually beforehand. You can see that the FPS doesn't drop in that case, showing that the performance issue comes from the clippingPolygon and not the rendering of the BIM model. low_fps_clippingPolygon.mp4 |
Thanks for the example @theogerritsen. We could definitely do more to improve performance on this feature. I opened a separate issue to track: #12258. I will also cross link your comment there. |
Description
The PR implements a new API for clipping that allows user to define a collection of polygonal areas rather than defining individual clipping planes.
This allows:
inverse
property to isolate regions instead of clipping themOut of scope for this PR:
PolygonHierarchy
(what would really should use to keep the API cohesive) definition supports an unlimited recursive list of holes, and how we pack that into the texture used for the compute command would need some work to support holes. It's also totally feasible to add ahierarchy
option at a later date. Given all that, I would suggest keeping it out of the scope of this PR and see if the feature is requested.Sandcastle Example
Sandcastle Example
This is implemented very similar to clipping planes, where we:
ClippingPolygon
, defined by a list of three or more positions, andClippingPolygonCollection
for managing the list and stateGlobeFS
which add lines the fragment shader todiscard
the area within the polygonTo avoid doing inside/outside checks for each fragment, we instead use a
ComputeCommand
to generate a texture containing the signed distance from the polygons' edges, and the fragment shader instead samples the results from this pre-computed texture. Additionally, the spherical approximation method is borrowed from our implementation of texture mapping for groundPrimitives, and should be enough precision for most cases.Issue number and link
Fixes #8751
Testing plan
For both 3D Tiles and the globe (this sandcastle allows you to toggle between the two):
viewer.scene.debugShowFramesPerSecond = true;
Author checklist
CONTRIBUTORS.md
CHANGES.md
with a short summary of my changeExclude clipped areas from shadows