Hello!
There is a need to use gamma in the application, and gamma value should be set up by user, so it is not always 2.2. Application uses Lemur. Following the documentation the next 3 steps were made:
1. Enable Gamma Correction global app setting.
2. Disable rendered output correction : renderer.setMainFrameBufferSrgb(false); (for example in the simpleInit method of your SimpleApplication).
3. Use the GammaCorrectionFilter in a FilterPostProcessor, and set the proper gamma value on it (default is 2.2).
Gamma correction works fine with the exception of GUI: textures in GUI became with linear colors, and because of this, are very dark Reason for this is because
FilterPostProcessor
is not run for guiViewPort
and renderer does not use linear to sRGB conversion, because we disabled it with renderer.setMainFrameBufferSrgb(false);
.
I tried to create own FilterPostProcessor
for guiViewPort
using such code:
FilterPostProcessor guiFilterPostProcessor = new FilterPostProcessor(assetManager);
guiFilterPostProcessor.addFilter(new GammaCorrectionFilter(1.8f));
guiViewPort.addProcessor(guiFilterPostProcessor);
It applies correct gamma correction for textures in GUI, but unfortunately main viewport is fully black. Looks like it is impossible to use FilterPostProcessor
for multiple viewports. Or is there a way?
There is a logical idea to make such ugly code:
guiViewPort.detachScene(guiNode);
rootNode.attachChild(guiNode);
which fixes gamma for GUI textures, but code smells and GUI gets all the post processor filters, not just GammaCorrectionFilter
…
Besides, if GammaCorrectionFilter
is run for GUI, texture color looks correct, but text color becomes brighter. It can be fixed with changing text color using new ColorRGBA().setAsSrgb()
, but such change should be done everywhere for GUI text, and it is not very convenient to use it.
Is it possible to set up gamma correction such way, so it is applied for main viewport, but does not break colors for textures and text in GUI? Maybe is it possible to work with GUI like it was before enabling gamma? Any advice is welcome.