zvd2 wrote: ↑Wed Jun 27, 2018 1:28 pm
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.
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 );
}
cegui/src/RendererModules/Ogre/TextureTarget.cpp
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 );
You could try to get clever and enable hw gamma correction only when it was enabled in Ogre, but given that you'll very likely need it always on, this will get you started.
Cheers
Matias