Skip to content

Commit

Permalink
Change displacement scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
brimson committed Jul 12, 2022
1 parent 67a47f1 commit 99e5167
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions shaders/cMotionBlur.fx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions shaders/kDatamosh.fx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

/*
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 99e5167

Please sign in to comment.