Merge pull request #51439 from Calinou/tonemap-clamp-negative-colors-3.x

Clamp negative colors regardless of the tonemapper to avoid artifacts
This commit is contained in:
Rémi Verschelde 2021-08-10 09:56:18 +02:00 committed by GitHub
commit 5116855637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 6 deletions

View File

@ -160,10 +160,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 clamp((white * color + color) / (color * white + white), vec3(0.0f), vec3(1.0f));
}
@ -347,8 +343,9 @@ void main() {
#endif
// Early Tonemap & SRGB Conversion; note that Linear tonemapping does not clamp to [0, 1]; some operations below expect a [0, 1] range and will clamp
color = apply_tonemapping(color, white);
// Ensure color values 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), white);
#ifdef KEEP_3D_LINEAR
// leave color as is (-> don't convert to SRGB)