浏览代码

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.
Yetizone 4 年之前
父节点
当前提交
ffc4151f29
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      servers/rendering/rasterizer_rd/shaders/tonemap.glsl

+ 4 - 0
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);
 }