# RGB Artifacts Appearing When Khronos toneMapping enabled

**URL:** <https://forum.babylonjs.com/t/rgb-artifacts-appearing-when-khronos-tonemapping-enabled/56514>\
**Category:** Questions\
**Created:** [February 11, 2025, 12:21pm UTC](https://forum.babylonjs.com/t/rgb-artifacts-appearing-when-khronos-tonemapping-enabled/56514 "2025-02-11T12:21:54Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [February 11, 2025, 12:21pm UTC](https://forum.babylonjs.com/t/rgb-artifacts-appearing-when-khronos-tonemapping-enabled/56514/1 "2025-02-11T12:21:54Z")

</div>

Hi everyone,

I’m encountering an issue when adjusting the `scene.imageProcessingConfiguration.exposure` value and toneMapping is enabled.

- When setting `scene.imageProcessingConfiguration.exposure = 1;`, everything renders fine.
- When setting `scene.imageProcessingConfiguration.exposure = 0.8;`, green artifacts appear on the surface.

> **[Babylon.js Playground](https://playground.babylonjs.com/#RUYAP4)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

I don’t know what could be causing this—it came from nowhere :))  
Thanks

tldr: This issue happens only on some PCs, while on others, everything works fine  
This is how it looks on my pc

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/a/2a0543f7d4387e7583fdcf097a214c0c7d318a4e.jpeg)

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [February 11, 2025, 2:01pm UTC](https://forum.babylonjs.com/t/rgb-artifacts-appearing-when-khronos-tonemapping-enabled/56514/2 "2025-02-11T14:01:40Z")

</div>

I remember I had the same thing but with blue color.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 11, 2025, 5:55pm UTC](https://forum.babylonjs.com/t/rgb-artifacts-appearing-when-khronos-tonemapping-enabled/56514/3 "2025-02-11T17:55:24Z")

</div>

I got 404 on the textures:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/d/9d7406a1208c935449101e0ef669e00cb9ae2e70.jpeg)

But i can see the green dots still…Investigating

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 11, 2025, 6:01pm UTC](https://forum.babylonjs.com/t/rgb-artifacts-appearing-when-khronos-tonemapping-enabled/56514/4 "2025-02-11T18:01:05Z")

</div>

cc @sebavan to check as I think he did the Khronos tone mapping.

I spotted nothing wrong at first glance (and be patient Seb is on vacation this week :))

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [February 11, 2025, 6:15pm UTC](https://forum.babylonjs.com/t/rgb-artifacts-appearing-when-khronos-tonemapping-enabled/56514/5 "2025-02-11T18:15:59Z")

</div>

> **[Babylon.js Playground](https://playground.babylonjs.com/#RUYAP4%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

Updated pg, …sorry, I was sabotaged from the inside :))  
Yes, no hurry

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 11, 2025, 6:16pm UTC](https://forum.babylonjs.com/t/rgb-artifacts-appearing-when-khronos-tonemapping-enabled/56514/6 "2025-02-11T18:16:00Z")

</div>

ok the glsl shader relevant code is:

```auto
result.rgb *= exposureLinear;
result.rgb = PBRNeutralToneMapping(result.rgb);
result.rgb = toGammaSpace(result.rgb);
result.rgb = saturate(result.rgb);

```

To fix it:

```auto
result.rgb *= exposureLinear;
result.rgb = saturate(result.rgb); <<<-----
result.rgb = PBRNeutralToneMapping(result.rgb);
result.rgb = toGammaSpace(result.rgb);
result.rgb = saturate(result.rgb);

```

@Evgeni_Popov / @sebavan thoughts on that?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 11, 2025, 6:35pm UTC](https://forum.babylonjs.com/t/rgb-artifacts-appearing-when-khronos-tonemapping-enabled/56514/7 "2025-02-11T18:35:56Z")

</div>

In my understanding, tone mapping is used to remapp the [0,+oo] input range to [0,1]. So, clamping the input range to [0,1] before doing tone mapping doesn’t look right to me.

[EDIT] It seems the output of `PBRNeutralToneMapping` can have negative r/g/b components. Adding `result.rgb = max(result.rgb, vec3(0.));` after the call gets rid of the green pixels.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 11, 2025, 7:03pm UTC](https://forum.babylonjs.com/t/rgb-artifacts-appearing-when-khronos-tonemapping-enabled/56514/8 "2025-02-11T19:03:54Z")

</div>

oh so maybe then we simply need to saturate before the toGammaSpace?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 12, 2025, 9:53am UTC](https://forum.babylonjs.com/t/rgb-artifacts-appearing-when-khronos-tonemapping-enabled/56514/9 "2025-02-12T09:53:39Z")

</div>

Looking at the source code of `` from Khronos, it looks like the output should be in the [0,1] range, so we shouldn’t have to saturate the color.

After closer inspection, it seems we have floating-point precision problems:

```glsl
vec4 applyImageProcessing(vec4 result) {
    result.rgb *= 0.8; // exposureLinear
    // INSERT HERE
    result.rgb = PBRNeutralToneMapping(result.rgb);
    result.rgb = toGammaSpace(result.rgb);
    result.rgb = saturate(result.rgb);
    return result;
}

```

Adding `result.rgb = max(result.rgb, vec3(1e-7))` at the `INSERT HERE` line makes it work, but not `result.rgb = max(result.rgb, vec3(0))`. Strange thing is that using 1e-30 instead of 1e-7 makes it also work, whereas 1e-30 can’t be represented with a 32 bits float, so I would expect it to be replaced with 0 (but maybe it’s replaced with the smallest value greater than 0 that can be represented with a 32 bits float)…

Another strange thing is that if I replace 0.8 with `exposureLinear` (`exposureLinear` is set to 0.8), it does work with the `result.rgb = max(result.rgb, vec3(0))` fix, no need for the `1e-7` value!

Also, some values of `exposureLinear` (like 0.5) don’t produce green pixels, they don’t need the fix.

So, it looks like floating point operation errors. It could also be specific to some GPUs. @MarianG said it only occurs on some PCs and not on others, maybe a NVidia specific problem (I have a Nvidia GPU)?

[…] New findings: there is no problem with the PG with WebGPU. So, I tested it by setting OpenGL as the ANGLE backend, and it works too (it also works with D3D9, but not with D3D11/D3D11On12)! So, it seems to be an ANGLE problem, perhaps specific to the Nvidia GPU. I’m going to create an issue in the Chromium repo.

---

<div class="post-metadata">

**Author:** ![MarianG](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mariang/32/138_2.png) [@MarianG](https://forum.babylonjs.com/u/MarianG)\
**Post date:** [February 12, 2025, 10:29am UTC](https://forum.babylonjs.com/t/rgb-artifacts-appearing-when-khronos-tonemapping-enabled/56514/10 "2025-02-12T10:29:35Z")

</div>

Hi, yes, I can confirm it is working on AMD Ryzen 9 5900HX, but it is not working on integrated Intel CPU or dedicated NVIDIA GeForce RTX 4060

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 12, 2025, 2:10pm UTC](https://forum.babylonjs.com/t/rgb-artifacts-appearing-when-khronos-tonemapping-enabled/56514/11 "2025-02-12T14:10:51Z")

</div>

I created the issue in the Chromium tracker:

[https://issues.chromium.org/issues/396060194](https://issues.chromium.org/issues/396060194)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 12, 2025, 5:15pm UTC](https://forum.babylonjs.com/t/rgb-artifacts-appearing-when-khronos-tonemapping-enabled/56514/12 "2025-02-12T17:15:27Z")

</div>

Again? Well hopefully they will fix it soon 🙂
