-
Notifications
You must be signed in to change notification settings - Fork 486
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
Fixing WideAngleCamera Lensflare issue #3276
Conversation
Added one more change for Z check based on this comment #3273 (comment) |
This fix works for me 👍 I moved around a pair of wideangle cameras at various angles and positions in a world with a DEM, and I no longer see the lens flare disappearing when it isn't supposed to. |
gazebo/rendering/LensFlare.cc
Outdated
double occlusionScale = 1.0; | ||
if (lightPos.z >= 0.0) | ||
{ | ||
// loop through all env cameras | ||
for (auto cam : ogreEnvCameras) | ||
{ | ||
// project light world point to camera clip space. | ||
auto viewProj = cam->getProjectionMatrix() * cam->getViewMatrix(); |
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.
replace cam
with _wideAngleCam
two times on this line
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.
Hmm, _wideAngleCam
doesn't have getProjectionMatrix()
method here.
gazebo/rendering/LensFlare.cc
Outdated
this->dataPtr->lightWorldPos); | ||
break; | ||
ignition::math::Pose3d( | ||
Conversions::ConvertIgn(cam->getDerivedPosition()), |
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.
replace cam
with _wideAngleCam
on this and the following line
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, _wideAngleCam
doesn't have getDerivedPosition()
here
gazebo/rendering/LensFlare.cc
Outdated
std::vector<Ogre::Camera *> ogreEnvCameras = _wideAngleCam->OgreEnvCameras(); | ||
|
||
// set dummy camera properties based on env cam | ||
Ogre::Camera *cam = ogreEnvCameras[0]; |
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 think the cam
and ogreEnvCameras
variables can be removed if all instances of cam
are replaced by _wideAngleCam
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.
actually just checking if cam
should be replaced by _wideAngleCam
in the calls below. I remember I had to use cam
(one of the env cameras) because it has the right properties for doing ray casting. Can you do a quick check and print out the viewport size, FOV, and aspect ratio for cam
vs _wideAngleCam
? I think they could be different.
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's a good point
I've restarted the windows build |
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.
It would be nice to add an example world or a test which has the camera in various poses, showing when the lensflare is supposed to appear and when it isn't.
719cc88
to
3db8327
Compare
Thanks to some debugging help from @iche033, I added some additional cameras in d33593d and c92f948 to illustrate some problems with the occlusion checking in the test world added in this pull request
Failure to occlude in
|
* Fixing Z check in WideAngleCamera::Project3d Signed-off-by: Sanjuksha Nirgude <sanjuksha@gmail.com> Added a test case for wideangle camera lensflare Signed-off-by: Aditya <aditya050995@gmail.com> Add extra model in test world The pre-existing model in the test world exhibits the lens flare rendering bug without the fix in this branch, so I added an extra model at a different pose that does not exhibit the bug. It makes it easier to confirm that the bug is fixed. * Add extra cameras with occluded views * Add another camera with box to its side that is incorrectly occluded Signed-off-by: Steve Peters <scpeters@openrobotics.org>
* Reverse extraneous z-up to y-up transform that was corrupting WideAngleCamera LensFlare results. Fixed small related bugs. * Use fisheye cameras in lensflare_wideangle_cam.world to improve testing of lens flare.
* Fixing Z check in WideAngleCamera::Project3d Signed-off-by: Sanjuksha Nirgude <sanjuksha@gmail.com> Added a test case for wideangle camera lensflare Signed-off-by: Aditya <aditya050995@gmail.com> Add extra model in test world The pre-existing model in the test world exhibits the lens flare rendering bug without the fix in this branch, so I added an extra model at a different pose that does not exhibit the bug. It makes it easier to confirm that the bug is fixed. * Add extra cameras with occluded views * Add another camera with box to its side that is incorrectly occluded Signed-off-by: Steve Peters <scpeters@openrobotics.org>
Signed-off-by: Sanjuksha Nirgude sanjuksha@gmail.com
🦟 Bug fix
#3273
Summary
Porting the same change for gazebo classic from gazebosim/gz-rendering#746 and a fix for wide angle camera not showing lensflare at certain angles. Wide Angle camera used to loop through all cameras to find the occlusion scale which resulted into not rendering lensfalre at certain angles. The fix removes the looping through all cameras and uses the camera facing the light source to calculate occlusion.
Checklist
codecheck
passed (See contributing)Results