From a82d4018e3c6422335cfefc13092da14d3377e81 Mon Sep 17 00:00:00 2001 From: Alexander Gauggel <agauggel@uni-koblenz.de> Date: Thu, 12 Aug 2021 18:11:51 +0200 Subject: [PATCH] [#106] Reduce motion blur artifacts when using mouse at high fraerate --- projects/indirect_dispatch/src/App.cpp | 9 ++++++++- projects/indirect_dispatch/src/AppConfig.hpp | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/projects/indirect_dispatch/src/App.cpp b/projects/indirect_dispatch/src/App.cpp index 5aa01616..16f27932 100644 --- a/projects/indirect_dispatch/src/App.cpp +++ b/projects/indirect_dispatch/src/App.cpp @@ -290,7 +290,14 @@ void App::run() { const float microsecondToSecond = 0.000001; const float fDeltatimeSeconds = microsecondToSecond * std::chrono::duration_cast<std::chrono::microseconds>(frameEndTime - frameStartTime).count(); - const float motionBlurMotionFactor = 1 / (fDeltatimeSeconds * cameraShutterSpeedInverse); + + // small mouse movements are restricted to pixel level and therefore quite unprecise + // therefore extrapolating movement at high framerates results in big jerky movements + // this results in wide sudden motion blur, which looks quite bad + // as a workaround the time scale is limited to a maximum value + const float motionBlurTimeScaleMax = 1.f / 60; + const float deltaTimeMotionBlur = std::max(fDeltatimeSeconds, motionBlurTimeScaleMax); + const float motionBlurMotionFactor = 1 / (deltaTimeMotionBlur * cameraShutterSpeedInverse); vkcv::PushConstants motionBlurPushConstants(sizeof(float) * 2); diff --git a/projects/indirect_dispatch/src/AppConfig.hpp b/projects/indirect_dispatch/src/AppConfig.hpp index e727efa6..c89c34ea 100644 --- a/projects/indirect_dispatch/src/AppConfig.hpp +++ b/projects/indirect_dispatch/src/AppConfig.hpp @@ -5,6 +5,6 @@ namespace AppConfig{ const int defaultWindowWidth = 1280; const int defaultWindowHeight = 720; const vk::Format depthBufferFormat = vk::Format::eD32Sfloat; - const vk::Format colorBufferFormat = vk::Format::eB10G11R11UfloatPack32; - const vk::Format motionBufferFormat = vk::Format::eR16G16Sfloat; + const vk::Format colorBufferFormat = vk::Format::eB10G11R11UfloatPack32; + const vk::Format motionBufferFormat = vk::Format::eR16G16Sfloat; } \ No newline at end of file -- GitLab