Skip to content

Commit

Permalink
Fix sRGB conversion issues
Browse files Browse the repository at this point in the history
This fixes a regression. Now tests pass again

Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
  • Loading branch information
darksylinc committed Feb 19, 2022
1 parent e241aba commit 6529b42
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ogre2/src/Ogre2Conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Ogre::PixelFormatGpu Ogre2Conversions::ogrePixelFormats[PF_COUNT] =
// PF_L16
Ogre::PFG_R16_UNORM,
// PF_R8G8B8A8
Ogre::PFG_RGBA8_UNORM_SRGB,
Ogre::PFG_RGBA8_UNORM,
};

//////////////////////////////////////////////////
Expand Down
13 changes: 8 additions & 5 deletions ogre2/src/Ogre2RenderTarget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,16 @@ void Ogre2RenderTarget::Copy(Image &_image) const
Ogre::PixelFormatGpu dstOgrePf = Ogre2Conversions::Convert(_image.Format());
Ogre::TextureGpu *texture = this->RenderTarget();

if (dstOgrePf != texture->getPixelFormat() &&
Ogre::PixelFormatGpuUtils::getEquivalentSRGB(dstOgrePf) ==
texture->getPixelFormat())
if (Ogre::PixelFormatGpuUtils::isSRgb(dstOgrePf) !=
Ogre::PixelFormatGpuUtils::isSRgb(texture->getPixelFormat()))
{
// Formats are identical except for sRGB-ness.
// Force a raw copy to go into the fast path (this is likely an Ogre bug)
dstOgrePf = Ogre::PixelFormatGpuUtils::getEquivalentSRGB(dstOgrePf);
// Force a raw copy by making them match (no conversion!).
// We can't change the TextureGpu format now, so we change dstOgrePf
if (Ogre::PixelFormatGpuUtils::isSRgb(texture->getPixelFormat()))
dstOgrePf = Ogre::PixelFormatGpuUtils::getEquivalentSRGB(dstOgrePf);
else
dstOgrePf = Ogre::PixelFormatGpuUtils::getEquivalentLinear(dstOgrePf);
}

Ogre::TextureBox dstBox(
Expand Down

0 comments on commit 6529b42

Please sign in to comment.