summaryrefslogtreecommitdiff
path: root/servers/rendering/rasterizer_rd/shaders/tonemap.glsl
diff options
context:
space:
mode:
authorYetizone <andreii.lisita@gmail.com>2020-10-20 00:08:44 +0300
committerYetizone <andreii.lisita@gmail.com>2020-10-20 00:08:44 +0300
commitffc4151f29b21d7e11bb6d1b14171b466bcbe752 (patch)
tree355867520d6502175399e5f879a781d90662a932 /servers/rendering/rasterizer_rd/shaders/tonemap.glsl
parent2393fb43c352683192a8292a70f00e065412de77 (diff)
tonemap.glsl: Ensure color parameter of tonemap_reinhard() is positive
Color values can become negative in the case of negative lights which leads to undesired behaviour.
Diffstat (limited to 'servers/rendering/rasterizer_rd/shaders/tonemap.glsl')
-rw-r--r--servers/rendering/rasterizer_rd/shaders/tonemap.glsl4
1 files changed, 4 insertions, 0 deletions
diff --git a/servers/rendering/rasterizer_rd/shaders/tonemap.glsl b/servers/rendering/rasterizer_rd/shaders/tonemap.glsl
index a464048ebd..e7b46a0706 100644
--- a/servers/rendering/rasterizer_rd/shaders/tonemap.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/tonemap.glsl
@@ -157,6 +157,10 @@ 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);
}