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

Use proper sRGB conversion in DepthCamera #766

Merged
merged 2 commits into from
Nov 28, 2022

Conversation

darksylinc
Copy link
Contributor

@darksylinc darksylinc commented Nov 27, 2022

🦟 Bug fix

No ticket was filed for this issue

Summary

Depth Camera uses an approximation for sRGB conversion.

This causes regular Camera to slightly but visibly differ in their RGB output compared to the one done by Depth Camera (stored encoded as RGBA8888 in the A channel of the DepthCamera).

This fix causes cameras to identically match 100% both outputs (possibly some GPUs may have a margin of error of up to 1/255 due to precision issues with floating points. DepthCamera already suffers a few problems due to assembly code not understanding that we store a binary encoded value in a F32 value; and sometimes denormals or NaNs get flushed).

Without this patch, here's a an output of a Regular Camera (Note these pictures were taking using Garden while this PR is targeting Fortress):

Original

And here's an output of a Depth Camera:

Depth

The shades of green are quite apart (R, G, B) and can be seen by the naked eye if you toggle between them:

Normal Depth
5, 185, 5 10, 177, 10
2, 143, 2 6, 134, 6
0, 73, 0 0, 66, 0

The shadow is also in a different colour, but there's no point to keep pointing it out.

After this patch, the output produced is binary identical.

Update: Correction. It's NOT binary identical. The error seems to be up to 3 / 255. A bit more than I'd hope, but much better than having the current massive error where it's even visible with the naked eye.

Update:

The error depends on GPU and backend. However it is quite good. At worst case, only 14 pixels out of 10.000 pixels were not exact with a max seen error of 9 / 255.

Vulkan backend fares MUCH better in providing exact results (these tests were made in Garden, not in Fortress).

Max. Error Num Pixels that aren’t exact (in 100x100 image)
OpenGL (SW Mesa, llvmpipe) 3 6
OpenGL (Radeon RX 6800 XT, Mesa) 9 14
Vulkan (Radeon RX 6800 XT, RADV) 2 5
Vulkan (Radeon RX 6800 XT, AMDVLK) 1 9

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • 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 and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Also backport Metal shader compilation fix from Garden.

Signed-off-by: Matias N. Goldberg <[email protected]>
@darksylinc darksylinc requested a review from iche033 as a code owner November 27, 2022 21:51
@github-actions github-actions bot added the 🏯 fortress Ignition Fortress label Nov 27, 2022
@codecov
Copy link

codecov bot commented Nov 28, 2022

Codecov Report

Merging #766 (49f58c1) into ign-rendering6 (dcd40b8) will not change coverage.
The diff coverage is n/a.

❗ Current head 49f58c1 differs from pull request most recent head 3610a05. Consider uploading reports for the commit 3610a05 to get more accurate results

@@               Coverage Diff               @@
##           ign-rendering6     #766   +/-   ##
===============================================
  Coverage           77.82%   77.82%           
===============================================
  Files                 146      146           
  Lines               13399    13399           
===============================================
  Hits                10428    10428           
  Misses               2971     2971           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@iche033 iche033 merged commit 395deab into gazebosim:ign-rendering6 Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏯 fortress Ignition Fortress
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants