Skip to content

Commit

Permalink
More cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Apr 16, 2022
2 parents 3ecb7e6 + a163baa commit 90cafa7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 83 deletions.
26 changes: 13 additions & 13 deletions shaders/ReShade.fxh
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,28 @@ namespace ReShade
sampler DepthBuffer { Texture = DepthBufferTex; };

// Helper functions
float GetLinearizedDepth(float2 TexCoord)
float GetLinearizedDepth(float2 texcoord)
{
#if RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN
TexCoord.y = 1.0 - TexCoord.y;
texcoord.y = 1.0 - texcoord.y;
#endif

TexCoord.x /= RESHADE_DEPTH_INPUT_X_SCALE;
TexCoord.y /= RESHADE_DEPTH_INPUT_Y_SCALE;
texcoord.x /= RESHADE_DEPTH_INPUT_X_SCALE;
texcoord.y /= RESHADE_DEPTH_INPUT_Y_SCALE;

#if RESHADE_DEPTH_INPUT_X_PIXEL_OFFSET
TexCoord.x -= RESHADE_DEPTH_INPUT_X_PIXEL_OFFSET * BUFFER_RCP_WIDTH;
texcoord.x -= RESHADE_DEPTH_INPUT_X_PIXEL_OFFSET * BUFFER_RCP_WIDTH;
#else // Do not check RESHADE_DEPTH_INPUT_X_OFFSET, since it may be a decimal number, which the preprocessor cannot handle
TexCoord.x -= RESHADE_DEPTH_INPUT_X_OFFSET / 2.000000001;
texcoord.x -= RESHADE_DEPTH_INPUT_X_OFFSET / 2.000000001;
#endif

#if RESHADE_DEPTH_INPUT_Y_PIXEL_OFFSET
TexCoord.y += RESHADE_DEPTH_INPUT_Y_PIXEL_OFFSET * BUFFER_RCP_HEIGHT;
texcoord.y += RESHADE_DEPTH_INPUT_Y_PIXEL_OFFSET * BUFFER_RCP_HEIGHT;
#else
TexCoord.y += RESHADE_DEPTH_INPUT_Y_OFFSET / 2.000000001;
texcoord.y += RESHADE_DEPTH_INPUT_Y_OFFSET / 2.000000001;
#endif

float depth = tex2Dlod(DepthBuffer, float4(TexCoord, 0, 0)).x * RESHADE_DEPTH_MULTIPLIER;
float depth = tex2Dlod(DepthBuffer, float4(texcoord, 0, 0)).x * RESHADE_DEPTH_MULTIPLIER;

#if RESHADE_DEPTH_INPUT_IS_LOGARITHMIC
const float C = 0.01;
Expand All @@ -118,9 +118,9 @@ namespace ReShade
}

// Vertex shader generating a triangle covering the entire screen
void PostProcessVS(in uint id : SV_VERTEXID, out float4 position : SV_POSITION, out float2 TexCoord : TEXCOORD0)
void PostProcessVS(in uint id : SV_VERTEXID, out float4 position : SV_POSITION, out float2 texcoord : TEXCOORD0)
{
TexCoord.x = (id == 2) ? 2.0 : 0.0;
TexCoord.y = (id == 1) ? 2.0 : 0.0;
position = float4(TexCoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
texcoord.x = (id == 2) ? 2.0 : 0.0;
texcoord.y = (id == 1) ? 2.0 : 0.0;
position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}
83 changes: 13 additions & 70 deletions shaders/kDatamosh.fx
Original file line number Diff line number Diff line change
Expand Up @@ -109,72 +109,15 @@ namespace Datamosh

uniform float _Time < source = "timer"; >;

uniform int _Block_Size <
ui_category = "Datamosh";
ui_type = "slider";
ui_label = "Block Size";
ui_min = 4;
ui_max = 32;
> = 16;

uniform float _Entropy <
ui_category = "Datamosh";
ui_type = "slider";
ui_label = "Entropy";
ui_tooltip = "The larger value stronger noise and makes mosh last longer.";
ui_min = 0.0;
ui_max = 1.0;
> = 0.5;

uniform float _Contrast <
ui_category = "Datamosh";
ui_type = "slider";
ui_label = "Contrast";
ui_tooltip = "Contrast of stripe-shaped noise.";
ui_min = 0.0;
ui_max = 4.0;
> = 2.0;

uniform float _Scale <
ui_category = "Datamosh";
ui_type = "slider";
ui_label = "Scale";
ui_tooltip = "Scale factor for velocity vectors.";
ui_min = 0.0;
ui_max = 4.0;
> = 2.0;

uniform float _Diffusion <
ui_category = "Datamosh";
ui_type = "slider";
ui_label = "Diffusion";
ui_tooltip = "Amount of random displacement.";
ui_min = 0.0;
ui_max = 4.0;
> = 2.0;

uniform float _Constraint <
ui_type = "slider";
ui_category = "Optical flow";
ui_label = "Motion Threshold";
ui_min = 0.0;
ui_max = 2.0;
> = 1.0;

uniform float _MipBias <
ui_type = "drag";
ui_category = "Optical flow";
ui_label = "Optical flow mipmap bias";
ui_min = 0.0;
> = 0.0;

uniform float _BlendFactor <
ui_type = "slider";
ui_category = "Optical flow";
ui_label = "Temporal Blending Factor";
ui_min = 0.0;
ui_Max = 0.9;
> = 0.1;
OPTION(int, _Block_Size, "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, 4.0, 2.0)
OPTION(float, _Diffusion, "slider", "Datamosh", "Amount of random displacement", 0.0, 4.0, 2.0)

OPTION(float, _Constraint, "slider", "Optical flow", "Motion threshold", 0.0, 2.0, 1.0)
OPTION(float, _MipBias, "slider", "Optical flow", "Optical flow mipmap bias", 0.0, 7.0, 0.0)
OPTION(float, _BlendFactor, "slider", "Optical flow", "Temporal blending factor", 0.0, 0.9, 0.1)

#ifndef LINEAR_SAMPLING
#define LINEAR_SAMPLING 0
Expand Down Expand Up @@ -754,9 +697,9 @@ namespace Datamosh
PASS(Derivatives_VS, Derivatives_PS, Shared_Resources_Datamosh::Render_Common_1_B)

// Trilinear Optical Flow, calculate 2 levels at a time
PASS(Basic_VS, Level_4_PS, Shared_Resources_Flow::Render_Common_4)
PASS(Sample_3x3_4_VS, Level_3_PS, Shared_Resources_Flow::Render_Common_3)
PASS(Sample_3x3_3_VS, Level_2_PS, Shared_Resources_Flow::Render_Common_2)
PASS(Basic_VS, Level_4_PS, Shared_Resources_Datamosh::Render_Common_4)
PASS(Sample_3x3_4_VS, Level_3_PS, Shared_Resources_Datamosh::Render_Common_3)
PASS(Sample_3x3_3_VS, Level_2_PS, Shared_Resources_Datamosh::Render_Common_2)

pass
{
Expand Down Expand Up @@ -812,4 +755,4 @@ namespace Datamosh
#endif
}
}
}
}

0 comments on commit 90cafa7

Please sign in to comment.