Ogre Version: 2.1
Render System: GL3Plus
When I'm not using gamma correction on my renderwindow my textures appear too dark but when I am using gamma correction cegui assets appear too bright. What's the proper way of doing this?
Gamma correction & cegui Topic is solved
-
- Gnoblar
- Posts: 15
- Joined: Mon Jun 25, 2018 7:05 pm
- x 3
Re: Gamma correction & cegui
While I'm at it, shouldn't it be possible to automatically detect whether gamma correction is necessary? At the very least I've never seen any other 3D program require this to be set manually.
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1280
- Contact:
Re: Gamma correction & cegui
Hi!
I don't like the term "gamma correction" but I rather prefer "sRGB space". Colour can be in linear space or sRGB space (there are more). Just like in 3D transformations there's local, world and view space (among many others, possibly arbitrary spaces, because in Einstein terms, it's all relative).
Photorealistic rendering, which is what we commonly use PBR for, definitely needs "gamma correction" to be enabled, always. However if you're not doing photorealistic rendering, you may or may not want to turn it off depending on your artistic needs.
I do agree gamma correction should be on by default, rather than off. It's just something that slipped by and has historically been optional, being off the default (mostly because Ogre is now a 18 year old engine).
As for your problem, i.e. CEGUI not working fine with sRGB, I thought it would be fixed by now.. sigh.
Find OgreTexture::createEmptyOgreTexture and OgreTextureTarget::declareRenderSize in CEGUI's source code, and right after creating the Textures, call setHardwareGammaEnabled:
cegui/src/RendererModules/Ogre/TextureTarget.cpp
Code: Select all
//----------------------------------------------------------------------------//
void OgreTexture::createEmptyOgreTexture()
{
// try to create a Ogre::Texture with given dimensions
d_texture = Ogre::TextureManager::getSingleton().createManual(
getUniqueName(), "General", Ogre::TEX_TYPE_2D,
1, 1, 0,
Ogre::PF_A8B8G8R8);
d_texture->setHardwareGammaEnabled( true );
}
Code: Select all
//----------------------------------------------------------------------------//
void OgreTextureTarget::declareRenderSize(const Sizef& sz)
{
// exit if current size is enough
if ((d_area.getWidth() >= sz.d_width) && (d_area.getHeight() >=sz.d_height))
return;
Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual(
OgreTexture::getUniqueName(),
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D, sz.d_width, sz.d_height, 1, 0, Ogre::PF_A8R8G8B8,
Ogre::TU_RENDERTARGET);
rttTex->setHardwareGammaEnabled( true );
Cheers
Matias
-
- Gnoblar
- Posts: 15
- Joined: Mon Jun 25, 2018 7:05 pm
- x 3
Re: Gamma correction & cegui
Thank you very much for the extensive reply, your suggestion worked perfectly.
- areay
- Bugbear
- Posts: 819
- Joined: Wed May 05, 2010 4:59 am
- Location: Auckland, NZ
- x 69
Re: Gamma correction & cegui
Late to the party but the first cegui source that needs editting is cegui/src/RendererModules/Ogre/Texture.cpp