# Canonical gamma correction since r112

**URL:** <https://discourse.threejs.org/t/canonical-gamma-correction-since-r112/11756>\
**Category:** Questions\
**Tags:** webgl-renderer\
**Created:** [December 27, 2019, 4:09pm UTC](https://discourse.threejs.org/t/canonical-gamma-correction-since-r112/11756 "2019-12-27T16:09:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![al-ro](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@al-ro](https://discourse.threejs.org/u/al-ro)\
**Post date:** [December 27, 2019, 4:09pm UTC](https://discourse.threejs.org/t/canonical-gamma-correction-since-r112/11756/1 "2019-12-27T16:09:54Z")

</div>

Hello!

The recent migration guide says:

> `WebGLRenderer.gammaOutput` has been removed. Please use `WebGLRenderer.outputEncoding` instead.

There are examples online describing the old gammaOutput approach but I can’t find anything about the default behaviour of the new encoding approach.

What is the correct way to get gamma corrected output from a Three.js scene with no textures? For example a scene with geometries of various solid coloured Basic, Lambert and Standard materials, lights and shadows and I want to correct for gamma 2.2.

What about scenes with simple jpeg textures? And what about scenes with custom materials where colours are determined in a fragment shader? Do we do gamma correction before outputting the fragment colour or do we leave it to the renderer?

Thanks!

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [December 27, 2019, 5:07pm UTC](https://discourse.threejs.org/t/canonical-gamma-correction-since-r112/11756/2 "2019-12-27T17:07:47Z")

</div>

> [@al-ro](#):
>
> I want to correct for gamma 2.2.

Then use this line of code:

```js
renderer.outputEncoding = THREE.sRGBEncoding;

```

> [@al-ro](#):
>
> What about scenes with simple jpeg textures?

Normally, JPEG textures are sRGB encoded. So if you want to retain the original color as good as possible, you should define the texture’s encoding if you load it manually like so:

```js
texture.encoding = THREE.sRGBEncoding;

```

The renderer can then decode the texels into linear space for lighting equations in the shader. Notice, that this only happens for built-in materials. When implementing custom materials, you have to perform the decode by yourself.

> [@al-ro](#):
>
> And what about scenes with custom materials where colours are determined in a fragment shader? Do we do gamma correction before outputting the fragment colour or do we leave it to the renderer?

Custom shader materials are not automatically part of the renderer’s output encoding process. This only happens if you include the `encodings_fragment` shader chunk into your fragment shader code.

---

<div class="post-metadata">

**Author:** ![al-ro](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@al-ro](https://discourse.threejs.org/u/al-ro)\
**Post date:** [December 29, 2019, 9:50am UTC](https://discourse.threejs.org/t/canonical-gamma-correction-since-r112/11756/3 "2019-12-29T09:50:11Z")

</div>

Thanks, that is very helpful.
