From 99e51678b7397b5f37eb3c53e51bb850e4ebf2a2 Mon Sep 17 00:00:00 2001 From: brimson Date: Mon, 11 Jul 2022 18:46:42 -0700 Subject: [PATCH] Change displacement scaling --- shaders/cMotionBlur.fx | 12 ++++++++---- shaders/kDatamosh.fx | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/shaders/cMotionBlur.fx b/shaders/cMotionBlur.fx index 554b59b..e15fb85 100644 --- a/shaders/cMotionBlur.fx +++ b/shaders/cMotionBlur.fx @@ -53,7 +53,7 @@ namespace OpticalFlowLK OPTION(float, _MipBias, "slider", "Optical flow", "Optical flow mipmap bias", 0.0, 6.0, 0.0) OPTION(float, _BlendFactor, "slider", "Optical flow", "Temporal blending factor", 0.0, 0.9, 0.2) - OPTION(float, _Scale, "slider", "Main", "Blur scale", 0.0, 0.1, 0.05) + OPTION(float, _Scale, "slider", "Main", "Blur scale", 0.0, 1.0, 0.5) OPTION(bool, _FrameRateScaling, "radio", "Other", "Enable frame-rate scaling", 0.0, 1.0, false) OPTION(float, _TargetFrameRate, "drag", "Other", "Target frame-rate", 0.0, 144.0, 60.0) @@ -425,15 +425,19 @@ namespace OpticalFlowLK float2 Velocity = tex2Dlod(Sample_Common_3_A, float4(TexCoord, 0.0, _MipBias)).xy; - float2 ScaledVelocity = (Velocity / BUFFER_SIZE_3) * _Scale; + float2 ScaledVelocity = Velocity * _Scale; ScaledVelocity = (_FrameRateScaling) ? ScaledVelocity / FrameTimeRatio : ScaledVelocity; + float2 ScreenSize = float2(BUFFER_WIDTH, BUFFER_HEIGHT); + float2 ScreenCoord = TexCoord.xy * ScreenSize; + for(int k = 0; k < Samples; ++k) { float2 Offset = ScaledVelocity * (Noise + k); - OutputColor0 += tex2D(Sample_Color, (TexCoord + Offset)); - OutputColor0 += tex2D(Sample_Color, (TexCoord - Offset)); + OutputColor0 += tex2D(Sample_Color, (ScreenCoord + Offset) / ScreenSize); + OutputColor0 += tex2D(Sample_Color, (ScreenCoord - Offset) / ScreenSize); } + OutputColor0 /= (Samples * 2.0); } diff --git a/shaders/kDatamosh.fx b/shaders/kDatamosh.fx index dee9570..df2872c 100644 --- a/shaders/kDatamosh.fx +++ b/shaders/kDatamosh.fx @@ -79,10 +79,10 @@ namespace Datamosh OPTION(int, _BlockSize, "slider", "Datamosh", "Block Size", 4, 32, 16) OPTION(float, _Entropy, "slider", "Datamosh", "Entropy", 0.0, 1.0, 0.5) OPTION(float, _Contrast, "slider", "Datamosh", "Contrast of stripe-shaped noise", 0.0, 4.0, 2.0) - OPTION(float, _Scale, "slider", "Datamosh", "Scale factor for velocity vectors", 0.0, 1.0, 0.5) + OPTION(float, _Scale, "slider", "Datamosh", "Scale factor for velocity vectors", 0.0, 2.0, 1.0) OPTION(float, _Diffusion, "slider", "Datamosh", "Amount of random displacement", 0.0, 4.0, 2.0) - OPTION(float, _MipBias, "slider", "Optical flow", "Optical flow mipmap bias", 0.0, 6.0, 0.0) + OPTION(float, _MipBias, "slider", "Optical flow", "Optical flow mipmap bias", 0.0, 6.0, 2.0) OPTION(float, _BlendFactor, "slider", "Optical flow", "Temporal blending factor", 0.0, 0.9, 0.5) /* @@ -520,7 +520,7 @@ namespace Datamosh void Datamosh_PS(in float4 Position : SV_POSITION, in float2 TexCoord : TEXCOORD0, out float4 OutputColor0 : SV_TARGET0) { - const float2 DisplacementTexel = 1.0 / BUFFER_SIZE_2; + const float2 DisplacementTexel = 1.0 / float2(BUFFER_WIDTH, BUFFER_HEIGHT); const float Quality = 1.0 - _Entropy; // Random numbers