diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-08-10 09:56:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-10 09:56:11 +0200 |
commit | 51b4df72a7d67b442cbb1a2db1610853895971de (patch) | |
tree | 130868ac3ba6df4398312916edf97e32cefaf863 /servers/rendering | |
parent | 56f17d925f774b3a80fdb2bc57c512e4bba063cb (diff) | |
parent | 57451f132ff5bf9481961d34d4d7ad4965a355e8 (diff) |
Merge pull request #51436 from Calinou/tonemap-clamp-negative-colors
Clamp negative colors regardless of the tonemapper to avoid artifacts
Diffstat (limited to 'servers/rendering')
-rw-r--r-- | servers/rendering/renderer_rd/shaders/tonemap.glsl | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/servers/rendering/renderer_rd/shaders/tonemap.glsl b/servers/rendering/renderer_rd/shaders/tonemap.glsl index f028195a74..3c685c25b9 100644 --- a/servers/rendering/renderer_rd/shaders/tonemap.glsl +++ b/servers/rendering/renderer_rd/shaders/tonemap.glsl @@ -184,10 +184,6 @@ vec3 tonemap_aces(vec3 color, float white) { } vec3 tonemap_reinhard(vec3 color, float white) { - // Ensure color values are positive. - // They can be negative in the case of negative lights, which leads to undesired behavior. - color = max(vec3(0.0), color); - return (white * color + color) / (color * white + white); } @@ -211,7 +207,7 @@ vec3 apply_tonemapping(vec3 color, float white) { // inputs are LINEAR, always o return tonemap_reinhard(color, white); } else if (params.tonemapper == TONEMAPPER_FILMIC) { return tonemap_filmic(color, white); - } else { //aces + } else { // TONEMAPPER_ACES return tonemap_aces(color, white); } } @@ -405,7 +401,9 @@ void main() { color += screen_space_dither(gl_FragCoord.xy); } - color = apply_tonemapping(color, params.white); + // Ensure color values passed to tonemappers are positive. + // They can be negative in the case of negative lights, which leads to undesired behavior. + color = apply_tonemapping(max(vec3(0.0), color), params.white); color = linear_to_srgb(color); // regular linear -> SRGB conversion |