Add function for extracting single channel data from an RGB[A] image (backport #706) #709
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎉 New feature
Related to gazebosim/jetty_demo#3
Summary
Adds a new
Image::ChannelData
function to help extract a single channel (r, g, b, or a) from an RGB[A] image.Thanks for profiling data from @azeey, it was found when loading the Jetty demo world a big chunk of time is spend on splitting the metallic and roughness maps of glb meshes. The main cause of slow down is found to be the Image::Pixel function as the AssimpLoader iterates through every pixel in the image. With the new
Image::ChannelData
function, the AssimpLoader now has a faster and more efficient way of retrieving different channels of the input image.Note that the perf issue with
Image::Pixel
function was also noticed in #699 (comment). Some changes were made to speed it up but seems like it's still not efficient. We'll need to revisit this later on.For the Jetty demo world, the speed up for splitting the channels of an image was found to be >10x. See example timings (seconds):
The load time for the demo world reduced from 42s (with gazebosim/gz-sim#3070) to 30s on my machine.
Checklist
codecheck
passed (See contributing)Generated-by: Remove this if GenAI was not used.
Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
andGenerated-by
messages.This is an automatic backport of pull request #706 done by [Mergify](https://mergify.com).