Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use selection buffer in ray queries (ogre2) #378

Merged
merged 11 commits into from
Sep 15, 2021

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Aug 12, 2021

馃帀 New feature

Replaces part of ray query logic with the use of selection buffer (mouse picking) for performance improvement.

The current ray query implementation has 2 stages:

  1. ray-bounding box check - broad phase check to narrow down the number of objects that are potentially clicked by the mouse
  2. ray-triangle intersection test - checks against all objects found in 1 and compute the actual 3d intersection point on the mesh.

These 2 stages are all done on the CPU and they can be slow if the user clicks on a region with multiple overlapping bounding boxes. This PR replaces stage 1 with the use of selection buffer which can efficiently return the first object that the user clicks on. So that in stage 2 we would only need to do ray intersection test with 1 mesh.

Stage 2 can also be improved. That'll come later. Update: see #383

Test it

Use ign-gazebo, insert multiple overlapping complex meshes, and try panning with the mouse by left clicking on a mesh in the scene and dragging the mouse. The movement should be less laggy with these changes. See gazebosim/gz-sim#969

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge

Signed-off-by: Ian Chen <ichen@osrfoundation.org>
Signed-off-by: Ian Chen <ichen@osrfoundation.org>
Signed-off-by: Ian Chen <ichen@osrfoundation.org>
@codecov
Copy link

codecov bot commented Aug 12, 2021

Codecov Report

Merging #378 (d74c222) into ign-rendering4 (cda2c27) will increase coverage by 0.40%.
The diff coverage is 93.86%.

Impacted file tree graph

@@                Coverage Diff                 @@
##           ign-rendering4     #378      +/-   ##
==================================================
+ Coverage           55.91%   56.32%   +0.40%     
==================================================
  Files                 147      147              
  Lines               13983    14119     +136     
==================================================
+ Hits                 7819     7952     +133     
- Misses               6164     6167       +3     
Impacted Files Coverage 螖
ogre2/src/Ogre2SelectionBuffer.cc 87.39% <92.24%> (+7.70%) 猬嗭笍
ogre2/src/Ogre2Camera.cc 88.00% <100.00%> (+0.19%) 猬嗭笍
ogre2/src/Ogre2RayQuery.cc 93.87% <100.00%> (+2.96%) 猬嗭笍

Continue to review full report at Codecov.

Legend - Click here to learn more
螖 = absolute <relative> (impact), 酶 = not affected, ? = missing data
Powered by Codecov. Last update cda2c27...d74c222. Read the comment docs.

ogre2/src/Ogre2RayQuery.cc Outdated Show resolved Hide resolved
ogre2/src/Ogre2RayQuery.cc Outdated Show resolved Hide resolved
@iche033
Copy link
Contributor Author

iche033 commented Sep 3, 2021

the UNIT_Utils_TEST failure is fixed in part 2, #383

* extend selection buffer to return depth

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* selection buffer depth working

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* cleanup

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* style

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* add check for mac

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* Add shaders

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* enable mac test

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* style

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* fix bad merge

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* fix drag and drop

Signed-off-by: Ian Chen <ichen@osrfoundation.org>

* fix utils test

Signed-off-by: Ian Chen <ichen@osrfoundation.org>
Signed-off-by: Ian Chen <ichen@osrfoundation.org>
Signed-off-by: Ian Chen <ichen@osrfoundation.org>
Copy link
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a minor comment

@iche033 iche033 merged commit 038317d into ign-rendering4 Sep 15, 2021
@iche033 iche033 deleted the rayquery_selection_buffer branch September 15, 2021 19:40
Core development automation moved this from In review to Done Sep 15, 2021
@j-rivero j-rivero removed this from Done in Core development May 6, 2022
@darksylinc darksylinc mentioned this pull request Oct 30, 2022
9 tasks
iche033 pushed a commit that referenced this pull request Dec 2, 2022
This PR does 3 things:

Adds Ogre2LensFlare
Adds tests to test this new pass to INTEGRATION_render_pass
Works for both normal Camera and WideAngleCamera.
Significantly optimizes Ogre2RayQuery
The original CPU implementation is ridiculously slow
PR Use selection buffer in ray queries (ogre2) #378 used a GPU implementation to address these issues. However the GPU version can't be easily used (without bigger refactors to how gz-rendering operates) because we need to render (for ray queries) while we are about to render (for lens flares). We cannot use the GPU version.
This PR adds an option to force CPU method.
LensFlare heavily relies on a lot of raycasts for occlusion (depends on the value passed to SetOcclusionSteps).

Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
馃敭 dome Ignition Dome
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants