-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[3D] add support for gl_clipdistance (part 1) #57899
Conversation
Tests failed for Qt 6One or more tests failed using the build from commit 162308c pointcloud_3d_singlecolor_clipping (testPointCloudSingleColorClipping)pointcloud_3d_singlecolor_clippingTest failed at testPointCloudSingleColorClipping at tests/src/3d/testqgspointcloud3drendering.cpp:319 Rendered image did not match tests/testdata/control_images/3d/expected_pointcloud_3d_singlecolor_clipping/expected_pointcloud_3d_singlecolor_clipping.png (found 10028 pixels different) The full test report (included comparison of rendered vs expected images) can be found here. Further documentation on the QGIS test infrastructure can be found in the Developer's Guide. |
Tests failed for Qt 5One or more tests failed using the build from commit b3e8f7e pointcloud_3d_singlecolor (testPointCloudSingleColor)pointcloud_3d_singlecolorTest failed at testPointCloudSingleColor at tests/src/3d/testqgspointcloud3drendering.cpp:276
pointcloud_3d_colorramp (testPointCloudAttributeByRamp)pointcloud_3d_colorrampTest failed at testPointCloudAttributeByRamp at tests/src/3d/testqgspointcloud3drendering.cpp:316
pointcloud_3d_classification (testPointCloudClassification)pointcloud_3d_classificationTest failed at testPointCloudClassification at tests/src/3d/testqgspointcloud3drendering.cpp:353
pointcloud_3d_classification_pointsizes (testPointCloudClassificationOverridePointSizes)pointcloud_3d_classification_pointsizesTest failed at testPointCloudClassificationOverridePointSizes at tests/src/3d/testqgspointcloud3drendering.cpp:392
pointcloud_3d_filtered_classification (testPointCloudFilteredClassification)pointcloud_3d_filtered_classificationTest failed at testPointCloudFilteredClassification at tests/src/3d/testqgspointcloud3drendering.cpp:430
pointcloud_3d_filtered_scene_extent (testPointCloudFilteredSceneExtent)pointcloud_3d_filtered_scene_extentTest failed at testPointCloudFilteredSceneExtent at tests/src/3d/testqgspointcloud3drendering.cpp:472
The full test report (included comparison of rendered vs expected images) can be found here. Further documentation on the QGIS test infrastructure can be found in the Developer's Guide. |
656cf3c
to
6718c15
Compare
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.
Needs minor comment changes, but LGTM.
hi @ptitjano - sorry for taking so long to review this PR (holiday season is in full swing!) Thanks a lot for your efforts, going the route of clipping planes! It would be great to split this kind of work into smaller bits, it would make the review easier (e.g. one PR for addition of new materials, one PR for phong shaders refactoring, one PR for addition of clipping planes). As for the code changes:
I think the Phong material implementation needs to be cleaned up and clipping planes implementation needs to be updated before we can merge this... |
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
This is achieved by calling `setClipDistance` in the vertex shader if the clipping is enabled.
This is achieved by calling `setClipDistance` in the geometry shader if the clipping is enabled.
This adds two functions to setup clip planes on a 3d scene: - enableClipping() to enable opengl clipping - disableClipping() to disable opengl clipping The `enableClipping()` function achieves 3 things: - it stores the clipping plane equations - it adds clip planes to the framegraph - it enables the clipping on the material of the existing entities `disableClipping()` does the opposite things. The clip planes equations need to be stored to handle the dynamic addition of new entities. Indeed, when a new entity is added, clipping needs to be enabled on its material if necessary. This is achieved in `finalizeNewEntity` which is called on all new entities. However, this is not true for the terrain entity. That's why, `mTerrain` now listens to the `newEntityCreated` signal to call `handleClippingOnEntity()`.
0150229
to
ae79d8f
Compare
I'm used to projects where force push during review is considered a good practice. So, it has become a second nature.
In the end, we lose most of the benefits of git tooling :
I also think that github is well suited to handle review with force pushes. From the "Files Changed" tab, you can select "changes since your last review" which creates the same diffs than if there had not been no force push |
Nope... if I pick "changes since your last review", I get this because of the force push: The best github can give me is to unmark changed files as "viewed", but good luck re-reviewing files containing many changes... There's no way of knowing what has changed after a force push unless I would be keeping a local copy of the branch... |
@ptitjano we're all well aware there's a review people power problem here, let's not push for non-crucial development practices which make it in ANY way harder to review 🤣👍 |
My bad. Sorry for the inconvenience. I have never encountered this issue while reviewing PR on other github projects even when force pushed. |
I really don't want to derail this PR or write a rant... And I really thank you and @wonder-sk for all the time you spend reviewing. But as I tried to explain earlier, merged PR which contain "review commits" we lost most of the benefit of git: revert/ history/blame because the commit are not atomic anymore. And unfortunately, this happens often. QGIS has a really big code base and I'm still quite new at this thing. So, I spend a lot of times looking at the history to study the commits. Unfortunately, this is sometimes really hard and frustrating (I really mean it) because I sometimes study one commit for a long time, it does not seem to make sense, and a few commits later I see a commit named something like 'fix based on review' and I realize that if "fixes" the commit that I did not understand. It's not always easy to understand how QGIS internal work and if you can't use the commits, it makes the task much harder. |
My personal thoughts on "best practice" would be:
3a works if it makes sense for a single commit to represent the whole change set. 3b works otherwise, but isn't ideal from a security point of view (the force pushed commits could potentially contain anything, and won't be rereviewed before merging). There's no "perfect" approach here 😝. (That said -- You'll see everyone bends the rules at times and will merge messy things with commits with eg GitHub generated names after applying suggestions via the web, just because the benefit of a super clean history doesn't always outweigh the pain of cleanup/force push/wait hours for ci to finish.) I agree with @wonder-sk in that force pushed mid review make things really tricky, and force the reviewer to waste time rereading through all the old discussions and manually checking that everything's been addressed. It's slow and frustrating as a result. The worst option (in my view) is merge commits containing the full history. Those really mess up the git history and break blame/bisect/... etc. 🤮. |
I would disagree here, but in the end, it is a matter of personal preference what exactly an atomic commit should be. My personal preference is to have even bigger features all done in one "atomic" commit - at least it is easy to see what are all the ingredients. And "review commits" never bothered me really, so it is surprising to me they may be frustrating for others. After all, when doing git blame or looking into git history, one typically needs to look at the original PR anyway to get better context, so it does not matter if the work is done in one, two or ten commits... Agreed with the suggested "best practice" from @nyalldawson 👍 |
I guess we will agree that we disagree on this point. Anyway, I will try to follow the recommendations of @nyalldawson This PR should be ready now. |
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.
🎉 Looks good to me now - thanks for your efforts!
@ptitjano The PR is freeze exempt - would you like to get it merged now, or shall we merge it after the 3.40 release? |
Description
This PR adds support for gl_clipdistance as suggested by @wonder-sk in #57593 (review)
This allows to properly cut objects which are outside of the 3d scene extent. Contrary to #57593 it does not contain the rotation part. It will be added in a following PR. This is still useful in the general case to propery cut the objects at the border of the scene:
without gl_clipdistance
with gl_clipdistance
The PR itself is quite simple. 3 changes are needed:
Qt3DRender::QClipPlane
in the framegraph to addgl_clipDistance
supportFor each material:
-call
Qgs3DUtils::addBoundingBoxParametersToEffect
to define the plane equation as uniform for the equationgl_clipistance
in each vertex or geometry shader by callingsetClipDistance
(see shaders/clipplane.inc)The other changes provide some cleanup in the materials to limit the number of shader files and reduce the maintenance burden.
This should work for all the data sources (raster, vector, mesh, pointcloud, etc..)
Update October 8, 2024
This PR has been completely rewritten based on @wonder-sk feedback in #57899 (comment)
This PR introduces the necessary APIs to add support for clipping (
gl_ClipDistance
). The main logic is handled inQgs3DMapScene
:All the end user Material now inherit from a new
QgsMaterial
class. This allows to enable/disable on all the entities of a scene.I have added unit tests to ensure that clipping works for all the existing types handled by QGIS 3D.