mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 06:59:18 +02:00
Sanitize NaN/Inf in env cubemap and tonemap to stop one-frame black flashes
This commit is contained in:
@@ -46,6 +46,17 @@ vec4 tonemap(vec4 x)
|
||||
// with pureWhite=1.0 it collapses to identity (L*(1+L)/(1+L) = L) and
|
||||
// just clips HDR>1.0 at the framebuffer -> washed-out / burnt look.
|
||||
// ACES gives a smooth highlight shoulder + slight toe contrast.
|
||||
return FBOUT(vec4(ACESFilm(x.rgb), x.a));
|
||||
|
||||
// Last-line-of-defense sanitize. ACESFilm has the form
|
||||
// (x*(a*x+b)) / (x*(c*x+d)+e)
|
||||
// which maps NaN -> NaN and +Inf -> NaN (Inf/Inf). Either turns the
|
||||
// pixel black after framebuffer clamp. A negative HDR input feeds a
|
||||
// negative numerator/denominator and can produce non-physical output
|
||||
// that also looks like a black flash. Clamp to a sensible range
|
||||
// before the curve so a single bad upstream pixel can't escape.
|
||||
vec3 hdr = x.rgb;
|
||||
hdr = mix(hdr, vec3(0.0), vec3(any(isnan(hdr)) || any(isinf(hdr))));
|
||||
hdr = max(hdr, vec3(0.0));
|
||||
return FBOUT(vec4(ACESFilm(hdr), x.a));
|
||||
//return FBOUT(vec4(reinhard(x.rgb), x.a));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user