Fix RGB channel swap in STBICodec RGB-to-RGBA conversion (v2-3)#567
Open
taylorhoward92 wants to merge 1 commit intoOGRECave:v2-3from
Open
Fix RGB channel swap in STBICodec RGB-to-RGBA conversion (v2-3)#567taylorhoward92 wants to merge 1 commit intoOGRECave:v2-3from
taylorhoward92 wants to merge 1 commit intoOGRECave:v2-3from
Conversation
stb_image always returns pixel data in RGB byte order, but the variable names in the 3-component conversion loop (b, g, r) assume BGR order. The code then writes r, g, b — which actually outputs B, G, R — into a buffer declared as PFG_RGBA8_UNORM (R first), swapping the red and blue channels. Fix by writing b, g, r (preserving stb's native RGB order), which matches the correct behaviour already present on master (v3-0). The visual effect of this bug is that all 3-channel RGB textures rendered through the STB codec have red and blue swapped (e.g. brown skin appears blue, lime-green appears teal). See the screenshots in osrf/homebrew-simulation#3394 (comment 4101535199) for an example. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
@taylorhoward92 I quickly tested your patch and it fixes the color swap problem in |
taylorhoward92
added a commit
to taylorhoward92/nixpkgs
that referenced
this pull request
Apr 9, 2026
Adds patch from OGRECave/ogre-next#567 to fix RGB→RGBA channel swap in STBICodec. Updates hash for PR 566 patch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
taylorhoward92
added a commit
to taylorhoward92/nixpkgs
that referenced
this pull request
Apr 9, 2026
Adds patch from OGRECave/ogre-next#567 to fix RGB→RGBA channel swap in STBICodec. Updates hash for PR 566 patch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
Contributor
it looks like the fix in 3.0.0 was made in #317 as part of a larger change |
scpeters
approved these changes
Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Summary
b, g, rassume BGR input, butstb_imagealways returns RGBr, g, b(actually B, G, R) intoPFG_RGBA8_UNORM(R-first) swaps red and blueb, g, rwrite order — this backports the fix to v2-3Visual evidence
See the screenshots in osrf/homebrew-simulation#3394 (comment) — the "Rescue Randy" model has blue skin and teal jacket instead of brown skin and lime jacket when ogre 2.3 is built without FreeImage (STB codec active).
Test plan
OGRE_CONFIG_ENABLE_FREEIMAGE=OFF,OGRE_CONFIG_ENABLE_STBI=ON)fuel_textured_mesh.sdfin gz-sim)