I was reading this article Color management in three.js · GitHub which recommends our projects use renderer.outputEncoding = THREE.sRGBEncoding; for realistic color management. Everything was looking great, until I started adding the Bloom post-processing effect and FXAA via the effect composer.
Bloom with threshold = 1 should have no effect, yet it makes the scene.background color brighter.
Renderer should have .outputEncoding = sRGBEncoding if no post-processing is used, otherwise use LinearEncoding and apply gamma correction (TBD) as last pass in post instead.
I used LinearEncoding, but everything looks dark & saturated now. So my question is, how do I enable this encoding in the post-processing pass? I see a function in both Unreal and FXAA shaders:
const gammaCorrectionPass = new ShaderPass( GammaCorrectionShader );
composer.addPass( gammaCorrectionPass );
Keep in mind it’s not exactly like outputEncoding = sRGBEncoding, though, because Fog and Scene.background need to be manually converted to linear color space otherwise they’ll look incorrect.
Is sRGBencoding and 2.2 gamma just two different ways of describing the same color-space? If I say gamma 1.0, is it identical as saying “linear encoding”? I hear them used interchangeably all the time.
No, they are similar but not exactly the same. Gamma is just a really simple exponent curve. My understanding is that sRGB was created since simple gamma correction gives bad results in lower end (near black). So sRGB is (nearly?) the same as gamma 2.2 everywhere except in the blacks.
Gamma curve:
The function linear to gamma 2.2 is really simple. Just do x^{\frac{1}{2.2}} where x is r,g and b.
I’m currently struggling with the colorCorrectionShader, to be precise it works fine on the mesh texture but washes out the saturation from the background (and also the shadow below the object).
Can you provide a code example for the manually conversion for the background color space? Thanks