From 7ff1c194e0647aa09f4bc16a5f41bc008170124d Mon Sep 17 00:00:00 2001 From: Mr-Wiseguy Date: Wed, 27 Mar 2024 22:18:31 -0400 Subject: [PATCH] Clamp alpha for blur effect to mitigate image retention --- patches/effect_patches.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/patches/effect_patches.c b/patches/effect_patches.c index 5754d58..7538708 100644 --- a/patches/effect_patches.c +++ b/patches/effect_patches.c @@ -92,7 +92,14 @@ void Play_DrawMotionBlur(PlayState* this) { // @recomp Scale alpha based on the target framerate so that the blur effect decays at an equivalent rate // to how it does in the original game's framerate. - alpha = (s32)(recomp_powf(alpha / 255.0f, 20.0f / recomp_get_target_framerate(gFramerateDivisor)) * 255.0f); + s32 original_alpha = alpha; + f32 exponent = 20.0f / recomp_get_target_framerate(gFramerateDivisor); + f32 alpha_float = recomp_powf(alpha / 255.0f, exponent); + // Clamp to an alpha of 0.9, which ensures that the output color converges to within a reasonable delta + // of the target color when using an R8G8B8A8 framebuffer as RT64 currently does. + // Not clamping leads to image retention at high framerates. + alpha_float = MIN(alpha_float, 0.9f); + alpha = (s32)(alpha_float * 255.0f); if (sMotionBlurStatus == MOTION_BLUR_PROCESS) { func_80170AE0(&this->pauseBgPreRender, &gfx, alpha);