Gamma Correction and Tone Mapping

Posted on

Helmet: Gamma Correct / Gamma Correct + Tone Mapping / No Gamma or Tone Mapping
Damaged Helmet: Gamma Corrected / Not Corrected
Specular Highlight: Gamma Corrected / Not Corrected
Teapot: Gamma Corrected / Not Corrected

Gamma Correction and Tone Mapping are now implemented in Castle Game Engine. They can be trivially controlled by global variables GammaCorrection (by default it is on for PBR materials) and ToneMapping.

Gamma Correction is a way of making lighting calculations more correct (see e.g. here and here for explanation; my analysis of various implementation is here).

Tone Mapping is just a fancy name for nice-looking color processing, that makes the final look more visually pleasing. It is independent from the gamma correction (technically), although they both “change the scene colors” so are often considered together. We now implement 3 tone mapping operators (based on glTF sample viewer): see TToneMapping. Note that you can easily do your own color processing (thus providing functionality equivalent to these tone-mapping operators) by using Effect node like in this example: tone_mapping.x3dv from demo models.

I wrote a new manual chapter about Gamma Correction documenting all of this, and my description of gamma correction in various engines was also extended.

Start the discussion at Castle Game Engine Forum