Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ReShade.fxh"
- uniform float F_COL <
- ui_type = "drag";
- ui_min = 0.25;
- ui_max = 0.5;
- ui_step = 0.25;
- ui_label = "F Col";
- > = 0.25;
- uniform float FIR_SIZE <
- ui_type = "drag";
- ui_min = 1.0;
- ui_max = 50.0;
- ui_step = 1.0;
- ui_label = "FIR Size";
- > = 29.0;
- uniform float F_LUMA_LP <
- ui_type = "drag";
- ui_min = 0.0001;
- ui_max = 0.333333;
- ui_step = 0.02;
- ui_label = "F Luma LP";
- > = 0.16667;
- uniform float F_COL_BW <
- ui_type = "drag";
- ui_min = 10.0;
- ui_max = 200.0;
- ui_step = 1.0;
- ui_label = "F Col BW";
- > = 50.0;
- uniform float SATURATION <
- ui_type = "drag";
- ui_min = 0.0;
- ui_max = 100.0;
- ui_step = 1.0;
- ui_label = "Saturation";
- > = 30.0;
- uniform float BRIGHTNESS <
- ui_type = "drag";
- ui_min = 0.0;
- ui_max = 2.0;
- ui_label = "Brightness";
- ui_step = 0.01;
- > = 1.0;
- uniform float HUE <
- ui_type = "drag";
- ui_min = 0.0;
- ui_max = 1.0;
- ui_step = 0.01;
- ui_label = "Hue";
- > = 0.0;
- uniform int Viewmode <
- ui_type = "drag";
- ui_min = 0;
- ui_max = 5;
- ui_label = "View Mode";
- > = 0;
- sampler ColorHD { Texture = ReShade::BackBufferTex; Format = RGBA32F;};
- texture iChannel2_Tex
- {
- Width = BUFFER_WIDTH;
- Height = BUFFER_HEIGHT;
- Format = RGBA32F;
- };
- sampler iChannel2 { Texture = iChannel2_Tex; };
- texture iChannel0_Tex
- {
- Width = BUFFER_WIDTH;
- Height = BUFFER_HEIGHT;
- Format = RGBA32F;
- };
- sampler iChannel0 { Texture = iChannel0_Tex; };
- texture iChannel1_Tex
- {
- Width = BUFFER_WIDTH;
- Height = BUFFER_HEIGHT;
- Format = RGBA32F;
- };
- sampler iChannel1 { Texture = iChannel1_Tex; };
- //Pass 1 Releated Stuff
- static const float pi = 3.141592654;
- static const float tau = 6.283185308;
- float3x3 rgb2yiq = float3x3(0.299, 0.596, 0.211,
- 0.587,-0.274,-0.523,
- 0.114,-0.322, 0.312);
- float2 Oscillator(float Fo, float Fs, float n)
- {
- float phase = (tau*Fo*floor(n))/Fs;
- return float2(cos(phase),sin(phase));
- }
- float4 PS_Stock(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target
- {
- return tex2D(ColorHD, texcoord).rgba;
- }
- void PS_ArtifactColors0(in float4 pos : SV_POSITION, in float2 uv : TEXCOORD0, out float4 col : COLOR0)
- {
- float2 texcoord = uv * ReShade::ScreenSize; //this is because the original shader uses OpenGL's fragCoord, which is in texels rather than pixels
- float Fs = ReShade::ScreenSize.x;
- float Fcol = Fs * F_COL;
- float n = floor(texcoord.x);
- float3 cRGB = tex2D(iChannel0, texcoord / ReShade::ScreenSize.xy).rgb;
- float3 cYIQ = rgb2yiq * cRGB;
- float2 cOsc = Oscillator(Fcol, Fs, n);
- float sig = cYIQ.x + dot(cOsc, cYIQ.yz);
- col = float4(sig,0,0,0);
- }
- //Pass 2 Releated Stuff
- float4 sample2D(sampler2D sam,float2 resolution, float2 uv)
- {
- return tex2D(sam, uv / resolution);
- }
- float2 cmul(float2 a, float2 b)
- {
- return float2((a.x * b.x) - (a.y * b.y), (a.x * b.y) + (a.y * b.x));
- }
- float sinc(float x)
- {
- return (x == 0.0) ? 1.0 : sin(x*pi)/(x*pi);
- }
- //https://en.wikipedia.org/wiki/Window_function
- float WindowBlackman(float a, int N, int i)
- {
- float a0 = (1.0 - a) / 2.0;
- float a1 = 0.5;
- float a2 = a / 2.0;
- float wnd = a0;
- wnd -= a1 * cos(2.0 * pi * (float(i) / float(N - 1)));
- wnd += a2 * cos(4.0 * pi * (float(i) / float(N - 1)));
- return wnd;
- }
- //FIR lowpass filter
- //Fc = Cutoff freq., Fs = Sample freq., N = # of taps, i = Tap index
- float Lowpass(float Fc, float Fs, int N, int i)
- {
- float wc = (Fc/Fs);
- float wnd = WindowBlackman(0.16, N, i);
- return 2.0*wc * wnd * sinc(2.0*wc * float(i - N/2));
- }
- //FIR bandpass filter
- //Fa/Fb = Low/High cutoff freq., Fs = Sample freq., N = # of taps, i = Tap index
- float Bandpass(float Fa, float Fb, float Fs, int N, int i)
- {
- float wa = (Fa/Fs);
- float wb = (Fb/Fs);
- float wnd = WindowBlackman(0.16, N, i);
- return 2.0*(wb-wa) * wnd * (sinc(2.0*wb * float(i - N/2)) - sinc(2.0*wa * float(i - N/2)));
- }
- void PS_ArtifactColors1(in float4 pos : SV_POSITION, in float2 uv : TEXCOORD0, out float4 col : COLOR0)
- {
- float2 texcoord = uv * ReShade::ScreenSize; //this is because the original shader uses OpenGL's fragCoord, which is in texels rather than pixels
- float Fs = ReShade::ScreenSize.x;
- float Fcol = Fs * F_COL;
- float Fcolbw = Fs * F_COL_BW;
- float Flumlp = Fs * F_LUMA_LP;
- float n = floor(texcoord.x);
- float y_sig = 0.0;
- float iq_sig = 0.0;
- float2 cOsc = Oscillator(Fcol, Fs, n);
- n += float(FIR_SIZE)/2.0;
- //Separate luma(Y) & chroma(IQ) signals
- for(int i = 0;i < FIR_SIZE;i++)
- {
- int tpidx = FIR_SIZE - i - 1;
- float lp = Lowpass(Flumlp, Fs, FIR_SIZE, tpidx);
- float bp = Bandpass(Fcol - Fcolbw, Fcol + Fcolbw, Fs, FIR_SIZE, tpidx);
- y_sig += sample2D(iChannel1, ReShade::ScreenSize.xy, float2(n - float(i), texcoord.y)).r * lp;
- iq_sig += sample2D(iChannel1, ReShade::ScreenSize.xy, float2(n - float(i), texcoord.y)).r * bp;
- }
- //Shift IQ signal down from Fcol to DC
- float2 iq_sig_mix = cmul(float2(iq_sig, 0), cOsc);
- col = float4(y_sig, iq_sig_mix, 0);
- }
- //Pass 3 Releated Stuff
- float2x2 rotate(float a)
- {
- return float2x2( cos(a), sin(a),
- -sin(a), cos(a));
- }
- float3x3 yiq2rgb = float3x3(1.000, 1.000, 1.000,
- 0.956,-0.272,-1.106,
- 0.621,-0.647, 1.703);
- void PS_ArtifactColors2 (in float4 pos : SV_POSITION, in float2 txcoord : TEXCOORD0, out float4 col : COLOR0)
- {
- float2 texcoord = txcoord * ReShade::ScreenSize; //this is because the original shader uses OpenGL's fragCoord, which is in texels rather than pixels
- float Fs = ReShade::ScreenSize.x;
- float Fcol = Fs * F_COL;
- float Flumlp = Fs * F_LUMA_LP;
- float n = floor(texcoord.x);
- float2 uv = texcoord.xy;
- float luma = sample2D(iChannel0, ReShade::ScreenSize.xy, uv).r;
- float2 chroma = float2(0,0);
- //Filtering out unwanted high freqency content from the chroma(IQ) signal.
- for(int i = 0;i < FIR_SIZE;i++)
- {
- int tpidx = FIR_SIZE - i - 1;
- float lp = Lowpass(Flumlp, Fs, FIR_SIZE, tpidx);
- chroma += sample2D(iChannel0, ReShade::ScreenSize.xy, uv - float2(i - FIR_SIZE / 2, 0)).yz * lp;
- }
- chroma *= mul(chroma,rotate(tau * HUE));
- float3 color = yiq2rgb * float3(BRIGHTNESS * luma, chroma * SATURATION);
- if(Viewmode == 0){
- col = float4(color, 0); //Result
- } else if (Viewmode == 1){
- col = tex2D(iChannel1, uv / ReShade::ScreenSize.xy); //Stock
- } else if (Viewmode == 2){
- col = float4(luma,luma,luma,luma); //Luma
- } else if (Viewmode == 3){
- col = float4(40.0*chroma+0.5,0,0); //Chroma
- } else if (Viewmode == 4){
- col = 0.5 * tex2D(iChannel2, uv / ReShade::ScreenSize.xy).rrrr+0.25; //Signal
- } else {
- if(uv.x < ReShade::ScreenSize.x/2.0)
- {
- col = tex2D(iChannel1, uv / ReShade::ScreenSize.xy);
- } else {
- col = float4(color, 0);
- }
- }
- }
- technique ArtifactColors {
- pass ArtifactColorsStock{
- RenderTarget = iChannel1_Tex;
- VertexShader=PostProcessVS;
- PixelShader=PS_Stock;
- }
- pass ArtifactColors0 {
- RenderTarget = iChannel2_Tex;
- VertexShader=PostProcessVS;
- PixelShader=PS_ArtifactColors0;
- }
- pass ArtifactColors1 {
- RenderTarget = iChannel0_Tex;
- VertexShader=PostProcessVS;
- PixelShader=PS_ArtifactColors1;
- }
- pass ArtifactColors2 {
- //RenderTarget = iChannel1_Tex;
- VertexShader=PostProcessVS;
- PixelShader=PS_ArtifactColors2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement