rj200 / Glamarye_Fast_Effects_for_ReShade

Designed for speed, this shader for ReShade is for people who can't just run everything at max settings but want good enough post-processing without costing much framerate. It combines 4 effects in one - Fast FXAA, sharpening, depth of field and fast ambient occlusion
MIT License
111 stars 12 forks source link

bugfix GI divide by zero in Witcher 3 Next-Gen new game intro bathtub scene #10

Closed ewelsh42 closed 1 year ago

ewelsh42 commented 1 year ago

When you start a new game in the Witcher 3 - Next Gen update (I don't know if the bug is present in the original or not), as the camera pans downwards and we see the wooden tub underneath Geralt's legs, the center of the tub exhibits jumpy black voids of nothing rendered. It happens whenever there are closeups of the nearest sections of the tub. The bug is only present in the GI instance of the shader, not in the non-GI instance. I tracked it down to a potential divide by zero that wasn't guarded against:

Current: float contrast = dot(luma,(c-sharp_diff)/(bounce_area.rgb+gi.rgb));

Bug-fixed: float contrast = dot(luma,(c-sharp_diff)/(bounce_area.rgb+gi.rgb+0.00001));

I'm thinking that with the tub right up against the camera, there must be both zero bounce area and zero gi, so it was dividing by zero and causing the artifacts? Guarding with +0.00001 fixes it and the artifacts go away.

rj200 commented 1 year ago

Thank you. Fixed it.