-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add LensFlarePass (ogre2 engine) #752
Conversation
949844f
to
335da24
Compare
I just pushed more commits. WideAngleCamera support was added. It took me longer than I thought because my previous PR (PR #733) added Ogre2WideAngleCamera but left out the ability to add RenderPasses to it. And I only realized when the time came. I had to slightly refactor how Ogre2WideAngleCamera works in order to support all kinds of RenderPasses (like LensFlare) in it. Fortunately I was VERY thorough in the new integration tests which let me caught various bugs with Render passes in It is now complete. Only |
|
||
if (!this->dataPtr->preferGpu || // | ||
!this->dataPtr->camera || // | ||
!this->dataPtr->camera->Parent() || // |
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.
remove the extra //
at the end?
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.
That comment prevents clang format from merging all statements into fewer lines.
const bool bIsAffine = transform.isAffine(); | ||
|
||
Ogre::Ray mouseRay; | ||
#ifndef SLOW_METHOD |
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.
is this a new macro or something defined in ogre? Maybe add a brief comment / doc about this macro?
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.
same question goes for the SINGLE_THREADED
macro
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.
I added explanations on the top.
These macros are basically "just in case" but (knocks on wood) should never be needed other than for benchmarking
Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
Add RayQuery::SetPreferGpu Add RayQuery::UsesGpu Add RenderPass::PreRender(const CameraPtr &) overload Add RenderTarget::PreRender(const CameraPtr &) overload Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
It would only work it the Pass was added before the Camera initializes the Compositor workspace Signed-off-by: Matias N. Goldberg <[email protected]>
SetOcclusionSteps(0) disables occlusion instead of causing divisions by 0 Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
Fix warning Signed-off-by: Matias N. Goldberg <[email protected]>
Add SINGLE_THREADED macro Signed-off-by: Matias N. Goldberg <[email protected]>
Changed how we render to it, because the old way was not friendly to adding RenderPass(es) to it Fix Ogre2WideAngleCamera::Copy, which would return garbage Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
It's failing, but for very little. Needs more research. Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
These accidentally slipped through the commits. Signed-off-by: Matias N. Goldberg <[email protected]>
Enable GPU RayQuery version on Apple Document SINGLE_THREADED & SLOW_METHOD macros Use kWideAngleNumCubemapFaces instead of literal 6 Fix typos Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
OK I pushed various fixes for the problems CI found. The only problem I see is that Metal version is complaining that VisualAt test is failing on macOS. However:
It would be great to know if this failure happens with on CI with regular main to discard whether this is a fault from this PR. Perhaps I should submit a PR with an innocuous change to see if macOS CI fails as well? |
Signed-off-by: Matias N. Goldberg <[email protected]>
OK macOS test has finished again, and this time VisualAt succeeded. Which is even more anxiety-inducing. Now macOS CI failed again; but this time it's something I recognize:
This particular test checks handedness is correct (i.e. the texture isn't upside down, mirrored, rotated). The sun should be coming from top left corner [0][0]; which means it should be the brightest part. But only the LensFlareWideAnglePass test fails; which means the actual problem is likely in the previous PR #733 and went undetected. I'll add another test for WideAngleCamera to detect handedness. UpdateOK I just charted the values from Metal's test:
The values are clearly Y-flipped, a common problem when dealing with shaders and different RenderSystems. For reference this is what my computer produces:
Now all that remains is to rule out whether this problem is caused by WideAngleCamera's last pass shader, or by LensFlare's shader during WideAngleCamera rendering. |
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.
you need the changes from gazebosim/gz-common#474 |
ahh weird. I thought it's my fault. I just went back to check CI for #758 and noticed that |
Btw there is no codecov comment. I thought it would appear once the CIs successfully ran the tests... but I guess it's not? |
I think it codecov may not work on PRs created from forks. I see that they are only run if it's a branch in this repo https://app.codecov.io/gh/gazebosim/gz-rendering/pulls |
Codecov Report
@@ Coverage Diff @@
## main #752 +/- ##
==========================================
+ Coverage 74.38% 75.15% +0.76%
==========================================
Files 160 162 +2
Lines 14673 15084 +411
==========================================
+ Hits 10915 11336 +421
+ Misses 3758 3748 -10
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
ah there we go, we now have codecov report :) I retriggered a few more github actions |
SetBackgroundColor would work before creating a Camera. However once a Camera was initialized, subsequent calls to SetBackgroundColor would be ignored Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
Signed-off-by: Matias N. Goldberg <[email protected]>
OK I've added a coordinate convention test to WideAngleCamera and as I suspected, the Metal version was upside down. In the process of writing this test I discovered a bug in This PR includes the fix for Now all tests pass on Metal, except for VisualAt, but appears to be unrelated to this PR. All tests related to this PR are passing so I see it as 100% ready for merge. BTW: Just to be sure, I ran our own (OgreNext) Readback Test(*) for Metal and everything appears to be OK from OgreNext side. (*)The readback test is an OgreNext test that tries to force race conditions to come out when reading from CPU what the GPU just wrote (if this test fails, then gazebo tests like VisualAt would definitely fail at random). I originally wrote it to stress-test our Vulkan RenderSystem. |
@sanjuksha here's a patch to ogre2_demo to see the effect: patchdiff --git a/examples/ogre2_demo/Main.cc b/examples/ogre2_demo/Main.cc
index 337cf1d1..1f9bdef0 100644
--- a/examples/ogre2_demo/Main.cc
+++ b/examples/ogre2_demo/Main.cc
@@ -303,6 +303,15 @@ CameraPtr createCamera(const std::string &_engineName,
noisePass->SetStdDev(0.08);
noisePass->SetEnabled(false);
camera->AddRenderPass(noisePass);
+
+ auto light = scene->LightByIndex(0u);
+ RenderPassPtr p = rpSystem->Create<LensFlarePass>();
+ LensFlarePassPtr lensFlarePass =
+ std::dynamic_pointer_cast<LensFlarePass>(p);
+ lensFlarePass->Init(scene);
+ lensFlarePass->SetEnabled(true);
+ lensFlarePass->SetLight(light);
+ camera->AddRenderPass(lensFlarePass);
}
return camera; Once you launch the demo, you can press Can you see if that works for you? |
Thanks @iche033 for the patch. Both of the mentioned tests in the description worked for me now. INTEGRATION_render_pass test |
Previous PR #752 added LensFlarePass to ogre2. This PR adds LensFlarePass to ogre1. This includes LensFlarePass support for ogre1's WideAngleCamera. WideAngleCamera had to be modified a little to support RenderPass at all. In theory the gaussian filter pass should also work with WideAngleCamera but I did not test it. It also implements OgreWideAngleCamera::Copy so that integration tests can function (Ogre2WideAngleCamera::Copy had already been implemented). OgreRayQuery also had to be modified to support OgreWideAngleCamera; since LensFlares need ray queries for occlusion support. Additionally I add RemoveAllRenderPasses since I noticed a lot of RenderPasses didn't get to properly deinitialize. Though it didn't seem like much harm was being done because currently all RenderPasses are very simple. Signed-off-by: Matias N. Goldberg <[email protected]>
🎉 New feature
Dependency
Depends on gazebosim/gz-common#474
Ticket
Affects #730
But it doesn't close it because the ticket says
ogre
backend as well.Summary
This PR does 3 things:
Ogre2RayQuery
SetOcclusionSteps
).The speed up of
Ogre2RayQuery
comes from:This results in a massive performance increase.
Results of iterating 1000 rays over Ogre2_demo scene intentionally hitting the broadphase stage of duck mesh but missing every single triangle (to avoid an early out) on a Ryzen 5950X 12C/24T 32GB:
Therefore this implementation achieves a 15x performance improvement on Debug builds and 6.91x improvement on Release builds.
YMMV not only because of the number of threads your system may have, but also because the threaded version is more susceptible to power state changes (Original & Optimize don't change their readings much when switching the governor from 'On Demand' to 'Performance' however Optimized + Threaded can take 1.6x longer as the CPU is not able ramp the frequency in time for all CPUs)
Test it
You can run
INTEGRATION_render_pass
or add this code to any sample (e.g. ogre2_demo):out.mp4
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.