From 2cf701fe79a38203b7b918d921fc7c45542dca3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Fri, 25 Oct 2024 07:57:34 +0200 Subject: [PATCH] motion blur fix when delta time is zero --- WickedEngine/shaders/motionblurCS.hlsl | 2 +- WickedEngine/wiRenderPath3D.cpp | 1 + WickedEngine/wiRenderer.cpp | 3 ++- WickedEngine/wiRenderer.h | 1 + WickedEngine/wiVersion.cpp | 2 +- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/WickedEngine/shaders/motionblurCS.hlsl b/WickedEngine/shaders/motionblurCS.hlsl index 9d27d25d8..89e5549a9 100644 --- a/WickedEngine/shaders/motionblurCS.hlsl +++ b/WickedEngine/shaders/motionblurCS.hlsl @@ -63,7 +63,7 @@ void main(uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID) #else - const float strength = motionblur_strength / GetFrame().delta_time; + const float strength = motionblur_strength; const float2 neighborhood_velocity = neighborhoodmax[(pixel + (dither((float2)pixel) - 0.5f) * 16) / MOTIONBLUR_TILESIZE] * strength; // dither to reduce tile artifact const float neighborhood_velocity_magnitude = length(neighborhood_velocity); diff --git a/WickedEngine/wiRenderPath3D.cpp b/WickedEngine/wiRenderPath3D.cpp index 557bee1e4..256cd88d2 100644 --- a/WickedEngine/wiRenderPath3D.cpp +++ b/WickedEngine/wiRenderPath3D.cpp @@ -2363,6 +2363,7 @@ namespace wi if (getMotionBlurEnabled() && getMotionBlurStrength() > 0 && motionblurResources.IsValid()) { wi::renderer::Postprocess_MotionBlur( + scene->dt, motionblurResources, rt_first == nullptr ? *rt_read : *rt_first, *rt_write, diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index e180e745a..1cbbde37a 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -15601,6 +15601,7 @@ void CreateMotionBlurResources(MotionBlurResources& res, XMUINT2 resolution) device->CreateBuffer(&bufferdesc, nullptr, &res.buffer_tiles_expensive); } void Postprocess_MotionBlur( + float dt, const MotionBlurResources& res, const Texture& input, const Texture& output, @@ -15661,7 +15662,7 @@ void Postprocess_MotionBlur( postprocess.resolution.y = desc.height; postprocess.resolution_rcp.x = 1.0f / postprocess.resolution.x; postprocess.resolution_rcp.y = 1.0f / postprocess.resolution.y; - motionblur_strength = strength / 60.0f; // align to shutter speed + motionblur_strength = dt > 0 ? (strength / 60.0f / dt) : 0; // align to shutter speed // Compute tile max velocities (horizontal): { diff --git a/WickedEngine/wiRenderer.h b/WickedEngine/wiRenderer.h index 67e5dde25..790b7cb56 100644 --- a/WickedEngine/wiRenderer.h +++ b/WickedEngine/wiRenderer.h @@ -741,6 +741,7 @@ namespace wi::renderer }; void CreateMotionBlurResources(MotionBlurResources& res, XMUINT2 resolution); void Postprocess_MotionBlur( + float dt, // delta time in seconds const MotionBlurResources& res, const wi::graphics::Texture& input, const wi::graphics::Texture& output, diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 6dc12d37b..32d864b57 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 71; // minor bug fixes, alterations, refactors, updates - const int revision = 603; + const int revision = 604; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);