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:
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.