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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential bug: Wrong value stuck in Ogre2GpuRays #521

Open
darksylinc opened this issue Dec 25, 2021 · 1 comment
Open

Potential bug: Wrong value stuck in Ogre2GpuRays #521

darksylinc opened this issue Dec 25, 2021 · 1 comment
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@darksylinc
Copy link
Contributor

Environment

  • OS Version: Ubuntu 18.04 LTS
  • Source or binary build?
    main 5e19061 but I think it affects all of them

Description

I noticed Ogre2LaserRetroMaterialSwitcher performs the following:

if (!subItem->hasCustomParameter(this->customParamIdx))
{
  // limit laser retro value to 2000 (as in gazebo)
  if (retroValue > 2000.0)
  {
    retroValue = 2000.0;
  }
  float color = retroValue / 2000.0;
  subItem->setCustomParameter(this->customParamIdx,
      Ogre::Vector4(color, color, color, 1.0));
}

Basically: "If we haven't set the retroValue yet, set it".

However I see two potential issues with this:

  • If the retro value can be changed at runtime (can it?) the change won't register unless Gazebo is recreating the associated Item
  • customParamIdx = 10u; which is also shared with the thermal camera (same value). As a result, if an object is both in the Thermal Camera and in GpuRays, then the Thermal Camera will override the retroValue (because ThermalCamera never checks hasCustomParameter( ... )) and later GpuRays will not try to override anything.

I see two possible solutions:

  1. Change customParamIdx = 10u; to one of the camera implementations (not recommended, this problem will reappear)
  2. Get rid of the if (!subItem->hasCustomParameter(this->customParamIdx)) check. It's no performance improvement, and this fix will get rid of the problem and any future clash.

Steps to reproduce

This was found through manual examination, but I suppose it should be possible to repro by using GpuRays and Thermal Camera at the same time on the same object

Other

It's possible both Ogre2 and Ogre1 backends are affected. I think the fix should be trivial to propagate to all branches without breaking ABI.

@darksylinc darksylinc added the bug Something isn't working label Dec 25, 2021
darksylinc added a commit to darksylinc/ign-rendering that referenced this issue Dec 26, 2021
There were multiple bugs that had to be fixed:

- Objects which had no laser_retro set (or an invalid one) would be
rendered using regular lighting PBS shaders; causing the retro value to
contain garbage instead of the intended default value of 0
- Performance regression in 993bb0b:
When ported to Ogre 2.2, ignition would render the scene 4 times instead
of 2 (twice for objects, twice for particles). Depth buffer data was
created through a 2nd redundant pass. This is inefficient as the depth
buffer data is already available from the 1st pass
- Bug regression in 993bb0b: In the
pass for normal objects, ignition would first use IGN_VISIBILITY_ALL
flags for colour, but it would use 0x01000000 for depth. This creates
the wrong mix of data because an occluder that had visibility set to
0x01000000 would use the correct depth but the retro value of the object
behind it. This bug is implicitly fixed by the previous item (colour and
depth data are now obtained from the same pass instead of using multi
pass)
- PFG_R8_UNORM is nowhere enough to contain all possible laser retro
values and would quantize too much. Increased precision to PFG_R16_UNORM
- Affects gazebosim#521. The problem is fixed for Fortress by always overriding
setCustomParameter, but likely the fix should be backported to previous
versions.

Signed-off-by: Matias N. Goldberg <[email protected]>
iche033 added a commit that referenced this issue Jan 5, 2022
There were multiple bugs that had to be fixed:

- Objects which had no laser_retro set (or an invalid one) would be
rendered using regular lighting PBS shaders; causing the retro value to
contain garbage instead of the intended default value of 0
- Performance regression in 993bb0b:
When ported to Ogre 2.2, ignition would render the scene 4 times instead
of 2 (twice for objects, twice for particles). Depth buffer data was
created through a 2nd redundant pass. This is inefficient as the depth
buffer data is already available from the 1st pass
- Bug regression in 993bb0b: In the
pass for normal objects, ignition would first use IGN_VISIBILITY_ALL
flags for colour, but it would use 0x01000000 for depth. This creates
the wrong mix of data because an occluder that had visibility set to
0x01000000 would use the correct depth but the retro value of the object
behind it. This bug is implicitly fixed by the previous item (colour and
depth data are now obtained from the same pass instead of using multi
pass)
- PFG_R8_UNORM is nowhere enough to contain all possible laser retro
values and would quantize too much. Increased precision to PFG_R16_UNORM
- Affects #521. The problem is fixed for Fortress by always overriding
setCustomParameter, but likely the fix should be backported to previous
versions.

Signed-off-by: Matias N. Goldberg <[email protected]>

Co-authored-by: Ian Chen <[email protected]>
@darksylinc
Copy link
Contributor Author

This bug is fixed in Fortress & Garden on Ogre2.
It should be backported to Citadel.

I don't know if the bug exists in Ogre1.

@chapulina chapulina added the help wanted Extra attention is needed label Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants