Skip to content

Commit

Permalink
Back to GS because there is no 5 point laplace
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Jan 3, 2022
1 parent 1efc2ff commit 4f18a11
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
7 changes: 2 additions & 5 deletions shaders/cInterpolation.fx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ void DerivativesPS(float4 Position : SV_POSITION, float4 TexCoord : TEXCOORD0, o

void OpticalFlowPS(float4 Position : SV_POSITION, float2 TexCoord : TEXCOORD0, out float4 OutputColor0 : SV_TARGET0)
{
float RedBlack = frac(dot(Position.xy, 0.5)) * 2.0;
const float MaxLevel = 6.5;
float4 OpticalFlow;
float2 Smoothness;
Expand All @@ -283,15 +282,13 @@ void OpticalFlowPS(float4 Position : SV_POSITION, float2 TexCoord : TEXCOORD0, o
Smoothness.g = dot(SampleIxy.zw, SampleIxy.zw) + Lambda;
Smoothness.rg = 1.0 / Smoothness.rg;

// Calculate red points
Value.r = dot(SampleIxy.xy, OpticalFlow.xy) + Iz.r;
Value.g = dot(SampleIxy.zw, OpticalFlow.zw) + Iz.g;
OpticalFlow = (RedBlack == 1.0) ? OpticalFlow - (SampleIxy.xyzw * (Value.rrgg * Smoothness.rrgg)) : OpticalFlow;
OpticalFlow.xz = OpticalFlow.xz - (SampleIxy.xz * (Value.rg * Smoothness.rg));

// Calculate black points
Value.r = dot(SampleIxy.xy, OpticalFlow.xy) + Iz.r;
Value.g = dot(SampleIxy.zw, OpticalFlow.zw) + Iz.g;
OpticalFlow = (RedBlack == 0.0) ? OpticalFlow - (SampleIxy.xyzw * (Value.rrgg * Smoothness.rrgg)) : OpticalFlow;
OpticalFlow.yw = OpticalFlow.yw - (SampleIxy.yw * (Value.rg * Smoothness.rg));
}

OutputColor0.xy = OpticalFlow.xy + OpticalFlow.zw;
Expand Down
8 changes: 3 additions & 5 deletions shaders/cMotionBlur.fx
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,14 @@ void OpticalFlowPS(float4 Position : SV_POSITION, float2 TexCoord : TEXCOORD0, o
Smoothness.r = dot(SampleIxy.xy, SampleIxy.xy) + Lambda;
Smoothness.g = dot(SampleIxy.zw, SampleIxy.zw) + Lambda;
Smoothness.rg = 1.0 / Smoothness.rg;

// Calculate red points

Value.r = dot(SampleIxy.xy, OpticalFlow.xy) + Iz.r;
Value.g = dot(SampleIxy.zw, OpticalFlow.zw) + Iz.g;
OpticalFlow = (RedBlack == 1.0) ? OpticalFlow - (SampleIxy.xyzw * (Value.rrgg * Smoothness.rrgg)) : OpticalFlow;
OpticalFlow.xz = OpticalFlow.xz - (SampleIxy.xz * (Value.rg * Smoothness.rg));

// Calculate black points
Value.r = dot(SampleIxy.xy, OpticalFlow.xy) + Iz.r;
Value.g = dot(SampleIxy.zw, OpticalFlow.zw) + Iz.g;
OpticalFlow = (RedBlack == 0.0) ? OpticalFlow - (SampleIxy.xyzw * (Value.rrgg * Smoothness.rrgg)) : OpticalFlow;
OpticalFlow.yw = OpticalFlow.yw - (SampleIxy.yw * (Value.rg * Smoothness.rg));
}

OutputColor0.xy = OpticalFlow.xy + OpticalFlow.zw;
Expand Down
7 changes: 2 additions & 5 deletions shaders/cOpticalFlow.fx
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ void DerivativesPS(float4 Position : SV_POSITION, float4 TexCoord : TEXCOORD0, o

void OpticalFlowPS(float4 Position : SV_POSITION, float2 TexCoord : TEXCOORD0, out float4 OutputColor0 : SV_TARGET0)
{
float RedBlack = frac(dot(Position.xy, 0.5)) * 2.0;
const float MaxLevel = 6.5;
float4 OpticalFlow;
float2 Smoothness;
Expand All @@ -310,15 +309,13 @@ void OpticalFlowPS(float4 Position : SV_POSITION, float2 TexCoord : TEXCOORD0, o
Smoothness.g = dot(SampleIxy.zw, SampleIxy.zw) + Lambda;
Smoothness.rg = 1.0 / Smoothness.rg;

// Calculate red points
Value.r = dot(SampleIxy.xy, OpticalFlow.xy) + Iz.r;
Value.g = dot(SampleIxy.zw, OpticalFlow.zw) + Iz.g;
OpticalFlow = RedBlack == 1.0 ? OpticalFlow - (SampleIxy.xyzw * (Value.rrgg * Smoothness.rrgg)) : OpticalFlow;
OpticalFlow.xz = OpticalFlow.xz - (SampleIxy.xz * (Value.rg * Smoothness.rg));

// Calculate black points
Value.r = dot(SampleIxy.xy, OpticalFlow.xy) + Iz.r;
Value.g = dot(SampleIxy.zw, OpticalFlow.zw) + Iz.g;
OpticalFlow = RedBlack == 0.0 ? OpticalFlow - (SampleIxy.xyzw * (Value.rrgg * Smoothness.rrgg)) : OpticalFlow;
OpticalFlow.yw = OpticalFlow.yw - (SampleIxy.yw * (Value.rg * Smoothness.rg));
}

OutputColor0.xy = OpticalFlow.xy + OpticalFlow.zw;
Expand Down
4 changes: 2 additions & 2 deletions shaders/kDatamosh.fx
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ void OpticalFlowPS(float4 Position : SV_POSITION, float2 TexCoord : TEXCOORD0, o

Smoothness = 1.0 / (dot(SampleIxy.xy, SampleIxy.xy) + Lambda);
Value = dot(SampleIxy.xy, OutputColor0.xy) + Iz;
OutputColor0.xy = (RedBlack == 1.0) ? OutputColor0.xy - (SampleIxy.xy * (Value * Smoothness)) : OutputColor0.xy;
OutputColor0.x = OutputColor0.x - (SampleIxy.x * (Value * Smoothness));
Value = dot(SampleIxy.xy, OutputColor0.xy) + Iz;
OutputColor0.xy = (RedBlack == 0.0) ? OutputColor0.xy - (SampleIxy.xy * (Value * Smoothness)) : OutputColor0.xy;
OutputColor0.y = OutputColor0.y - (SampleIxy.y * (Value * Smoothness));
}

OutputColor0.ba = float2(1.0, _BlendFactor);
Expand Down

0 comments on commit 4f18a11

Please sign in to comment.