mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-22 15:51:30 +11:00
commit
2b63603462
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
Phosphor Afterglow Shader pass 0
|
||||
|
||||
Copyright (C) 2020 guest(r) - guest.r@gmail.com
|
||||
Copyright (C) 2020 - 2022 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -23,6 +23,10 @@
|
|||
|
||||
layout(push_constant) uniform Push
|
||||
{
|
||||
vec4 SourceSize;
|
||||
vec4 OriginalSize;
|
||||
vec4 OutputSize;
|
||||
uint FrameCount;
|
||||
float PR, PG, PB;
|
||||
} params;
|
||||
|
||||
|
@ -64,11 +68,21 @@ layout(set = 0, binding = 3) uniform sampler2D AfterglowPassFeedback;
|
|||
|
||||
void main()
|
||||
{
|
||||
vec3 color = COMPAT_TEXTURE(OriginalHistory0, TEX0.xy).rgb;
|
||||
vec2 dx = vec2(params.OriginalSize.z, 0.0);
|
||||
vec2 dy = vec2(0.0, params.OriginalSize.w);
|
||||
|
||||
vec3 color0 = COMPAT_TEXTURE(OriginalHistory0, TEX0.xy).rgb;
|
||||
vec3 color1 = COMPAT_TEXTURE(OriginalHistory0, TEX0.xy - dx).rgb;
|
||||
vec3 color2 = COMPAT_TEXTURE(OriginalHistory0, TEX0.xy + dx).rgb;
|
||||
vec3 color3 = COMPAT_TEXTURE(OriginalHistory0, TEX0.xy - dy).rgb;
|
||||
vec3 color4 = COMPAT_TEXTURE(OriginalHistory0, TEX0.xy + dy).rgb;
|
||||
|
||||
vec3 color = (2.5 * color0 + color1 + color2 + color3 + color4)/6.5;
|
||||
|
||||
vec3 accumulate = COMPAT_TEXTURE(AfterglowPassFeedback, TEX0.xy).rgb;
|
||||
|
||||
float w = 1.0;
|
||||
if ((color.r + color.g + color.b < 5.0/255.0)) { w = 0.0; }
|
||||
if ((color0.r + color0.g + color0.b < 5.0/255.0)) { w = 0.0; }
|
||||
|
||||
vec3 result = mix( max(mix(color, accumulate, 0.49 + vec3(PR, PG, PB))- 2.0/255.0, 0.0), color, w);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
Average Luminance Shader, Smart Edge Interpolation Coefficients Calculation
|
||||
|
||||
Copyright (C) 2018-2020 guest(r) - guest.r@gmail.com
|
||||
Copyright (C) 2018-2022 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -51,7 +51,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
Average Luminance Shader, Smart Edge Interpolation Coefficients Calculation
|
||||
|
||||
Copyright (C) 2018-2020 guest(r) - guest.r@gmail.com
|
||||
Copyright (C) 2018-2022 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -51,7 +51,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
Gaussian blur - horizontal pass, dynamic range, resizable
|
||||
|
||||
Copyright (C) 2020 guest(r) - guest.r@gmail.com
|
||||
Copyright (C) 2020 - 2022 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -29,6 +29,7 @@ layout(push_constant) uniform Push
|
|||
uint FrameCount;
|
||||
float SIZEHB;
|
||||
float SIGMA_HB;
|
||||
float BLOOMCUT_H;
|
||||
} params;
|
||||
|
||||
#pragma parameter bogus_bloom "[ BLOOM/HALATION/(GLOW) PASS SETTINGS ]:" 0.0 0.0 1.0 1.0
|
||||
|
@ -39,6 +40,9 @@ layout(push_constant) uniform Push
|
|||
#pragma parameter SIGMA_HB " Horizontal Bloom/Halation/(Glow) Sigma" 0.75 0.25 15.0 0.05
|
||||
#define SIGMA_HB params.SIGMA_HB
|
||||
|
||||
#pragma parameter BLOOMCUT_H " Horizontal Bloom/Halation/(Glow) Substract" 0.0 0.0 0.5 0.01
|
||||
#define BLOOMCUT_H params.BLOOMCUT_H
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
|
@ -86,7 +90,7 @@ void main()
|
|||
do
|
||||
{
|
||||
pixel = COMPAT_TEXTURE(LinearizePass, tex + n*dx);
|
||||
w = gaussian(n+f);
|
||||
w = max(gaussian(n+f) - BLOOMCUT_H, 0.0);
|
||||
pixel.a = max(max(pixel.r, pixel.g),pixel.b);
|
||||
pixel.a*=pixel.a*pixel.a;
|
||||
color = color + w * pixel;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
Gaussian blur - vertical pass, dynamic range, resizable
|
||||
|
||||
Copyright (C) 2020 guest(r) - guest.r@gmail.com
|
||||
Copyright (C) 2020 - 2022 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -29,6 +29,7 @@ layout(push_constant) uniform Push
|
|||
uint FrameCount;
|
||||
float SIZEVB;
|
||||
float SIGMA_VB;
|
||||
float BLOOMCUT_V;
|
||||
} params;
|
||||
|
||||
|
||||
|
@ -38,6 +39,9 @@ layout(push_constant) uniform Push
|
|||
#pragma parameter SIGMA_VB " Vertical Bloom/Halation/(Glow) Sigma" 0.60 0.25 15.0 0.05
|
||||
#define SIGMA_VB params.SIGMA_VB
|
||||
|
||||
#pragma parameter BLOOMCUT_V " Vertical Bloom/Halation/(Glow) Substract" 0.0 0.0 0.5 0.01
|
||||
#define BLOOMCUT_V params.BLOOMCUT_V
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
|
@ -87,7 +91,7 @@ void main()
|
|||
do
|
||||
{
|
||||
pixel = COMPAT_TEXTURE(Source, tex + n*dy);
|
||||
w = gaussian(n+f);
|
||||
w = max(gaussian(n+f) - BLOOMCUT_V, 0.0);
|
||||
pixel.a*=pixel.a*pixel.a;
|
||||
color = color + w * pixel;
|
||||
wsum = wsum + w;
|
||||
|
|
|
@ -35,8 +35,6 @@ layout(push_constant) uniform Push
|
|||
float S_SHARP;
|
||||
float HARNG;
|
||||
float HSHARP;
|
||||
float prescalex;
|
||||
float prescaley;
|
||||
float spike;
|
||||
float internal_res;
|
||||
} params;
|
||||
|
@ -49,7 +47,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
|
||||
#pragma parameter bogus_filtering "[ FILTERING OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter HSHARPNESS " Horizontal Filter Range" 1.5 1.0 8.0 0.125
|
||||
#pragma parameter HSHARPNESS " Horizontal Filter Range" 1.5 1.0 8.0 0.05
|
||||
#define HSHARPNESS params.HSHARPNESS
|
||||
|
||||
#pragma parameter SIGMA_HOR " Horizontal Blur Sigma" 0.90 0.1 7.0 0.05
|
||||
|
@ -67,9 +65,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter spike " Scanline Spike Removal" 1.0 0.0 2.0 0.10
|
||||
#define spike params.spike
|
||||
|
||||
#pragma parameter prescalex " Prescale-X Factor (for xBR...pre-shader)" 1.0 1.0 4.0 1.0 // Joint parameter with main pass, values must match
|
||||
#define prescalex params.prescalex // prescale-x factor
|
||||
|
||||
#define COMPAT_TEXTURE(c,d) texture(c,d)
|
||||
#define TEX0 vTexCoord
|
||||
|
||||
|
@ -84,7 +79,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -101,8 +96,10 @@ float gaussian(float x)
|
|||
|
||||
void main()
|
||||
{
|
||||
vec4 SourceSize = params.OriginalSize * vec4(2.0*prescalex, 1.0, 0.5/prescalex, 1.0);
|
||||
|
||||
vec2 prescalex = vec2(textureSize(LinearizePass, 0)) / params.OriginalSize.xy;
|
||||
|
||||
vec4 SourceSize = params.OriginalSize * vec4(2.0*prescalex.x, prescalex.y, 0.5/prescalex.x, 1.0/prescalex.y);
|
||||
|
||||
float f = fract(SourceSize.x * vTexCoord.x);
|
||||
f = 0.5 - f;
|
||||
vec2 tex = floor(SourceSize.xy * vTexCoord)*SourceSize.zw + 0.5*SourceSize.zw;
|
||||
|
@ -141,7 +138,7 @@ void main()
|
|||
w = gaussian(n+f) - sharp;
|
||||
fpx = abs(n+f-sign(n)*FPR)/FPR;
|
||||
if (abs(n) <= CLAMPSIZE) { cmax = max(cmax, pixel); cmin = min(cmin, pixel); }
|
||||
if (w < 0.0) w = clamp(w, mix(-maxsharp, 0.0, pow(fpx, HSHARP)), 0.0);
|
||||
if (w < 0.0) w = clamp(w, mix(-maxsharp, 0.0, pow(clamp(fpx,0.0,1.0), HSHARP)), 0.0);
|
||||
|
||||
color = color + w * pixel;
|
||||
wsum = wsum + w;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
layout(push_constant) uniform Push
|
||||
{
|
||||
float IOS, OS, BLOOM, brightboost, brightboost1, gsl, scanline1, scanline2, beam_min, beam_max, beam_size,
|
||||
h_sharp, s_sharp, warpX, warpY, glow, shadowMask, masksize, vertmask, ring;
|
||||
h_sharp, s_sharp, warpX, warpY, glow, shadowMask, masksize, vertmask, ring, no_scanlines;
|
||||
} params;
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
|
@ -70,10 +70,10 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter bloom_dist " Bloom Distribution" 0.0 0.0 3.0 0.05
|
||||
#define bloom_dist global.bloom_dist // bloom effect distribution
|
||||
|
||||
#pragma parameter halation " Halation Strength" 0.0 0.0 2.0 0.025
|
||||
#pragma parameter halation " Halation Strength" 0.0 -2.0 2.0 0.025
|
||||
#define halation global.halation // halation effect
|
||||
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.02
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.025
|
||||
#define gamma_c global.gamma_c // adjust brightness
|
||||
|
||||
#pragma parameter brightboost " Bright Boost Dark Pixels" 1.40 0.25 10.0 0.05
|
||||
|
@ -93,7 +93,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter scanline2 " Scanline Beam Shape Edges" 8.0 0.0 70.0 1.0
|
||||
#define scanline2 params.scanline2 // scanline param, vertical sharpness
|
||||
|
||||
#pragma parameter beam_min " Scanline Shape Dark Pixels" 1.30 0.25 5.0 0.05
|
||||
#pragma parameter beam_min " Scanline Shape Dark Pixels" 1.30 0.25 10.0 0.05
|
||||
#define beam_min params.beam_min // dark area beam min - narrow
|
||||
|
||||
#pragma parameter beam_max " Scanline Shape Bright Pixels" 1.00 0.4 3.5 0.025
|
||||
|
@ -105,10 +105,10 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter vertmask " Scanline Color Deconvergence" 0.0 -1.0 1.0 0.1
|
||||
#define vertmask params.vertmask // Scanline deconvergence colors
|
||||
|
||||
#pragma parameter scans " Scanline Saturation / Mask Falloff" 0.60 0.0 2.5 0.05
|
||||
#pragma parameter scans " Scanline Saturation / Mask Falloff" 0.50 -5.0 5.0 0.10
|
||||
#define scans global.scans // scanline saturation
|
||||
|
||||
#pragma parameter scan_falloff " Scanline Falloff" 1.0 0.25 2.0 0.05
|
||||
#pragma parameter scan_falloff " Scanline Falloff" 1.0 0.20 2.0 0.05
|
||||
#define scan_falloff global.scan_falloff // scanline falloff
|
||||
|
||||
#pragma parameter scangamma " Scanline Gamma" 2.40 0.5 5.0 0.05
|
||||
|
@ -117,9 +117,12 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter rolling_scan " Rolling Scanlines" 0.0 -1.0 1.0 0.01
|
||||
#define rolling_scan global.rolling_scan // rolling scanlines
|
||||
|
||||
#pragma parameter no_scanlines " No-scanline mode" 0.0 0.0 1.0 1.0
|
||||
#define no_scanlines params.no_scanlines
|
||||
|
||||
#pragma parameter bogus_screen "[ SCREEN OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter intres " Internal Resolution Y: 224p/240p, 1.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with linearize pass, values must match
|
||||
#pragma parameter intres " Internal Resolution Y: 0.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with linearize pass, values must match
|
||||
|
||||
#pragma parameter IOS " Integer Scaling: Odd:Y, Even:'X'+Y" 0.0 0.0 4.0 1.0
|
||||
#define IOS params.IOS // Smart Integer Scaling
|
||||
|
@ -145,9 +148,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter overscanY " Overscan Y original pixels" 0.0 -200.0 200.0 1.0
|
||||
#define overscanY global.overscanY // OverscanY pixels
|
||||
|
||||
#pragma parameter prescalex " Prescale-X Factor (for xBR...pre-shader)" 1.0 1.0 4.0 1.0
|
||||
#define prescalex global.prescalex // prescale-x factor
|
||||
|
||||
|
||||
#define COMPAT_TEXTURE(c,d) texture(c,d)
|
||||
#define TEX0 vTexCoord
|
||||
|
@ -163,7 +163,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -233,6 +233,8 @@ vec3 gc(vec3 c)
|
|||
|
||||
void main()
|
||||
{
|
||||
float prescalex = float(textureSize(LinearizePass, 0).x) / (2.0*global.OriginalSize.x);
|
||||
|
||||
vec4 SourceSize = global.OriginalSize * vec4(prescalex, 1.0, 1.0/prescalex, 1.0);
|
||||
|
||||
SourceSize*= vec4(2.0, 1.0, 0.5, 1.0);
|
||||
|
@ -242,19 +244,18 @@ void main()
|
|||
float gamma_in = 1.0/COMPAT_TEXTURE(LinearizePass, vec2(0.25,0.25)).a;
|
||||
float intera = COMPAT_TEXTURE(LinearizePass, vec2(0.75,0.25)).a;
|
||||
bool interb = (intera < 0.5);
|
||||
|
||||
float SourceY = SourceSize.y;
|
||||
|
||||
float SourceY = SourceSize.y;
|
||||
float sy = 1.0;
|
||||
if (global.intres == 0.5) sy = SourceY/224.0; else
|
||||
if (global.intres == 1.0) sy = SourceY/240.0; else
|
||||
if (global.intres > 1.25) sy = global.intres;
|
||||
if (global.intres == 1.0) sy = SourceY/224.0;
|
||||
if (global.intres > 0.25 && global.intres != 1.0) sy = global.intres;
|
||||
SourceSize*=vec4(1.0, 1.0/sy, 1.0, sy);
|
||||
|
||||
// Calculating texel coordinates
|
||||
|
||||
vec2 texcoord = TEX0.xy;
|
||||
if (IOS > 0.0 && !interb){
|
||||
vec2 ofactor = OutputSize.xy/SourceSize.xy;
|
||||
vec2 ofactor = OutputSize.xy/global.OriginalSize.xy;
|
||||
vec2 intfactor = (IOS < 2.5) ? floor(ofactor) : ceil(ofactor);
|
||||
vec2 diff = ofactor/intfactor;
|
||||
float scan = diff.y;
|
||||
|
@ -265,7 +266,7 @@ void main()
|
|||
float factor = 1.00 + (1.0-0.5*OS)*BLOOM/100.0 - lum*BLOOM/100.0;
|
||||
texcoord = Overscan(texcoord, factor, factor);
|
||||
|
||||
texcoord = Overscan(texcoord, (SourceSize.x - overscanX)/SourceSize.x, (SourceSize.y - overscanY)/SourceSize.y);
|
||||
texcoord = Overscan(texcoord, (global.OriginalSize.x - overscanX)/global.OriginalSize.x, (global.OriginalSize.y - overscanY)/global.OriginalSize.y);
|
||||
|
||||
vec2 pos = Warp(texcoord);
|
||||
vec2 pos0 = Warp(TEX0.xy);
|
||||
|
@ -287,12 +288,16 @@ void main()
|
|||
pC4.x = pos.x;
|
||||
if (interb) pC4.y = pos.y;
|
||||
|
||||
if (global.intres == 0.5 && prescalex < 1.5) pC4.y = floor(pC4.y * global.OriginalSize.y)*global.OriginalSize.w + 0.5*global.OriginalSize.w;
|
||||
|
||||
vec3 color1 = COMPAT_TEXTURE(Pass1, pC4 ).rgb;
|
||||
vec3 scolor1 = COMPAT_TEXTURE(Pass1, pC4 ).aaa;
|
||||
|
||||
if(!interb) color1 = pow(color1, vec3(scangamma/gamma_in));
|
||||
|
||||
pC4+=dy;
|
||||
|
||||
if (global.intres == 0.5 && prescalex < 1.5) pC4.y = floor((pos.y + 0.33*dy.y) * global.OriginalSize.y)*global.OriginalSize.w + 0.5*global.OriginalSize.w;
|
||||
|
||||
vec3 color2 = COMPAT_TEXTURE(Pass1, pC4 ).rgb;
|
||||
vec3 scolor2 = COMPAT_TEXTURE(Pass1, pC4 ).aaa;
|
||||
|
@ -345,16 +350,21 @@ if (!interb)
|
|||
float mc1 = max(max(color1.r,color1.g),color1.b) + eps;
|
||||
float mc2 = max(max(color2.r,color2.g),color2.b) + eps;
|
||||
|
||||
cref1 = color1 / mc1; cref1=cref1*cref1; cref1*=cref1;
|
||||
cref2 = color2 / mc2; cref2=cref2*cref2; cref2*=cref2;
|
||||
cref1 = color1 / mc1;
|
||||
cref2 = color2 / mc2;
|
||||
|
||||
w1 = max( mix(w1*mix(one, cref1, scans), w1, wf1*min((1.0+0.15*scans), 1.2)), 0.0); w1 = min(w1*color1, mc1)/(color1 + eps);
|
||||
w2 = max( mix(w2*mix(one, cref2, scans), w2, wf2*min((1.0+0.15*scans), 1.2)), 0.0); w2 = min(w2*color2, mc2)/(color2 + eps);
|
||||
float scanpow1 = (scans > 0.0) ? 1.0 : pow(f1, 0.375);
|
||||
float scanpow2 = (scans > 0.0) ? 1.0 : pow(f2, 0.375);
|
||||
w1 = pow(w1, mix(2.0*abs(scans).xxx + 1.0, 1.0.xxx, mix(1.0.xxx, cref1, scanpow1)));
|
||||
w2 = pow(w2, mix(2.0*abs(scans).xxx + 1.0, 1.0.xxx, mix(1.0.xxx, cref2, scanpow2)));
|
||||
|
||||
// Scanline Deconvergence
|
||||
|
||||
vec3 cd1 = one; vec3 cd2 = one; float vm = sqrt(abs(vertmask));
|
||||
vec3 cd1 = one; vec3 cd2 = one;
|
||||
|
||||
if (abs(vertmask) > 0.025)
|
||||
{
|
||||
float vm = sqrt(abs(vertmask));
|
||||
float v_high1 = 1.0 + 0.3*vm;
|
||||
float v_high2 = 1.0 + 0.6*vm;
|
||||
float v_low = 1.0 - vm;
|
||||
|
@ -372,8 +382,9 @@ if (!interb)
|
|||
cd1 = mix(one, vec3(v_high1, v_low, v_high1), ds1);
|
||||
cd2 = mix(one, vec3(v_low, v_high2, v_low), ds2);
|
||||
}
|
||||
}
|
||||
|
||||
color = gc(color1)*w1*cd1 + gc(color2)*w2*cd2;
|
||||
color = (gc(color1)*w1*cd1 + gc(color2)*w2*cd2)/mix(1.0.xxx, w1+w2, no_scanlines);
|
||||
|
||||
if (abs(rolling_scan) > 0.005)
|
||||
{
|
||||
|
@ -391,7 +402,7 @@ if (!interb)
|
|||
color = gc(color1);
|
||||
}
|
||||
|
||||
float colmx = pow(max(max(ctmp.r,ctmp.g),ctmp.b), 1.40/gamma_in);
|
||||
float colmx = max(max(ctmp.r,ctmp.g),ctmp.b);
|
||||
|
||||
if(!interb) color = pow( color, vec3(gamma_in/scangamma) );
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
layout(push_constant) uniform Push
|
||||
{
|
||||
float TATE, IOS, OS, BLOOM, brightboost, brightboost1, gsl, scanline1, scanline2, beam_min, beam_max, beam_size,
|
||||
h_sharp, s_sharp, csize, bsize1, warpX, warpY, glow, vertmask, spike, ring;
|
||||
h_sharp, s_sharp, csize, bsize1, warpX, warpY, glow, vertmask, spike, ring, no_scanlines;
|
||||
} params;
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
|
@ -70,10 +70,10 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter bloom_dist " Bloom Distribution" 0.0 0.0 3.0 0.05
|
||||
#define bloom_dist global.bloom_dist // bloom effect distribution
|
||||
|
||||
#pragma parameter halation " Halation Strength" 0.0 0.0 2.0 0.025
|
||||
#pragma parameter halation " Halation Strength" 0.0 -2.0 2.0 0.025
|
||||
#define halation global.halation // halation effect
|
||||
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.02
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.025
|
||||
#define gamma_c global.gamma_c // adjust brightness
|
||||
|
||||
#pragma parameter brightboost " Bright Boost Dark Pixels" 1.40 0.25 10.0 0.05
|
||||
|
@ -93,7 +93,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter scanline2 " Scanline Beam Shape Edges" 8.0 0.0 70.0 1.0
|
||||
#define scanline2 params.scanline2 // scanline param, vertical sharpness
|
||||
|
||||
#pragma parameter beam_min " Scanline Shape Dark Pixels" 1.30 0.25 5.0 0.05
|
||||
#pragma parameter beam_min " Scanline Shape Dark Pixels" 1.30 0.25 10.0 0.05
|
||||
#define beam_min params.beam_min // dark area beam min - narrow
|
||||
|
||||
#pragma parameter beam_max " Scanline Shape Bright Pixels" 1.00 0.4 3.5 0.025
|
||||
|
@ -105,10 +105,10 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter vertmask " Scanline Color Deconvergence" 0.0 -1.0 1.0 0.1
|
||||
#define vertmask params.vertmask // Scanline deconvergence colors
|
||||
|
||||
#pragma parameter scans " Scanline Saturation / Mask Falloff" 0.60 0.0 2.5 0.05
|
||||
#pragma parameter scans " Scanline Saturation / Mask Falloff" 0.5 -5.0 5.0 0.10
|
||||
#define scans global.scans // scanline saturation
|
||||
|
||||
#pragma parameter scan_falloff " Scanline Falloff" 1.0 0.25 2.0 0.05
|
||||
#pragma parameter scan_falloff " Scanline Falloff" 1.0 0.20 2.0 0.05
|
||||
#define scan_falloff global.scan_falloff // scanline falloff
|
||||
|
||||
#pragma parameter spike " Scanline Spike Removal" 1.0 0.0 2.0 0.10
|
||||
|
@ -120,12 +120,15 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter scangamma " Scanline Gamma" 2.40 0.5 5.0 0.05
|
||||
#define scangamma global.scangamma
|
||||
|
||||
#pragma parameter no_scanlines " No-scanline mode" 0.0 0.0 1.0 1.0
|
||||
#define no_scanlines params.no_scanlines
|
||||
|
||||
#pragma parameter bogus_filtering "[ FILTERING OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter h_sharp " Horizontal sharpness" 5.20 0.20 15.0 0.10
|
||||
#define h_sharp params.h_sharp // pixel sharpness
|
||||
|
||||
#pragma parameter s_sharp " Substractive sharpness (1.0 recommended)" 0.50 0.0 1.5 0.10
|
||||
#pragma parameter s_sharp " Substractive sharpness (1.0 recommended)" 0.50 0.0 2.0 0.10
|
||||
#define s_sharp params.s_sharp // substractive sharpness
|
||||
|
||||
#pragma parameter ring " Substractive sharpness Ringing" 0.0 0.0 3.0 0.05
|
||||
|
@ -142,7 +145,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
|
||||
#pragma parameter bogus_screen "[ SCREEN OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter intres " Internal Resolution Y: 224p/240p, 1.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with linearize pass, values must match
|
||||
#pragma parameter intres " Internal Resolution Y: 0.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with linearize pass, values must match
|
||||
|
||||
#pragma parameter TATE " TATE Mode" 0.0 0.0 1.0 1.0
|
||||
#define TATE params.TATE // Screen orientation
|
||||
|
@ -171,9 +174,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter overscanY " Overscan Y original pixels" 0.0 -200.0 200.0 1.0
|
||||
#define overscanY global.overscanY // OverscanY pixels
|
||||
|
||||
#pragma parameter prescalex " Prescale-X Factor (for xBR...pre-shader)" 1.0 1.0 4.0 1.0
|
||||
#define prescalex global.prescalex // prescale-x factor
|
||||
|
||||
|
||||
#define COMPAT_TEXTURE(c,d) texture(c,d)
|
||||
#define TEX0 vTexCoord
|
||||
|
@ -189,7 +189,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -260,7 +260,9 @@ vec3 gc(vec3 c)
|
|||
|
||||
void main()
|
||||
{
|
||||
vec4 SourceSize = global.OriginalSize * mix( vec4(prescalex, 1.0, 1.0/prescalex, 1.0), vec4(1.0, prescalex, 1.0, 1.0/prescalex), TATE);
|
||||
vec2 prescalex = vec2(vec2(textureSize(LinearizePass, 0))/global.OriginalSize.xy);
|
||||
|
||||
vec4 SourceSize = global.OriginalSize * mix( vec4(prescalex.x, 1.0, 1.0/prescalex.x, 1.0), vec4(1.0, prescalex.y, 1.0, 1.0/prescalex.y), TATE);
|
||||
|
||||
float lum = COMPAT_TEXTURE(AvgLumPass, vec2(0.5,0.5)).a;
|
||||
|
||||
|
@ -270,17 +272,17 @@ void main()
|
|||
bool notate = (TATE < 0.5);
|
||||
|
||||
float SourceY = mix(SourceSize.y, SourceSize.x, TATE);
|
||||
|
||||
float sy = 1.0;
|
||||
if (global.intres == 0.5) sy = SourceY/224.0; else
|
||||
if (global.intres == 1.0) sy = SourceY/240.0; else
|
||||
if (global.intres > 1.25) sy = global.intres;
|
||||
if (global.intres == 1.0) sy = SourceY/224.0;
|
||||
if (global.intres > 0.25 && global.intres != 1.0) sy = global.intres;
|
||||
if (notate) SourceSize*=vec4(1.0, 1.0/sy, 1.0, sy); else SourceSize*=vec4(1.0/sy, 1.0, sy, 1.0);
|
||||
|
||||
// Calculating texel coordinates
|
||||
|
||||
vec2 texcoord = TEX0.xy;
|
||||
if (IOS > 0.0 && !interb){
|
||||
vec2 ofactor = OutputSize.xy/SourceSize.xy;
|
||||
vec2 ofactor = OutputSize.xy/global.OriginalSize.xy;
|
||||
vec2 intfactor = (IOS < 2.5) ? floor(ofactor) : ceil(ofactor);
|
||||
vec2 diff = ofactor/intfactor;
|
||||
float scan = mix(diff.y, diff.x, TATE);
|
||||
|
@ -325,12 +327,15 @@ void main()
|
|||
|
||||
vec2 pC4 = floor(OGL2Pos) * ps + 0.5*ps;
|
||||
|
||||
if (global.intres == 0.5 && notate && prescalex.y < 1.5) pC4.y = floor(pC4.y * global.OriginalSize.y)*global.OriginalSize.w + 0.5*global.OriginalSize.w;
|
||||
if (global.intres == 0.5 && !notate && prescalex.x < 1.5) pC4.x = floor(pC4.x * global.OriginalSize.x)*global.OriginalSize.z + 0.5*global.OriginalSize.z;
|
||||
|
||||
if (interb) pC4.y = pos.y;
|
||||
|
||||
float zero = exp2(-h_sharp);
|
||||
float sharp1 = s_sharp * zero;
|
||||
|
||||
float fdivider = min(prescalex, 2.0);
|
||||
float fdivider = max(min(mix(prescalex.x, prescalex.y,TATE), 2.0), 1.5*float(interb));
|
||||
|
||||
float wl3 = (2.0 + fpx)/fdivider;
|
||||
float wl2 = (1.0 + fpx)/fdivider;
|
||||
|
@ -350,8 +355,8 @@ void main()
|
|||
|
||||
float twl3 = max(wl3 - sharp1, 0.0);
|
||||
float twl2 = max(wl2 - sharp1, mix(-0.12, 0.0, 1.0-fp1*fp1));
|
||||
float twl1 = max(wl1 - sharp1, 0.0);
|
||||
float twr1 = max(wr1 - sharp1, 0.0);
|
||||
float twl1 = max(wl1 - sharp1, -0.12);
|
||||
float twr1 = max(wr1 - sharp1, -0.12);
|
||||
float twr2 = max(wr2 - sharp1, mix(-0.12, 0.0, 1.0-fpx*fpx));
|
||||
float twr3 = max(wr3 - sharp1, 0.0);
|
||||
|
||||
|
@ -401,8 +406,8 @@ void main()
|
|||
float rm2 = max(max(r2.r,r2.g),r2.b);
|
||||
|
||||
float swl2 = max(twl2, 0.0) * (dot(l2,luma) + ts);
|
||||
float swl1 = twl1 * (dot(l1,luma) + ts);
|
||||
float swr1 = twr1 * (dot(r1,luma) + ts);
|
||||
float swl1 = max(twl1, 0.0) * (dot(l1,luma) + ts);
|
||||
float swr1 = max(twr1, 0.0) * (dot(r1,luma) + ts);
|
||||
float swr2 = max(twr2, 0.0) * (dot(r2,luma) + ts);
|
||||
|
||||
float fscolor1 = (lm2*swl2 + lm1*swl1 + rm1*swr1 + rm2*swr2)/(swl2+swl1+swr1+swr2);
|
||||
|
@ -415,6 +420,9 @@ void main()
|
|||
if (!interb)
|
||||
{
|
||||
pC4+=offy;
|
||||
|
||||
if (global.intres == 0.5 && notate && prescalex.y < 1.5) pC4.y = floor((pos.y + 0.33*offy.y) * global.OriginalSize.y)*global.OriginalSize.w + 0.5*global.OriginalSize.w;
|
||||
if (global.intres == 0.5 && !notate && prescalex.x < 1.5) pC4.x = floor((pos.x + 0.33*offy.x) * global.OriginalSize.x)*global.OriginalSize.z + 0.5*global.OriginalSize.z;
|
||||
|
||||
l3 = COMPAT_TEXTURE(LinearizePass, pC4 -off2).rgb;
|
||||
l2 = COMPAT_TEXTURE(LinearizePass, pC4 -offx).rgb;
|
||||
|
@ -445,8 +453,8 @@ void main()
|
|||
rm2 = max(max(r2.r,r2.g),r2.b);
|
||||
|
||||
swl2 = max(twl2, 0.0) * (dot(l2,luma) + ts);
|
||||
swl1 = twl1 * (dot(l1,luma) + ts);
|
||||
swr1 = twr1 * (dot(r1,luma) + ts);
|
||||
swl1 = max(twl1, 0.0) * (dot(l1,luma) + ts);
|
||||
swr1 = max(twr1, 0.0) * (dot(r1,luma) + ts);
|
||||
swr2 = max(twr2, 0.0) * (dot(r2,luma) + ts);
|
||||
|
||||
float fscolor2 = (lm2*swl2 + lm1*swl1 + rm1*swr1 + rm2*swr2)/(swl2+swl1+swr1+swr2);
|
||||
|
@ -502,16 +510,21 @@ if (!interb)
|
|||
float mc1 = max(max(color1.r,color1.g),color1.b) + eps;
|
||||
float mc2 = max(max(color2.r,color2.g),color2.b) + eps;
|
||||
|
||||
cref1 = color1 / mc1; cref1=cref1*cref1; cref1*=cref1;
|
||||
cref2 = color2 / mc2; cref2=cref2*cref2; cref2*=cref2;
|
||||
cref1 = color1 / mc1;
|
||||
cref2 = color2 / mc2;
|
||||
|
||||
w1 = max( mix(w1*mix(one, cref1, scans), w1, wf1*min((1.0+0.15*scans), 1.2)), 0.0); w1 = min(w1*color1, mc1)/(color1 + eps);
|
||||
w2 = max( mix(w2*mix(one, cref2, scans), w2, wf2*min((1.0+0.15*scans), 1.2)), 0.0); w2 = min(w2*color2, mc2)/(color2 + eps);
|
||||
float scanpow1 = (scans > 0.0) ? 1.0 : pow(f1, 0.375);
|
||||
float scanpow2 = (scans > 0.0) ? 1.0 : pow(f2, 0.375);
|
||||
w1 = pow(w1, mix(2.0*abs(scans).xxx + 1.0, 1.0.xxx, mix(1.0.xxx, cref1, scanpow1)));
|
||||
w2 = pow(w2, mix(2.0*abs(scans).xxx + 1.0, 1.0.xxx, mix(1.0.xxx, cref2, scanpow2)));
|
||||
|
||||
// Scanline Deconvergence
|
||||
|
||||
vec3 cd1 = one; vec3 cd2 = one; float vm = sqrt(abs(vertmask));
|
||||
|
||||
vec3 cd1 = one; vec3 cd2 = one;
|
||||
|
||||
if (abs(vertmask) > 0.025)
|
||||
{
|
||||
float vm = sqrt(abs(vertmask));
|
||||
float v_high1 = 1.0 + 0.3*vm;
|
||||
float v_high2 = 1.0 + 0.6*vm;
|
||||
float v_low = 1.0 - vm;
|
||||
|
@ -529,8 +542,9 @@ if (!interb)
|
|||
cd1 = mix(one, vec3(v_high1, v_low, v_high1), ds1);
|
||||
cd2 = mix(one, vec3(v_low, v_high2, v_low), ds2);
|
||||
}
|
||||
}
|
||||
|
||||
color = gc(color1)*w1*cd1 + gc(color2)*w2*cd2;
|
||||
color = (gc(color1)*w1*cd1 + gc(color2)*w2*cd2)/mix(1.0.xxx, w1+w2, no_scanlines);
|
||||
|
||||
if (abs(rolling_scan) > 0.005)
|
||||
{
|
||||
|
@ -548,7 +562,7 @@ if (!interb)
|
|||
color = gc(color1);
|
||||
}
|
||||
|
||||
float colmx = pow(max(max(ctmp.r,ctmp.g),ctmp.b), 1.40/gamma_in);
|
||||
float colmx = max(max(ctmp.r,ctmp.g),ctmp.b);
|
||||
|
||||
if(!interb) color = pow( color, vec3(gamma_in/scangamma) );
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
float overscanX;
|
||||
float overscanY;
|
||||
float intres;
|
||||
float prescalex;
|
||||
float c_shape;
|
||||
float barspeed;
|
||||
float barintensity;
|
||||
|
@ -66,12 +65,18 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
float deconrby;
|
||||
float dctypex;
|
||||
float dctypey;
|
||||
float post_br;
|
||||
float post_br;
|
||||
float maskboost;
|
||||
float smoothmask;
|
||||
float gamma_c;
|
||||
float m_glow;
|
||||
} global;
|
||||
|
||||
|
||||
#pragma parameter bogus_brightness "[ BRIGHTNESS SETTINGS ]:" 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter m_glow " Ordinary Glow / Magic Glow" 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter glow " Glow Strength" 0.08 -2.0 2.0 0.01
|
||||
#define glow params.glow // Glow Strength
|
||||
|
||||
|
@ -84,18 +89,18 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter bloom_dist " Bloom Distribution" 0.0 0.0 3.0 0.05
|
||||
#define bloom_dist global.bloom_dist // bloom effect distribution
|
||||
|
||||
#pragma parameter halation " Halation Strength" 0.0 0.0 2.0 0.025
|
||||
#pragma parameter halation " Halation Strength" 0.0 -2.0 2.0 0.025
|
||||
#define halation global.halation // halation effect
|
||||
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.02
|
||||
#define gamma_c global.gamma_c // adjust brightness
|
||||
|
||||
#pragma parameter brightboost " Bright Boost Dark Pixels" 1.40 0.25 10.0 0.05
|
||||
#define brightboost params.brightboost // adjust brightness
|
||||
|
||||
#pragma parameter brightboost1 " Bright Boost Bright Pixels" 1.10 0.25 3.00 0.025
|
||||
#define brightboost1 params.brightboost1 // adjust brightness
|
||||
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.025
|
||||
#define gamma_c global.gamma_c // adjust brightness
|
||||
|
||||
#pragma parameter bogus_screen "[ SCREEN OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter IOS " Integer Scaling: Odd:Y, Even:'X'+Y" 0.0 0.0 4.0 1.0
|
||||
|
@ -137,12 +142,9 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter overscanY " Overscan Y original pixels" 0.0 -200.0 200.0 1.0
|
||||
#define overscanY global.overscanY // OverscanY pixels
|
||||
|
||||
#pragma parameter prescalex " Prescale-X Factor (for xBR...pre-shader)" 1.0 1.0 4.0 1.0
|
||||
#define prescalex global.prescalex // prescale-x factor
|
||||
|
||||
#pragma parameter bogus_masks "[ CRT MASK OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter shadowMask " CRT Mask: 0:CGWG, 1-4:Lottes, 5-12:'Trinitron'" 0.0 -1.0 12.0 1.0
|
||||
#pragma parameter shadowMask " CRT Mask: 0:CGWG, 1-4:Lottes, 5-13:'Trinitron'" 0.0 -1.0 13.0 1.0
|
||||
#define shadowMask params.shadowMask // Mask Style
|
||||
|
||||
#pragma parameter maskstr " Mask Strength (0, 5-12)" 0.3 -0.5 1.0 0.025
|
||||
|
@ -151,6 +153,9 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter mcut " Mask 5-12 Low Strength" 1.10 0.0 2.0 0.05
|
||||
#define mcut params.mcut // Mask 5-12 dark color strength
|
||||
|
||||
#pragma parameter maskboost " CRT Mask Boost" 1.0 1.0 3.0 0.05
|
||||
#define maskboost global.maskboost // Mask Boost
|
||||
|
||||
#pragma parameter masksize " CRT Mask Size" 1.0 1.0 4.0 1.0
|
||||
#define masksize params.masksize // Mask Size
|
||||
|
||||
|
@ -160,7 +165,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter maskLight " Lottes maskLight" 1.5 0.0 2.0 0.05
|
||||
#define maskLight params.maskLight // Light "Phosphor"
|
||||
|
||||
#pragma parameter mshift " Mask Shift/Stagger" 0.0 -8.0 8.0 1.0
|
||||
#pragma parameter mshift " Mask Shift/Stagger" 0.0 -8.0 8.0 0.5
|
||||
#define mshift params.mshift // mask 'line' shift/stagger
|
||||
|
||||
#pragma parameter mask_layout " Mask Layout: RGB or BGR (check LCD panel) " 0.0 0.0 1.0 1.0
|
||||
|
@ -184,9 +189,12 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter slotms " Slot Mask Size" 1.0 1.0 4.0 1.0
|
||||
#define slotms global.slotms // Slot Mask Size
|
||||
|
||||
#pragma parameter mclip " Keep Mask effect with clipping" 0.50 0.0 1.0 0.05
|
||||
#pragma parameter mclip " Keep Mask effect with clipping" 0.0 0.0 1.0 0.05
|
||||
#define mclip global.mclip //
|
||||
|
||||
#pragma parameter smoothmask " Smooth Masks in bright scanlines" 0.0 0.0 1.0 1.0
|
||||
#define smoothmask global.smoothmask
|
||||
|
||||
#pragma parameter gamma_out "Gamma out" 1.95 1.0 5.0 0.05
|
||||
#define gamma_out global.gamma_out // output gamma
|
||||
|
||||
|
@ -234,7 +242,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -251,17 +259,22 @@ layout(set = 0, binding = 7) uniform sampler2D Source;
|
|||
|
||||
// Shadow mask (1-4 from PD CRT Lottes shader).
|
||||
|
||||
vec3 Mask(vec2 pos, float mx)
|
||||
vec3 Mask(vec2 pos, float mx, float mb)
|
||||
{
|
||||
vec2 pos0 = pos;
|
||||
pos.y = floor(pos.y/masksize);
|
||||
float next_line = float(fract(pos.y*0.5) > 0.25);
|
||||
pos0.x = (mshift > -0.25) ? (pos0.x + next_line * mshift) : (pos0.x + pos.y * mshift);
|
||||
float stagg_lvl = 1.0; if (fract(abs(mshift)) > 0.25 && abs(mshift) > 1.25) stagg_lvl = 2.0;
|
||||
float next_line = float(fract((pos.y/stagg_lvl)*0.5) > 0.25);
|
||||
pos0.x = (mshift > -0.25) ? (pos0.x + next_line * floor(mshift)) : (pos0.x + floor(pos.y / stagg_lvl) * floor(abs(mshift)));
|
||||
pos = floor(pos0/masksize);
|
||||
|
||||
vec3 mask = vec3(maskDark, maskDark, maskDark);
|
||||
vec3 one = vec3(1.0);
|
||||
float dark_compensate = mix(max( clamp( mix (mcut, maskstr, mx),0.0, 1.0) - 0.4, 0.0) + 1.0, 1.0, mx);
|
||||
|
||||
// brightness correcture masks 5-12
|
||||
float sm = 0.45; if(shadowMask == 8.0 || shadowMask == 11.0 || shadowMask == 13.0) sm = 0.7;
|
||||
float dark_compensate = mix(max( clamp( mix (mcut, maskstr, mx),0.0, 1.0) - sm, 0.0) + 1.0, 1.0, mx);
|
||||
|
||||
float mc = 1.0 - max(maskstr, 0.0);
|
||||
|
||||
// No mask
|
||||
|
@ -414,18 +427,33 @@ vec3 Mask(vec2 pos, float mx)
|
|||
}
|
||||
|
||||
// RRGGBBX mask
|
||||
else
|
||||
else if (shadowMask == 12.0)
|
||||
{
|
||||
mask = vec3(0.0);
|
||||
pos.x = floor(mod(pos.x,7.0));
|
||||
if (pos.x < 1.0) mask = 0.0.xxx;
|
||||
else if (pos.x < 3.0) mask.r = 1.0;
|
||||
else if (pos.x < 5.0) mask.g = 1.0;
|
||||
if (pos.x < 0.5) mask = 0.0.xxx;
|
||||
else if (pos.x < 2.5) mask.r = 1.0;
|
||||
else if (pos.x < 4.5) mask.g = 1.0;
|
||||
else mask.b = 1.0;
|
||||
mask = clamp(mix( mix(one, mask, mcut), mix(one, mask, maskstr), mx), 0.0, 1.0) * dark_compensate;
|
||||
}
|
||||
|
||||
// 4k mask
|
||||
else
|
||||
{
|
||||
mask = vec3(0.0);
|
||||
pos.x = floor(mod(pos.x,6.0));
|
||||
if (pos.x < 0.5) mask = 0.0.xxx;
|
||||
else if (pos.x < 1.5) mask.r = 1.0;
|
||||
else if (pos.x < 2.5) mask.rg = 1.0.xx;
|
||||
else if (pos.x < 3.5) mask.rgb = 1.0.xxx;
|
||||
else if (pos.x < 4.5) mask.gb = 1.0.xx;
|
||||
else mask.b = 1.0;
|
||||
mask = clamp(mix( mix(one, mask, mcut), mix(one, mask, maskstr), mx), 0.0, 1.0) * dark_compensate;
|
||||
}
|
||||
|
||||
return mask;
|
||||
float maskmin = min(min(mask.r,mask.g),mask.b);
|
||||
return (mask - maskmin) * (1.0 + (maskboost-1.0)*mb) + maskmin;
|
||||
}
|
||||
|
||||
float SlotMask(vec2 pos, float m)
|
||||
|
@ -433,6 +461,7 @@ float SlotMask(vec2 pos, float m)
|
|||
if ((slotmask + slotmask1) == 0.0) return 1.0;
|
||||
else
|
||||
{
|
||||
if (shadowMask == 2.0 || shadowMask == 6.0) pos.x = pos.x + 1.0;
|
||||
pos = floor(pos/slotms);
|
||||
float mlen = slotwidth*2.0;
|
||||
float px = fract(pos.x/mlen);
|
||||
|
@ -444,7 +473,7 @@ float SlotMask(vec2 pos, float m)
|
|||
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vec2 Warp(vec2 pos)
|
||||
{
|
||||
|
@ -498,6 +527,11 @@ vec3 declip(vec3 c, float b)
|
|||
return c;
|
||||
}
|
||||
|
||||
float igc(float mc)
|
||||
{
|
||||
return pow(mc, gamma_c);
|
||||
}
|
||||
|
||||
// noise function:
|
||||
// Dedicated to the public domain.
|
||||
// If you want a real license, you may consider this MIT/BSD/CC0/WTFPL-licensed (take your pick).
|
||||
|
@ -567,7 +601,7 @@ void fetch_pixel (inout vec3 c, inout vec3 b, vec2 coord, vec2 bcoord)
|
|||
|
||||
void main()
|
||||
{
|
||||
vec4 SourceSize = global.OriginalSize * vec4(prescalex, 1.0, 1.0/prescalex, 1.0);
|
||||
vec4 SourceSize = global.OriginalSize;
|
||||
|
||||
float lum = COMPAT_TEXTURE(AvgLumPass, vec2(0.5,0.5)).a;
|
||||
|
||||
|
@ -579,7 +613,7 @@ void main()
|
|||
|
||||
vec2 texcoord = TEX0.xy;
|
||||
if (IOS > 0.0 && !interb){
|
||||
vec2 ofactor = OutputSize.xy/SourceSize.xy;
|
||||
vec2 ofactor = OutputSize.xy/global.OriginalSize.xy;
|
||||
vec2 intfactor = (IOS < 2.5) ? floor(ofactor) : ceil(ofactor);
|
||||
vec2 diff = ofactor/intfactor;
|
||||
float scan = diff.y;
|
||||
|
@ -595,23 +629,31 @@ void main()
|
|||
vec2 pos1 = TEX0.xy;
|
||||
vec2 pos = Warp(texcoord);
|
||||
vec2 pos0 = Warp(TEX0.xy);
|
||||
vec3 color0 = COMPAT_TEXTURE(Source,pos1).rgb;
|
||||
float c0 = max(max(color0.r, color0.g),color0.b);
|
||||
|
||||
// color and bloom fetching
|
||||
vec3 color = COMPAT_TEXTURE(Source,pos1).rgb;
|
||||
vec3 Bloom = COMPAT_TEXTURE(BloomPass, pos).rgb;
|
||||
fetch_pixel(color, Bloom, pos1, pos);
|
||||
|
||||
float cm = max(max(color.r,color.g),color.b);
|
||||
if ((abs(global.deconrr) + abs(global.deconrry) + abs(global.deconrg) + abs(global.deconrgy) + abs(global.deconrb) + abs(global.deconrby)) > 0.2)
|
||||
fetch_pixel(color, Bloom, pos1, pos); // deconvergence
|
||||
|
||||
float cm = igc(max(max(color.r,color.g),color.b));
|
||||
float mx1 = COMPAT_TEXTURE(Source, pos1 ).a;
|
||||
float colmx = max(mx1, cm);
|
||||
float w3 = min((c0 + 0.0005) / (pow(colmx, gamma_in/1.4) + 0.0005), 1.0);
|
||||
float w3 = min((cm + 0.0001) / (colmx + 0.0005), 1.0);
|
||||
|
||||
vec2 dx = vec2(0.001, 0.0);
|
||||
float mx0 = COMPAT_TEXTURE(Source, pos1 - dx).a;
|
||||
float mx2 = COMPAT_TEXTURE(Source, pos1 + dx).a;
|
||||
float mx = max(max(mx0,mx1),max(mx2,cm));
|
||||
float mxg = max(max(mx0,mx1),max(mx2,cm));
|
||||
float mx = pow(mxg, 1.40/gamma_in);
|
||||
|
||||
// mask boost tweak
|
||||
|
||||
dx = vec2(global.OriginalSize.z, 0.0)*0.25;
|
||||
mx0 = COMPAT_TEXTURE(Source, pos1 - dx).a;
|
||||
mx2 = COMPAT_TEXTURE(Source, pos1 + dx).a;
|
||||
float mb = 1.0 - min(abs(mx0-mx2)/(0.5+mx1), 1.0);
|
||||
|
||||
vec3 one = vec3(1.0);
|
||||
|
||||
|
@ -623,33 +665,29 @@ void main()
|
|||
vec2 maskcoord = gl_FragCoord.xy * 1.000001;
|
||||
|
||||
float smask = SlotMask(maskcoord, mx);
|
||||
cmask*= Mask(maskcoord, mx);
|
||||
cmask*= Mask(maskcoord, mx, mb);
|
||||
|
||||
if (mask_layout > 0.5) cmask = cmask.rbg;
|
||||
if (mask_layout > 0.5) cmask = cmask.bgr;
|
||||
|
||||
cmask*=smask;
|
||||
vec3 cmask1 = cmask;
|
||||
float smask1 = smask;
|
||||
|
||||
if (mask_bloom > 0.025)
|
||||
{
|
||||
float maxb = max(max(Bloom.r,Bloom.g),Bloom.b);
|
||||
maxb = pow(sqrt(maxb*mix(maxb, colmx, 0.75)),0.275);
|
||||
vec3 mBloom = 0.5*(1.5*Bloom+0.5*maxb) * mix(1.0, 2.0-colmx, (bloom_dist + 0.5));
|
||||
float maskmx = 1.0; if (shadowMask > 0.5 || shadowMask < 4.5) maskmx = maskLight; else if (shadowMask > 6.5 && shadowMask < 10.5) maskmx = 1.0; else maskmx = max(max(cmask.r,cmask.g),cmask.b);
|
||||
cmask = min(cmask + maxb*mBloom*mask_bloom, maskmx);
|
||||
smask = min(smask + 0.9*maxb*max(max(mBloom.r,mBloom.g),mBloom.b)*mask_bloom, 1.0);
|
||||
float maxbl = max(max(max(Bloom.r,Bloom.g),Bloom.b), mxg);
|
||||
maxbl = maxbl * mix(1.0, 2.0-colmx, bloom_dist);
|
||||
cmask = max(min(cmask + maxbl*mask_bloom, 1.0), cmask);
|
||||
}
|
||||
|
||||
color = pow(color, vec3(mask_gamma/gamma_in));
|
||||
color = color*cmask;
|
||||
color = min(color,1.0);
|
||||
color = color*smask;
|
||||
color = pow(color, vec3(gamma_in/mask_gamma));
|
||||
|
||||
cmask = min(cmask*smask, 1.0);
|
||||
cmask1 = min(cmask1*smask1, 1.0);
|
||||
cmask = min(cmask, 1.0);
|
||||
cmask1 = min(cmask1, 1.0);
|
||||
|
||||
float bb = mix(brightboost, brightboost1, colmx);
|
||||
float bb = mix(brightboost, brightboost1, mx);
|
||||
if (interb) bb = (abs(intera-0.5)<0.1) ? pow(0.80*bb, 0.65) : pow(bb, 0.70);
|
||||
color*=bb;
|
||||
|
||||
|
@ -660,25 +698,41 @@ void main()
|
|||
|
||||
vec3 Bloom1 = Bloom;
|
||||
|
||||
if (abs(bloom) > 0.025)
|
||||
{
|
||||
if (bloom < -0.01) Bloom1 = plant(Bloom, maxb);
|
||||
|
||||
Bloom1 = min(Bloom1*(orig1+color), max(0.5*(colmx + orig1 - color),0.001*Bloom1));
|
||||
Bloom1 = 0.5*(Bloom1 + mix(Bloom1, mix(colmx*orig1, Bloom1, 0.5), 1.0-color));
|
||||
|
||||
Bloom1 = Bloom1 * mix(1.0, 2.0-colmx, bloom_dist);
|
||||
|
||||
color = color + abs(bloom) * Bloom1;
|
||||
color = pow(pow(color, vec3(mask_gamma/gamma_in)) + abs(bloom) * pow(Bloom1, vec3(mask_gamma/gamma_in)), vec3(gamma_in/mask_gamma));
|
||||
}
|
||||
|
||||
color = min(color, mix(one, cmask1, mclip));
|
||||
|
||||
if (!interb) color = declip(color, mix(1.0, w3, 0.6)); else w3 = 1.0;
|
||||
|
||||
|
||||
if (halation > 0.01) {
|
||||
Bloom = mix(0.5*(Bloom + Bloom*Bloom), 0.75*Bloom*Bloom, colmx);
|
||||
color = color + 2.0*max((2.0*mix(maxb*maxb, maxb, colmx)-0.5*max(max(Ref.r,Ref.g),Ref.b)),0.25)*mix(1.0,w3,0.5*colmx)*mix(one,cmask,0.6)*Bloom*halation; }
|
||||
else
|
||||
if (halation < 0.01) {
|
||||
float mbl = max(max(Bloom.r,Bloom.g),Bloom.b);
|
||||
Bloom = plant(Bloom + Ref + orig1 + Bloom*Bloom*Bloom, min(mbl*mbl,0.75));
|
||||
color = color + 2.0*mix(1.0,w3,0.5*colmx)*mix(one,cmask,0.5)*Bloom*(-halation); }
|
||||
|
||||
Glow = mix(Glow, 0.25*color, 0.7*colmx);
|
||||
if (glow >= 0.0) color = color + 0.5*Glow*glow; else { cmask*=cmask; cmask*=cmask; color = color + (-glow)*cmask*Glow; }
|
||||
if (smoothmask > 0.5) { w3 = mix(1.0, w3, smoothstep(0.3, 0.6, mx1)); color = max(min(color/w3, 1.0)*w3, min(color,color*(1.0-w3))); }
|
||||
|
||||
if (global.m_glow < 0.5) Glow = mix(Glow, 0.25*color, 0.7*colmx);
|
||||
else
|
||||
{
|
||||
vec3 gb = plant(orig1, 1.0);
|
||||
maxb = max(max(Glow.r,Glow.g),Glow.b);
|
||||
gb = mix(maxb*vec3(0.0, 0.0, 1.0), Glow, clamp(gb.r + gb.g - 0.375*gb.b,0.0,1.0));
|
||||
Glow = mix(0.75*Glow,5.0*plant(mix(gb,orig1, 0.5*sqrt(colmx)*abs(plant(Glow,1.0)-plant(orig1,1.0))), maxb), pow(colmx, 0.50/gamma_in));
|
||||
Glow = mix(Glow, 0.4*Glow, 1.0-colmx*colmx);
|
||||
}
|
||||
|
||||
if (glow >= 0.0 && global.m_glow < 0.5) color = color + 0.5*Glow*glow; else { cmask*=cmask; cmask*=cmask; color = color + abs(glow)*cmask*Glow; }
|
||||
|
||||
color = min(color, 1.0);
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
float overscanX;
|
||||
float overscanY;
|
||||
float intres;
|
||||
float prescalex;
|
||||
float c_shape;
|
||||
float barspeed;
|
||||
float barintensity;
|
||||
|
@ -66,12 +65,18 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
float deconrby;
|
||||
float dctypex;
|
||||
float dctypey;
|
||||
float post_br;
|
||||
float post_br;
|
||||
float maskboost;
|
||||
float smoothmask;
|
||||
float gamma_c;
|
||||
float m_glow;
|
||||
} global;
|
||||
|
||||
|
||||
#pragma parameter bogus_brightness "[ BRIGHTNESS SETTINGS ]:" 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter m_glow " Ordinary Glow / Magic Glow" 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter glow " Glow Strength" 0.08 -2.0 2.0 0.01
|
||||
#define glow params.glow // Glow Strength
|
||||
|
||||
|
@ -84,18 +89,18 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter bloom_dist " Bloom Distribution" 0.0 0.0 3.0 0.05
|
||||
#define bloom_dist global.bloom_dist // bloom effect distribution
|
||||
|
||||
#pragma parameter halation " Halation Strength" 0.0 0.0 2.0 0.025
|
||||
#pragma parameter halation " Halation Strength" 0.0 -2.0 2.0 0.025
|
||||
#define halation global.halation // halation effect
|
||||
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.02
|
||||
#define gamma_c global.gamma_c // adjust brightness
|
||||
|
||||
#pragma parameter brightboost " Bright Boost Dark Pixels" 1.40 0.25 10.0 0.05
|
||||
#define brightboost params.brightboost // adjust brightness
|
||||
|
||||
#pragma parameter brightboost1 " Bright Boost Bright Pixels" 1.10 0.25 3.00 0.025
|
||||
#define brightboost1 params.brightboost1 // adjust brightness
|
||||
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.025
|
||||
#define gamma_c global.gamma_c // adjust brightness
|
||||
|
||||
#pragma parameter bogus_screen "[ SCREEN OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter TATE " TATE Mode" 0.0 0.0 1.0 1.0
|
||||
|
@ -140,12 +145,9 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter overscanY " Overscan Y original pixels" 0.0 -200.0 200.0 1.0
|
||||
#define overscanY global.overscanY // OverscanY pixels
|
||||
|
||||
#pragma parameter prescalex " Prescale-X Factor (for xBR...pre-shader)" 1.0 1.0 4.0 1.0
|
||||
#define prescalex global.prescalex // prescale-x factor
|
||||
|
||||
#pragma parameter bogus_masks "[ CRT MASK OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter shadowMask " CRT Mask: 0:CGWG, 1-4:Lottes, 5-12:'Trinitron'" 0.0 -1.0 12.0 1.0
|
||||
#pragma parameter shadowMask " CRT Mask: 0:CGWG, 1-4:Lottes, 5-13:'Trinitron'" 0.0 -1.0 13.0 1.0
|
||||
#define shadowMask params.shadowMask // Mask Style
|
||||
|
||||
#pragma parameter maskstr " Mask Strength (0, 5-12)" 0.3 -0.5 1.0 0.025
|
||||
|
@ -154,6 +156,9 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter mcut " Mask 5-12 Low Strength" 1.10 0.0 2.0 0.05
|
||||
#define mcut params.mcut // Mask 5-12 dark color strength
|
||||
|
||||
#pragma parameter maskboost " CRT Mask Boost" 1.0 1.0 3.0 0.05
|
||||
#define maskboost global.maskboost // Mask Boost
|
||||
|
||||
#pragma parameter masksize " CRT Mask Size" 1.0 1.0 4.0 1.0
|
||||
#define masksize params.masksize // Mask Size
|
||||
|
||||
|
@ -163,7 +168,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter maskLight " Lottes maskLight" 1.5 0.0 2.0 0.05
|
||||
#define maskLight params.maskLight // Light "Phosphor"
|
||||
|
||||
#pragma parameter mshift " Mask Shift/Stagger" 0.0 -8.0 8.0 1.0
|
||||
#pragma parameter mshift " Mask Shift/Stagger" 0.0 -8.0 8.0 0.5
|
||||
#define mshift params.mshift // mask 'line' shift/stagger
|
||||
|
||||
#pragma parameter mask_layout " Mask Layout: RGB or BGR (check LCD panel) " 0.0 0.0 1.0 1.0
|
||||
|
@ -187,9 +192,12 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter slotms " Slot Mask Size" 1.0 1.0 4.0 1.0
|
||||
#define slotms global.slotms // Slot Mask Size
|
||||
|
||||
#pragma parameter mclip " Keep Mask effect with clipping" 0.50 0.0 1.0 0.05
|
||||
#pragma parameter mclip " Keep Mask effect with clipping" 0.0 0.0 1.0 0.05
|
||||
#define mclip global.mclip //
|
||||
|
||||
#pragma parameter smoothmask " Smooth Masks in bright scanlines" 0.0 0.0 1.0 1.0
|
||||
#define smoothmask global.smoothmask
|
||||
|
||||
#pragma parameter gamma_out "Gamma out" 2.4 1.0 5.0 0.05
|
||||
#define gamma_out global.gamma_out // output gamma
|
||||
|
||||
|
@ -237,7 +245,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -254,17 +262,22 @@ layout(set = 0, binding = 7) uniform sampler2D Source;
|
|||
|
||||
// Shadow mask (1-4 from PD CRT Lottes shader).
|
||||
|
||||
vec3 Mask(vec2 pos, float mx)
|
||||
vec3 Mask(vec2 pos, float mx, float mb)
|
||||
{
|
||||
vec2 pos0 = pos;
|
||||
pos.y = floor(pos.y/masksize);
|
||||
float next_line = float(fract(pos.y*0.5) > 0.25);
|
||||
pos0.x = (mshift > -0.25) ? (pos0.x + next_line * mshift) : (pos0.x + pos.y * mshift);
|
||||
float stagg_lvl = 1.0; if (fract(abs(mshift)) > 0.25 && abs(mshift) > 1.25) stagg_lvl = 2.0;
|
||||
float next_line = float(fract((pos.y/stagg_lvl)*0.5) > 0.25);
|
||||
pos0.x = (mshift > -0.25) ? (pos0.x + next_line * floor(mshift)) : (pos0.x + floor(pos.y / stagg_lvl) * floor(abs(mshift)));
|
||||
pos = floor(pos0/masksize);
|
||||
|
||||
vec3 mask = vec3(maskDark, maskDark, maskDark);
|
||||
vec3 one = vec3(1.0);
|
||||
float dark_compensate = mix(max( clamp( mix (mcut, maskstr, mx),0.0, 1.0) - 0.4, 0.0) + 1.0, 1.0, mx);
|
||||
|
||||
// brightness correcture masks 5-12
|
||||
float sm = 0.45; if(shadowMask == 8.0 || shadowMask == 11.0 || shadowMask == 13.0) sm = 0.7;
|
||||
float dark_compensate = mix(max( clamp( mix (mcut, maskstr, mx),0.0, 1.0) - sm, 0.0) + 1.0, 1.0, mx);
|
||||
|
||||
float mc = 1.0 - max(maskstr, 0.0);
|
||||
|
||||
// No mask
|
||||
|
@ -417,18 +430,33 @@ vec3 Mask(vec2 pos, float mx)
|
|||
}
|
||||
|
||||
// RRGGBBX mask
|
||||
else
|
||||
else if (shadowMask == 12.0)
|
||||
{
|
||||
mask = vec3(0.0);
|
||||
pos.x = floor(mod(pos.x,7.0));
|
||||
if (pos.x < 1.0) mask = 0.0.xxx;
|
||||
else if (pos.x < 3.0) mask.r = 1.0;
|
||||
else if (pos.x < 5.0) mask.g = 1.0;
|
||||
if (pos.x < 0.5) mask = 0.0.xxx;
|
||||
else if (pos.x < 2.5) mask.r = 1.0;
|
||||
else if (pos.x < 4.5) mask.g = 1.0;
|
||||
else mask.b = 1.0;
|
||||
mask = clamp(mix( mix(one, mask, mcut), mix(one, mask, maskstr), mx), 0.0, 1.0) * dark_compensate;
|
||||
}
|
||||
|
||||
// 4k mask
|
||||
else
|
||||
{
|
||||
mask = vec3(0.0);
|
||||
pos.x = floor(mod(pos.x,6.0));
|
||||
if (pos.x < 0.5) mask = 0.0.xxx;
|
||||
else if (pos.x < 1.5) mask.r = 1.0;
|
||||
else if (pos.x < 2.5) mask.rg = 1.0.xx;
|
||||
else if (pos.x < 3.5) mask.rgb = 1.0.xxx;
|
||||
else if (pos.x < 4.5) mask.gb = 1.0.xx;
|
||||
else mask.b = 1.0;
|
||||
mask = clamp(mix( mix(one, mask, mcut), mix(one, mask, maskstr), mx), 0.0, 1.0) * dark_compensate;
|
||||
}
|
||||
|
||||
return mask;
|
||||
float maskmin = min(min(mask.r,mask.g),mask.b);
|
||||
return (mask - maskmin) * (1.0 + (maskboost-1.0)*mb) + maskmin;
|
||||
}
|
||||
|
||||
float SlotMask(vec2 pos, float m)
|
||||
|
@ -436,6 +464,7 @@ float SlotMask(vec2 pos, float m)
|
|||
if ((slotmask + slotmask1) == 0.0) return 1.0;
|
||||
else
|
||||
{
|
||||
if (shadowMask == 2.0 || shadowMask == 6.0) pos.x = pos.x + 1.0;
|
||||
pos = floor(pos/slotms);
|
||||
float mlen = slotwidth*2.0;
|
||||
float px = fract(pos.x/mlen);
|
||||
|
@ -447,7 +476,7 @@ float SlotMask(vec2 pos, float m)
|
|||
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vec2 Warp(vec2 pos)
|
||||
{
|
||||
|
@ -501,6 +530,11 @@ vec3 declip(vec3 c, float b)
|
|||
return c;
|
||||
}
|
||||
|
||||
float igc(float mc)
|
||||
{
|
||||
return pow(mc, gamma_c);
|
||||
}
|
||||
|
||||
// noise function:
|
||||
// Dedicated to the public domain.
|
||||
// If you want a real license, you may consider this MIT/BSD/CC0/WTFPL-licensed (take your pick).
|
||||
|
@ -570,7 +604,7 @@ void fetch_pixel (inout vec3 c, inout vec3 b, vec2 coord, vec2 bcoord)
|
|||
|
||||
void main()
|
||||
{
|
||||
vec4 SourceSize = global.OriginalSize * vec4(prescalex, 1.0, 1.0/prescalex, 1.0);
|
||||
vec4 SourceSize = global.OriginalSize;
|
||||
|
||||
float lum = COMPAT_TEXTURE(AvgLumPass, vec2(0.5,0.5)).a;
|
||||
|
||||
|
@ -583,7 +617,7 @@ void main()
|
|||
|
||||
vec2 texcoord = TEX0.xy;
|
||||
if (IOS > 0.0 && !interb){
|
||||
vec2 ofactor = OutputSize.xy/SourceSize.xy;
|
||||
vec2 ofactor = OutputSize.xy/global.OriginalSize.xy;
|
||||
vec2 intfactor = (IOS < 2.5) ? floor(ofactor) : ceil(ofactor);
|
||||
vec2 diff = ofactor/intfactor;
|
||||
float scan = mix(diff.y, diff.x, TATE);
|
||||
|
@ -599,24 +633,31 @@ void main()
|
|||
vec2 pos1 = TEX0.xy;
|
||||
vec2 pos = Warp(texcoord);
|
||||
vec2 pos0 = Warp(TEX0.xy);
|
||||
vec3 color0 = COMPAT_TEXTURE(Source,pos1).rgb;
|
||||
float c0 = max(max(color0.r, color0.g),color0.b);
|
||||
|
||||
// color and bloom fetching
|
||||
vec3 color = COMPAT_TEXTURE(Source,pos1).rgb;
|
||||
vec3 Bloom = COMPAT_TEXTURE(BloomPass, pos).rgb;
|
||||
|
||||
fetch_pixel(color, Bloom, pos1, pos); // deconvergence
|
||||
|
||||
float cm = max(max(color.r,color.g),color.b);
|
||||
if ((abs(global.deconrr) + abs(global.deconrry) + abs(global.deconrg) + abs(global.deconrgy) + abs(global.deconrb) + abs(global.deconrby)) > 0.2)
|
||||
fetch_pixel(color, Bloom, pos1, pos); // deconvergence
|
||||
|
||||
float cm = igc(max(max(color.r,color.g),color.b));
|
||||
float mx1 = COMPAT_TEXTURE(Source, pos1 ).a;
|
||||
float colmx = max(mx1, cm);
|
||||
float w3 = min((c0 + 0.0005) / (pow(colmx, gamma_in/1.4) + 0.0005), 1.0);
|
||||
float w3 = min((cm + 0.0001) / (colmx + 0.0005), 1.0);
|
||||
|
||||
vec2 dx = mix(vec2(0.001, 0.0), vec2(0.0, 0.001), TATE);
|
||||
float mx0 = COMPAT_TEXTURE(Source, pos1 - dx).a;
|
||||
float mx2 = COMPAT_TEXTURE(Source, pos1 + dx).a;
|
||||
float mx = max(max(mx0,mx1),max(mx2,cm));
|
||||
float mxg = max(max(mx0,mx1),max(mx2,cm));
|
||||
float mx = pow(mxg, 1.40/gamma_in);
|
||||
|
||||
// mask boost tweak
|
||||
|
||||
dx = mix(vec2(global.OriginalSize.z, 0.0), vec2(0.0, global.OriginalSize.w), TATE) * 0.25;
|
||||
mx0 = COMPAT_TEXTURE(Source, pos1 - dx).a;
|
||||
mx2 = COMPAT_TEXTURE(Source, pos1 + dx).a;
|
||||
float mb = 1.0 - min(abs(mx0-mx2)/(0.5+mx1), 1.0);
|
||||
|
||||
vec3 one = vec3(1.0);
|
||||
|
||||
|
@ -629,51 +670,47 @@ void main()
|
|||
if (notate) maskcoord = maskcoord.yx;
|
||||
|
||||
float smask = SlotMask(maskcoord, mx);
|
||||
cmask*= Mask(maskcoord, mx);
|
||||
cmask*= Mask(maskcoord, mx, mb);
|
||||
|
||||
if (mask_layout > 0.5) cmask = cmask.rbg;
|
||||
if (mask_layout > 0.5) cmask = cmask.bgr;
|
||||
|
||||
cmask*=smask;
|
||||
vec3 cmask1 = cmask;
|
||||
float smask1 = smask;
|
||||
|
||||
if (mask_bloom > 0.025)
|
||||
{
|
||||
float maxb = max(max(Bloom.r,Bloom.g),Bloom.b);
|
||||
maxb = pow(sqrt(maxb*mix(maxb, colmx, 0.75)),0.275);
|
||||
vec3 mBloom = 0.5*(1.5*Bloom+0.5*maxb) * mix(1.0, 2.0-colmx, (bloom_dist + 0.5));
|
||||
float maskmx = 1.0; if (shadowMask > 0.5 || shadowMask < 4.5) maskmx = maskLight; else if (shadowMask > 6.5 && shadowMask < 10.5) maskmx = 1.0; else maskmx = max(max(cmask.r,cmask.g),cmask.b);
|
||||
cmask = min(cmask + maxb*mBloom*mask_bloom, maskmx);
|
||||
smask = min(smask + 0.9*maxb*max(max(mBloom.r,mBloom.g),mBloom.b)*mask_bloom, 1.0);
|
||||
float maxbl = max(max(max(Bloom.r,Bloom.g),Bloom.b), mxg);
|
||||
maxbl = maxbl * mix(1.0, 2.0-colmx, bloom_dist);
|
||||
cmask = max(min(cmask + maxbl*mask_bloom, 1.0), cmask);
|
||||
}
|
||||
|
||||
color = pow(color, vec3(mask_gamma/gamma_in));
|
||||
color = color*cmask;
|
||||
color = min(color,1.0);
|
||||
color = color*smask;
|
||||
color = pow(color, vec3(gamma_in/mask_gamma));
|
||||
|
||||
cmask = min(cmask*smask, 1.0);
|
||||
cmask1 = min(cmask1*smask1, 1.0);
|
||||
cmask = min(cmask, 1.0);
|
||||
cmask1 = min(cmask1, 1.0);
|
||||
|
||||
float bb = mix(brightboost, brightboost1, colmx);
|
||||
float bb = mix(brightboost, brightboost1, mx);
|
||||
if (interb) bb = (abs(intera-0.5)<0.1) ? pow(0.80*bb, 0.65) : pow(bb, 0.70);
|
||||
color*=bb;
|
||||
|
||||
vec3 Glow = COMPAT_TEXTURE(GlowPass, pos).rgb;
|
||||
vec3 Ref = COMPAT_TEXTURE(LinearizePass, pos).rgb;
|
||||
vec3 Glow = COMPAT_TEXTURE(GlowPass, pos).rgb;
|
||||
float maxb = COMPAT_TEXTURE(BloomPass, pos).a;
|
||||
float vig = COMPAT_TEXTURE(PrePass, clamp(pos, 0.0+0.5*global.OriginalSize.zw, 1.0-0.5*global.OriginalSize.zw)).a;
|
||||
|
||||
vec3 Bloom1 = Bloom;
|
||||
|
||||
if (abs(bloom) > 0.025)
|
||||
{
|
||||
if (bloom < -0.01) Bloom1 = plant(Bloom, maxb);
|
||||
|
||||
Bloom1 = min(Bloom1*(orig1+color), max(0.5*(colmx + orig1 - color),0.001*Bloom1));
|
||||
Bloom1 = 0.5*(Bloom1 + mix(Bloom1, mix(colmx*orig1, Bloom1, 0.5), 1.0-color));
|
||||
|
||||
Bloom1 = Bloom1 * mix(1.0, 2.0-colmx, bloom_dist);
|
||||
|
||||
color = color + abs(bloom) * Bloom1;
|
||||
color = pow(pow(color, vec3(mask_gamma/gamma_in)) + abs(bloom) * pow(Bloom1, vec3(mask_gamma/gamma_in)), vec3(gamma_in/mask_gamma));
|
||||
}
|
||||
|
||||
color = min(color, mix(one, cmask1, mclip));
|
||||
|
||||
|
@ -682,10 +719,25 @@ void main()
|
|||
if (halation > 0.01) {
|
||||
Bloom = mix(0.5*(Bloom + Bloom*Bloom), 0.75*Bloom*Bloom, colmx);
|
||||
color = color + 2.0*max((2.0*mix(maxb*maxb, maxb, colmx)-0.5*max(max(Ref.r,Ref.g),Ref.b)),0.25)*mix(1.0,w3,0.5*colmx)*mix(one,cmask,0.6)*Bloom*halation; }
|
||||
|
||||
else
|
||||
if (halation < -0.01) {
|
||||
float mbl = max(max(Bloom.r,Bloom.g),Bloom.b);
|
||||
Bloom = plant(Bloom + Ref + orig1 + Bloom*Bloom*Bloom, min(mbl*mbl,0.75));
|
||||
color = color + 2.0*mix(1.0,w3,0.5*colmx)*mix(one,cmask,0.5)*Bloom*(-halation); }
|
||||
|
||||
Glow = mix(Glow, 0.25*color, 0.7*colmx);
|
||||
if (glow >= 0.0) color = color + 0.5*Glow*glow; else { cmask*=cmask; cmask*=cmask; color = color + (-glow)*cmask*Glow; }
|
||||
if (smoothmask > 0.5) { w3 = mix(1.0, w3, smoothstep(0.3, 0.6, mx1)); color = max(min(color/w3, 1.0)*w3, min(color,color*(1.0-w3))); }
|
||||
|
||||
if (global.m_glow < 0.5) Glow = mix(Glow, 0.25*color, 0.7*colmx);
|
||||
else
|
||||
{
|
||||
vec3 gb = plant(orig1, 1.0);
|
||||
maxb = max(max(Glow.r,Glow.g),Glow.b);
|
||||
gb = mix(maxb*vec3(0.0, 0.0, 1.0), Glow, clamp(gb.r + gb.g - 0.375*gb.b,0.0,1.0));
|
||||
Glow = mix(0.75*Glow,5.0*plant(mix(gb,orig1, 0.5*sqrt(colmx)*abs(plant(Glow,1.0)-plant(orig1,1.0))), maxb), pow(colmx, 0.50/gamma_in));
|
||||
Glow = mix(Glow, 0.4*Glow, 1.0-colmx*colmx);
|
||||
}
|
||||
|
||||
if (glow >= 0.0 && global.m_glow < 0.5) color = color + 0.5*Glow*glow; else { cmask*=cmask; cmask*=cmask; color = color + abs(glow)*cmask*Glow; }
|
||||
|
||||
color = min(color, 1.0);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
Gaussian blur - horizontal pass, dynamic range, resizable
|
||||
|
||||
Copyright (C) 2020 guest(r) - guest.r@gmail.com
|
||||
Copyright (C) 2020-2022 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -29,10 +29,18 @@ layout(push_constant) uniform Push
|
|||
uint FrameCount;
|
||||
float SIZEH;
|
||||
float SIGMA_H;
|
||||
float m_glow;
|
||||
float m_glow_cutoff;
|
||||
} params;
|
||||
|
||||
#pragma parameter bogus_glow "[ GLOW PASS SETTINGS ]:" 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter m_glow " Ordinary Glow / Magic Glow" 0.0 0.0 1.0 1.0
|
||||
#define m_glow params.m_glow
|
||||
|
||||
#pragma parameter m_glow_cutoff " Magic Glow Cutoff" 0.12 0.0 0.4 0.01
|
||||
#define m_glow_cutoff params.m_glow_cutoff
|
||||
|
||||
#pragma parameter SIZEH " Horizontal Glow Radius" 6.0 1.0 50.0 1.0
|
||||
#define SIZEH params.SIZEH
|
||||
|
||||
|
@ -69,6 +77,12 @@ float gaussian(float x)
|
|||
return exp(-x*x*invsqrsigma);
|
||||
}
|
||||
|
||||
vec3 plant (vec3 tar, float r)
|
||||
{
|
||||
float t = max(max(tar.r,tar.g),tar.b) + 0.00001;
|
||||
return tar * r / t;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 SourceSize1 = params.OriginalSize;
|
||||
|
@ -86,6 +100,11 @@ void main()
|
|||
do
|
||||
{
|
||||
pixel = COMPAT_TEXTURE(LinearizePass, tex + n*dx).rgb;
|
||||
if (m_glow > 0.5)
|
||||
{
|
||||
pixel = max(pixel-m_glow_cutoff, 0.0);
|
||||
pixel = plant(pixel, max(max(max(pixel.r,pixel.g),pixel.b)-m_glow_cutoff,0.0));
|
||||
}
|
||||
w = gaussian(n+f);
|
||||
color = color + w * pixel;
|
||||
wsum = wsum + w;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
Interlacing
|
||||
|
||||
Copyright (C) 2020 guest(r) - guest.r@gmail.com
|
||||
Copyright (C) 2020 - 2022 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -34,7 +34,6 @@ layout(push_constant) uniform Push
|
|||
float iscans;
|
||||
float downsample_levelx;
|
||||
float downsample_levely;
|
||||
float prescalex;
|
||||
} params;
|
||||
|
||||
|
||||
|
@ -59,7 +58,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter iscan " Interlacing Scanline Effect" 0.20 0.0 1.0 0.05
|
||||
#define iscan params.iscan // interlacing effect scanlining
|
||||
|
||||
#pragma parameter intres " Internal Resolution Y: 224p/240p, 1.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with main pass, values must match
|
||||
#pragma parameter intres " Internal Resolution Y: 0.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with main pass, values must match
|
||||
|
||||
#define intres params.intres // interlace resolution
|
||||
|
||||
|
@ -69,9 +68,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter downsample_levely " Downsampling-Y (High-res content, pre-scalers)" 0.0 0.0 2.0 0.05
|
||||
#define downsample_levely params.downsample_levely // downsample level
|
||||
|
||||
#pragma parameter prescalex " Prescale-X Factor (for xBR...pre-shader)" 1.0 1.0 4.0 1.0 // Joint parameter with main pass, values must match
|
||||
#define prescalex params.prescalex // prescale-x factor
|
||||
|
||||
#pragma parameter iscans " Interlacing (Scanline) Saturation" 0.25 0.0 1.0 0.05
|
||||
#define iscans params.iscans // interlace saturation
|
||||
|
||||
|
@ -83,7 +79,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
Interlacing
|
||||
|
||||
Copyright (C) 2020 guest(r) - guest.r@gmail.com
|
||||
Copyright (C) 2020 - 2022 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -34,7 +34,6 @@ layout(push_constant) uniform Push
|
|||
float iscans;
|
||||
float downsample_levelx;
|
||||
float downsample_levely;
|
||||
float prescalex;
|
||||
} params;
|
||||
|
||||
|
||||
|
@ -59,7 +58,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter iscan " Interlacing Scanline Effect" 0.20 0.0 1.0 0.05
|
||||
#define iscan params.iscan // interlacing effect scanlining
|
||||
|
||||
#pragma parameter intres " Internal Resolution Y: 224p/240p, 1.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with main pass, values must match
|
||||
#pragma parameter intres " Internal Resolution Y: 0.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with main pass, values must match
|
||||
|
||||
#define intres params.intres // interlace resolution
|
||||
|
||||
|
@ -69,9 +68,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter downsample_levely " Downsampling-Y (High-res content, pre-scalers)" 0.0 0.0 3.0 0.05
|
||||
#define downsample_levely params.downsample_levely // downsample level
|
||||
|
||||
#pragma parameter prescalex " Prescale-X Factor (for xBR...pre-shader)" 1.0 1.0 4.0 1.0 // Joint parameter with main pass, values must match
|
||||
#define prescalex params.prescalex // prescale-x factor
|
||||
|
||||
#pragma parameter iscans " Interlacing (Scanline) Saturation" 0.25 0.0 1.0 0.05
|
||||
#define iscans params.iscans // interlace saturation
|
||||
|
||||
|
@ -83,7 +79,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
|
|
@ -73,7 +73,7 @@ layout(push_constant) uniform Push
|
|||
|
||||
#pragma parameter pre_bb " Brightness Adjustment" 1.0 0.0 2.0 0.01
|
||||
|
||||
#pragma parameter contr " Contrast Adjustment" 0.0 -1.0 1.0 0.05
|
||||
#pragma parameter contr " Contrast Adjustment" 0.0 -2.0 2.0 0.05
|
||||
|
||||
#pragma parameter sega_fix " Sega Brightness Fix" 0.0 0.0 1.0 1.0
|
||||
|
||||
|
@ -236,12 +236,11 @@ vec3 plant (vec3 tar, float r)
|
|||
}
|
||||
|
||||
float contrast(float x)
|
||||
{
|
||||
float y = 2.0*x-1.0;
|
||||
y = (sin(y*1.57079632679)+1.0)*0.5;
|
||||
return mix(x, y, params.contr);
|
||||
{
|
||||
return max(mix(x, smoothstep(0.0, 1.0, x), params.contr),0.0);
|
||||
}
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 imgColor = COMPAT_TEXTURE(StockPass, vTexCoord.xy);
|
||||
|
@ -345,10 +344,8 @@ void main()
|
|||
color = plant(color, contrast(max(max(color.r,color.g),color.b)));
|
||||
|
||||
p = 2.2;
|
||||
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
color = pow(color, vec3(p));
|
||||
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
|
||||
vec3 warmer = D65_to_D55*color;
|
||||
warmer = ToSRGB*warmer;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
Gaussian blur - horizontal pass, dynamic range, resizable
|
||||
|
||||
Copyright (C) 2021 guest(r) - guest.r@gmail.com
|
||||
Copyright (C) 2020 - 2022 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -29,6 +29,7 @@ layout(push_constant) uniform Push
|
|||
uint FrameCount;
|
||||
float SIZEHB;
|
||||
float SIGMA_HB;
|
||||
float BLOOMCUT_H;
|
||||
} params;
|
||||
|
||||
#pragma parameter bogus_glow "[ GLOW/BLOOM PASS SETTINGS ]:" 0.0 0.0 1.0 1.0
|
||||
|
@ -39,6 +40,9 @@ layout(push_constant) uniform Push
|
|||
#pragma parameter SIGMA_HB " Horizontal Bloom/Halation/Glow Sigma" 1.0 0.25 15.0 0.05
|
||||
#define SIGMA_HB params.SIGMA_HB
|
||||
|
||||
#pragma parameter BLOOMCUT_H " Horizontal Bloom/Halation/(Glow) Substract" 0.0 0.0 0.5 0.01
|
||||
#define BLOOMCUT_H params.BLOOMCUT_H
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
|
@ -86,7 +90,7 @@ void main()
|
|||
do
|
||||
{
|
||||
pixel = COMPAT_TEXTURE(LinearizePass, tex + n*dx);
|
||||
w = gaussian(n+f);
|
||||
w = max(gaussian(n+f) - BLOOMCUT_H, 0.0);
|
||||
pixel.a = max(max(pixel.r, pixel.g),pixel.b);
|
||||
pixel.a*=pixel.a*pixel.a;
|
||||
color = color + w * pixel;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
Gaussian blur - vertical pass, dynamic range, resizable
|
||||
|
||||
Copyright (C) 2020 guest(r) - guest.r@gmail.com
|
||||
Copyright (C) 2020 - 2022 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -30,6 +30,7 @@ layout(push_constant) uniform Push
|
|||
uint FrameCount;
|
||||
float SIZEVB;
|
||||
float SIGMA_VB;
|
||||
float BLOOMCUT_V;
|
||||
} params;
|
||||
|
||||
|
||||
|
@ -39,6 +40,9 @@ layout(push_constant) uniform Push
|
|||
#pragma parameter SIGMA_VB " Vertical Bloom/Halation/Glow Sigma" 1.0 0.25 15.0 0.05
|
||||
#define SIGMA_VB params.SIGMA_VB
|
||||
|
||||
#pragma parameter BLOOMCUT_V " Vertical Bloom/Halation/(Glow) Substract" 0.0 0.0 0.5 0.01
|
||||
#define BLOOMCUT_V params.BLOOMCUT_V
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
|
@ -87,7 +91,7 @@ void main()
|
|||
do
|
||||
{
|
||||
pixel = COMPAT_TEXTURE(Source, tex + n*dy);
|
||||
w = gaussian(n+f);
|
||||
w = max(gaussian(n+f) - BLOOMCUT_V, 0.0);
|
||||
pixel.a*=pixel.a*pixel.a;
|
||||
color = color + w * pixel;
|
||||
wsum = wsum + w;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
CRT - Guest - Advanced - Fast - Pass1
|
||||
|
||||
Copyright (C) 2018-2021 guest(r) - guest.r@gmail.com
|
||||
Copyright (C) 2018-2022 guest(r) - guest.r@gmail.com
|
||||
|
||||
Incorporates many good ideas and suggestions from Dr. Venom.
|
||||
I would also like give thanks to many Libretro forums members for continuous feedback, suggestions and caring about the shader.
|
||||
|
@ -31,7 +31,6 @@ layout(push_constant) uniform Push
|
|||
vec4 OutputSize;
|
||||
uint FrameCount;
|
||||
float IOS, h_sharp, s_sharp, spike, ring;
|
||||
float prescalex;
|
||||
} params;
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
|
@ -45,7 +44,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter h_sharp " Horizontal sharpness" 5.20 0.20 15.0 0.10
|
||||
#define h_sharp params.h_sharp // pixel sharpness
|
||||
|
||||
#pragma parameter s_sharp " Substractive sharpness (1.0 recommended)" 0.50 0.0 1.5 0.10
|
||||
#pragma parameter s_sharp " Substractive sharpness (1.0 recommended)" 0.50 0.0 2.0 0.10
|
||||
#define s_sharp params.s_sharp // substractive sharpness
|
||||
|
||||
#pragma parameter ring " Substractive sharpness Ringing" 0.0 0.0 3.0 0.05
|
||||
|
@ -54,8 +53,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter spike " Scanline Spike Removal" 1.0 0.0 2.0 0.10
|
||||
#define spike params.spike
|
||||
|
||||
#pragma parameter prescalex " Prescale-X Factor (for xBR...pre-shader)" 1.0 1.0 4.0 1.0 // Joint parameter with linearize pass, values must match
|
||||
#define prescalex params.prescalex // prescale-x factor
|
||||
|
||||
#define COMPAT_TEXTURE(c,d) texture(c,d)
|
||||
#define TEX0 vTexCoord
|
||||
|
@ -71,7 +68,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -82,9 +79,12 @@ layout(set = 0, binding = 2) uniform sampler2D LinearizePass;
|
|||
|
||||
void main()
|
||||
{
|
||||
vec4 SourceSize = params.OriginalSize * vec4(prescalex, 1.0, 1.0/prescalex, 1.0);
|
||||
vec2 prescalex = vec2(textureSize(LinearizePass, 0)) / params.OriginalSize.xy;
|
||||
|
||||
vec4 SourceSize = params.OriginalSize * vec4(prescalex.x, prescalex.y, 1.0/prescalex.x, 1.0/prescalex.y);
|
||||
|
||||
float intera = COMPAT_TEXTURE(LinearizePass, vec2(0.75,0.25)).a;
|
||||
bool interb = (intera < 0.5);
|
||||
|
||||
// Calculating texel coordinates
|
||||
|
||||
|
@ -108,7 +108,7 @@ void main()
|
|||
float zero = exp2(-h_sharp);
|
||||
float sharp1 = s_sharp * zero;
|
||||
|
||||
float fdivider = min(prescalex, 2.0);
|
||||
float fdivider = max(min(prescalex.x, 2.0), 1.5*float(interb));
|
||||
|
||||
float wl3 = (2.0 + fpx)/fdivider;
|
||||
float wl2 = (1.0 + fpx)/fdivider;
|
||||
|
@ -128,8 +128,8 @@ void main()
|
|||
|
||||
float twl3 = max(wl3 - sharp1, 0.0);
|
||||
float twl2 = max(wl2 - sharp1, mix(-0.12, 0.0, 1.0-fp1*fp1));
|
||||
float twl1 = max(wl1 - sharp1, 0.0);
|
||||
float twr1 = max(wr1 - sharp1, 0.0);
|
||||
float twl1 = max(wl1 - sharp1, -0.12);
|
||||
float twr1 = max(wr1 - sharp1, -0.12);
|
||||
float twr2 = max(wr2 - sharp1, mix(-0.12, 0.0, 1.0-fpx*fpx));
|
||||
float twr3 = max(wr3 - sharp1, 0.0);
|
||||
|
||||
|
@ -159,8 +159,8 @@ void main()
|
|||
float rm2 = max(max(r2.r,r2.g),r2.b);
|
||||
|
||||
float swl2 = max(twl2, 0.0) * (dot(l2,luma) + ts);
|
||||
float swl1 = twl1 * (dot(l1,luma) + ts);
|
||||
float swr1 = twr1 * (dot(r1,luma) + ts);
|
||||
float swl1 = max(twl1, 0.0) * (dot(l1,luma) + ts);
|
||||
float swr1 = max(twr1, 0.0) * (dot(r1,luma) + ts);
|
||||
float swr2 = max(twr2, 0.0) * (dot(r2,luma) + ts);
|
||||
|
||||
float fscolor1 = (lm2*swl2 + lm1*swl1 + rm1*swr1 + rm2*swr2)/(swl2+swl1+swr1+swr2);
|
||||
|
|
|
@ -44,7 +44,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter h_sharp " Horizontal sharpness" 5.20 0.20 15.0 0.10
|
||||
#define h_sharp params.h_sharp // pixel sharpness
|
||||
|
||||
#pragma parameter s_sharp " Substractive sharpness (1.0 recommended)" 0.50 0.0 1.5 0.10
|
||||
#pragma parameter s_sharp " Substractive sharpness (1.0 recommended)" 0.50 0.0 2.0 0.10
|
||||
#define s_sharp params.s_sharp // substractive sharpness
|
||||
|
||||
#pragma parameter ring " Substractive sharpness Ringing" 0.0 0.0 3.0 0.05
|
||||
|
@ -68,7 +68,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -116,8 +116,8 @@ void main()
|
|||
float fp1 = 1.-fpx;
|
||||
|
||||
float twl2 = max(wl2 - sharp1, mix(-0.12, 0.0, 1.0-fp1*fp1));
|
||||
float twl1 = max(wl1 - sharp1, 0.0);
|
||||
float twr1 = max(wr1 - sharp1, 0.0);
|
||||
float twl1 = max(wl1 - sharp1, -0.12);
|
||||
float twr1 = max(wr1 - sharp1, -0.12);
|
||||
float twr2 = max(wr2 - sharp1, mix(-0.12, 0.0, 1.0-fpx*fpx));
|
||||
|
||||
bool sharp = (sharp1 > 0.0);
|
||||
|
@ -144,8 +144,8 @@ void main()
|
|||
float rm2 = max(max(r2.r,r2.g),r2.b);
|
||||
|
||||
float swl2 = max(twl2, 0.0) * (dot(l2,luma) + ts);
|
||||
float swl1 = twl1 * (dot(l1,luma) + ts);
|
||||
float swr1 = twr1 * (dot(r1,luma) + ts);
|
||||
float swl1 = max(twl1, 0.0) * (dot(l1,luma) + ts);
|
||||
float swr1 = max(twr1, 0.0) * (dot(r1,luma) + ts);
|
||||
float swr2 = max(twr2, 0.0) * (dot(r2,luma) + ts);
|
||||
|
||||
float fscolor1 = (lm2*swl2 + lm1*swl1 + rm1*swr1 + rm2*swr2)/(swl2+swl1+swr1+swr2);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
layout(push_constant) uniform Push
|
||||
{
|
||||
float brightboost, brightboost1, gsl, scanline1, scanline2, beam_min, beam_max, beam_size,
|
||||
glow, vertmask, maskstr, inters, bloom, halation, scans, gamma_c, gamma_out, IOS;
|
||||
glow, vertmask, maskstr, inters, bloom, halation, scans, gamma_c, gamma_out, IOS, no_scanlines;
|
||||
} params;
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
|
@ -56,7 +56,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
|
||||
#pragma parameter bogus_screen "[ SCREEN OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter intres " Internal Resolution Y: 224p/240p, 1.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with linearize pass, values must match
|
||||
#pragma parameter intres " Internal Resolution Y: 0.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with linearize pass, values must match
|
||||
|
||||
#pragma parameter IOS " Integer Scaling: Odd:Y, Even:'X'+Y" 0.0 0.0 4.0 1.0
|
||||
#define IOS params.IOS // Smart Integer Scaling
|
||||
|
@ -105,10 +105,10 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter bloom_dist " Bloom Distribution" 0.0 0.0 3.0 0.05
|
||||
#define bloom_dist global.bloom_dist // bloom effect distribution
|
||||
|
||||
#pragma parameter halation " Halation Strength" 0.0 0.0 2.0 0.025
|
||||
#pragma parameter halation " Halation Strength" 0.0 -2.0 2.0 0.025
|
||||
#define halation params.halation // halation effect
|
||||
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.02
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.025
|
||||
#define gamma_c params.gamma_c // adjust brightness
|
||||
|
||||
#pragma parameter brightboost " Bright Boost Dark Pixels" 1.40 0.25 10.0 0.05
|
||||
|
@ -125,10 +125,10 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter scanline1 " Scanline Beam Shape Center" 6.0 -20.0 20.0 0.5
|
||||
#define scanline1 params.scanline1 // scanline param, vertical sharpness
|
||||
|
||||
#pragma parameter scanline2 " Scanline Beam Shape Edges" 8.0 3.0 70.0 1.0
|
||||
#pragma parameter scanline2 " Scanline Beam Shape Edges" 8.0 0.0 70.0 1.0
|
||||
#define scanline2 params.scanline2 // scanline param, vertical sharpness
|
||||
|
||||
#pragma parameter beam_min " Scanline Shape Dark Pixels" 1.30 0.25 5.0 0.05
|
||||
#pragma parameter beam_min " Scanline Shape Dark Pixels" 1.30 0.25 10.0 0.05
|
||||
#define beam_min params.beam_min // dark area beam min - narrow
|
||||
|
||||
#pragma parameter beam_max " Scanline Shape Bright Pixels" 1.00 0.4 3.5 0.025
|
||||
|
@ -140,13 +140,14 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter vertmask " Scanline Color Deconvergence" 0.0 -1.0 1.0 0.1
|
||||
#define vertmask params.vertmask // Scanline deconvergence colors
|
||||
|
||||
#pragma parameter scans " Scanline Saturation / Mask Falloff" 0.60 0.0 2.5 0.05
|
||||
#pragma parameter scans " Scanline Saturation / Mask Falloff" 0.50 -5.0 5.0 0.10
|
||||
#define scans params.scans // scanline saturation
|
||||
|
||||
#pragma parameter scan_falloff " Scanline Falloff" 1.0 0.25 2.0 0.05
|
||||
#pragma parameter scan_falloff " Scanline Falloff" 1.0 0.20 2.0 0.05
|
||||
#define scan_falloff global.scan_falloff // scanline falloff
|
||||
|
||||
|
||||
#pragma parameter no_scanlines " No-scanline mode" 0.0 0.0 1.0 1.0
|
||||
#define no_scanlines params.no_scanlines
|
||||
|
||||
#define COMPAT_TEXTURE(c,d) texture(c,d)
|
||||
#define TEX0 vTexCoord
|
||||
|
@ -162,7 +163,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -228,6 +229,8 @@ vec2 Warp(vec2 pos)
|
|||
|
||||
void main()
|
||||
{
|
||||
vec2 prescalex = vec2(textureSize(LinearizePass, 0)) / global.OriginalSize.xy;
|
||||
|
||||
vec4 SourceSize = vec4(global.SourceSize.x, global.OriginalSize.y, global.SourceSize.z, global.OriginalSize.w);
|
||||
float gamma_in = 1.0/COMPAT_TEXTURE(LinearizePass, vec2(0.25,0.25)).a;
|
||||
float intera = COMPAT_TEXTURE(LinearizePass, vec2(0.75,0.25)).a;
|
||||
|
@ -235,17 +238,16 @@ void main()
|
|||
|
||||
float SourceY = SourceSize.y;
|
||||
float sy = 1.0;
|
||||
if (global.intres == 0.5) sy = SourceY/224.0; else
|
||||
if (global.intres == 1.0) sy = SourceY/240.0; else
|
||||
if (global.intres > 1.25) sy = global.intres;
|
||||
SourceSize*=vec4(1.0, 1.0/sy, 1.0, sy);
|
||||
if (global.intres == 1.0) sy = SourceY/224.0;
|
||||
if (global.intres > 0.25 && global.intres != 1.0) sy = global.intres;
|
||||
SourceSize*=vec4(1.0, 1.0/sy, 1.0, sy);
|
||||
|
||||
// Calculating texel coordinates
|
||||
|
||||
vec2 texcoord = TEX0.xy;
|
||||
|
||||
if (IOS > 0.0 && !interb){
|
||||
vec2 ofactor = OutputSize.xy/SourceSize.xy;
|
||||
vec2 ofactor = OutputSize.xy/global.OriginalSize.xy;
|
||||
vec2 intfactor = (IOS < 2.5) ? floor(ofactor) : ceil(ofactor);
|
||||
vec2 diff = ofactor/intfactor;
|
||||
float scan = diff.y;
|
||||
|
@ -274,11 +276,15 @@ void main()
|
|||
pC4.x = pos.x;
|
||||
|
||||
if (interb) pC4.y = pos.y;
|
||||
|
||||
if (global.intres == 0.5 && prescalex.y < 1.5) pC4.y = floor(pC4.y * global.OriginalSize.y)*global.OriginalSize.w + 0.5*global.OriginalSize.w;
|
||||
|
||||
vec3 color1 = COMPAT_TEXTURE(Pass1, pC4 ).rgb;
|
||||
vec3 scolor1 = COMPAT_TEXTURE(Pass1, pC4 ).aaa;
|
||||
|
||||
pC4+=dy;
|
||||
|
||||
if (global.intres == 0.5 && prescalex.y < 1.5) pC4.y = floor((pos.y + 0.33*dy.y) * global.OriginalSize.y)*global.OriginalSize.w + 0.5*global.OriginalSize.w;
|
||||
|
||||
vec3 color2 = COMPAT_TEXTURE(Pass1, pC4 ).rgb;
|
||||
vec3 scolor2 = COMPAT_TEXTURE(Pass1, pC4 ).aaa;
|
||||
|
@ -324,16 +330,21 @@ if (!interb)
|
|||
float mc1 = max(max(color1.r,color1.g),color1.b) + eps;
|
||||
float mc2 = max(max(color2.r,color2.g),color2.b) + eps;
|
||||
|
||||
cref1 = color1 / mc1; cref1=cref1*cref1; cref1*=cref1;
|
||||
cref2 = color2 / mc2; cref2=cref2*cref2; cref2*=cref2;
|
||||
cref1 = color1 / mc1;
|
||||
cref2 = color2 / mc2;
|
||||
|
||||
w1 = max( mix(w1*mix(one, cref1, scans), w1, wf1*min((1.0+0.15*scans), 1.2)), 0.0); w1 = min(w1*color1, mc1)/(color1 + eps);
|
||||
w2 = max( mix(w2*mix(one, cref2, scans), w2, wf2*min((1.0+0.15*scans), 1.2)), 0.0); w2 = min(w2*color2, mc2)/(color2 + eps);
|
||||
float scanpow1 = (scans > 0.0) ? 1.0 : pow(f1, 0.375);
|
||||
float scanpow2 = (scans > 0.0) ? 1.0 : pow(f2, 0.375);
|
||||
w1 = pow(w1, mix(2.0*abs(scans).xxx + 1.0, 1.0.xxx, mix(1.0.xxx, cref1, scanpow1)));
|
||||
w2 = pow(w2, mix(2.0*abs(scans).xxx + 1.0, 1.0.xxx, mix(1.0.xxx, cref2, scanpow2)));
|
||||
|
||||
// Scanline Deconvergence
|
||||
|
||||
vec3 cd1 = one; vec3 cd2 = one; float vm = sqrt(abs(vertmask));
|
||||
vec3 cd1 = one; vec3 cd2 = one;
|
||||
|
||||
if (abs(vertmask) > 0.025)
|
||||
{
|
||||
float vm = sqrt(abs(vertmask));
|
||||
float v_high1 = 1.0 + 0.3*vm;
|
||||
float v_high2 = 1.0 + 0.6*vm;
|
||||
float v_low = 1.0 - vm;
|
||||
|
@ -351,8 +362,9 @@ if (!interb)
|
|||
cd1 = mix(one, vec3(v_high1, v_low, v_high1), ds1);
|
||||
cd2 = mix(one, vec3(v_low, v_high2, v_low), ds2);
|
||||
}
|
||||
}
|
||||
|
||||
color = gc(color1)*w1*cd1 + gc(color2)*w2*cd2;
|
||||
color = (gc(color1)*w1*cd1 + gc(color2)*w2*cd2)/mix(1.0.xxx, w1+w2, no_scanlines);
|
||||
color = min(color, 1.0);
|
||||
}
|
||||
|
||||
|
@ -361,7 +373,7 @@ if (!interb)
|
|||
color = gc(color1);
|
||||
}
|
||||
|
||||
float colmx = pow(max(max(ctmp.r,ctmp.g),ctmp.b), 1.40/gamma_in);
|
||||
float colmx = max(max(ctmp.r,ctmp.g),ctmp.b);
|
||||
|
||||
FragColor = vec4(color, colmx);
|
||||
}
|
||||
|
|
|
@ -48,10 +48,18 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
float bloom_dist;
|
||||
float mshift;
|
||||
float mask_layout;
|
||||
float maskboost;
|
||||
float no_scanlines;
|
||||
float intres;
|
||||
float fcompat;
|
||||
} global;
|
||||
|
||||
#pragma parameter fcompat " Compatibility Mode (slower, use if glitchy)" 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter bogus_screen "[ SCREEN OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter intres " Internal Resolution Y: 0.5...y-dowsample" 0.0 0.0 3.0 0.5 // Joint parameter with linearize pass, values must match
|
||||
|
||||
#pragma parameter IOS " Integer Scaling: Odd:Y, Even:'X'+Y" 0.0 0.0 4.0 1.0
|
||||
#define IOS params.IOS // Smart Integer Scaling
|
||||
|
||||
|
@ -84,7 +92,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter halation " Halation Strength" 0.0 0.0 1.0 0.025
|
||||
#define halation params.halation // halation effect
|
||||
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.02
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.025
|
||||
#define gamma_c params.gamma_c // adjust brightness
|
||||
|
||||
#pragma parameter brightboost " Bright Boost Dark Pixels" 1.40 0.25 10.0 0.05
|
||||
|
@ -101,10 +109,10 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter scanline1 " Scanline Beam Shape Center" 6.0 -20.0 20.0 0.5
|
||||
#define scanline1 params.scanline1 // scanline param, vertical sharpness
|
||||
|
||||
#pragma parameter scanline2 " Scanline Beam Shape Edges" 8.0 3.0 70.0 1.0
|
||||
#pragma parameter scanline2 " Scanline Beam Shape Edges" 8.0 0.0 70.0 1.0
|
||||
#define scanline2 params.scanline2 // scanline param, vertical sharpness
|
||||
|
||||
#pragma parameter beam_min " Scanline Shape Dark Pixels" 1.30 0.25 5.0 0.05
|
||||
#pragma parameter beam_min " Scanline Shape Dark Pixels" 1.30 0.25 10.0 0.05
|
||||
#define beam_min params.beam_min // dark area beam min - narrow
|
||||
|
||||
#pragma parameter beam_max " Scanline Shape Bright Pixels" 1.00 0.4 3.5 0.025
|
||||
|
@ -116,15 +124,18 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter vertmask " Scanline Color Deconvergence" 0.0 -1.0 1.0 0.1
|
||||
#define vertmask params.vertmask // Scanline deconvergence colors
|
||||
|
||||
#pragma parameter scans " Scanline Saturation / Mask Falloff" 0.60 0.0 3.5 0.05
|
||||
#pragma parameter scans " Scanline Saturation / Mask Falloff" 0.50 -5.0 5.0 0.10
|
||||
#define scans params.scans // scanline saturation
|
||||
|
||||
#pragma parameter scan_falloff " Scanline Falloff" 1.0 0.25 2.0 0.05
|
||||
#pragma parameter scan_falloff " Scanline Falloff" 1.0 0.20 2.0 0.05
|
||||
#define scan_falloff global.scan_falloff // scanline falloff
|
||||
|
||||
#pragma parameter no_scanlines " No-scanline mode" 0.0 0.0 1.0 1.0
|
||||
#define no_scanlines global.no_scanlines
|
||||
|
||||
#pragma parameter bogus_masks "[ CRT MASK OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter shadowMask " CRT Mask: 0:CGWG, 1-4:Lottes, 5-12:'Trinitron'" 0.0 -1.0 12.0 1.0
|
||||
#pragma parameter shadowMask " CRT Mask: 0:CGWG, 1-4:Lottes, 5-13:'Trinitron'" 0.0 -1.0 13.0 1.0
|
||||
#define shadowMask params.shadowMask // Mask Style
|
||||
|
||||
#pragma parameter maskstr " Mask Strength (0, 5-12)" 0.3 -0.5 1.0 0.025
|
||||
|
@ -133,6 +144,9 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter mcut " Mask 5-12 Low Strength" 1.10 0.0 2.0 0.05
|
||||
#define mcut params.mcut // Mask 5-12 dark color strength
|
||||
|
||||
#pragma parameter maskboost " CRT Mask Boost" 1.0 1.0 3.0 0.05
|
||||
#define maskboost global.maskboost // Mask Boost
|
||||
|
||||
#pragma parameter masksize " CRT Mask Size" 1.0 1.0 4.0 1.0
|
||||
#define masksize params.masksize // Mask Size
|
||||
|
||||
|
@ -142,7 +156,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter maskLight " Lottes maskLight" 1.5 0.0 2.0 0.05
|
||||
#define maskLight params.maskLight // Light "Phosphor"
|
||||
|
||||
#pragma parameter mshift " Mask Shift/Stagger" 0.0 -8.0 8.0 1.0
|
||||
#pragma parameter mshift " Mask Shift/Stagger" 0.0 -8.0 8.0 0.5
|
||||
#define mshift global.mshift // mask 'line' shift/stagger
|
||||
|
||||
#pragma parameter mask_layout " Mask Layout: RGB or BGR (check LCD panel) " 0.0 0.0 1.0 1.0
|
||||
|
@ -163,7 +177,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter slotms " Slot Mask Size" 1.0 1.0 4.0 1.0
|
||||
#define slotms params.slotms // Slot Mask Size
|
||||
|
||||
#pragma parameter mclip " Keep Mask effect with clipping" 0.50 0.0 1.0 0.05
|
||||
#pragma parameter mclip " Keep Mask effect with clipping" 0.0 0.0 1.0 0.05
|
||||
#define mclip params.mclip // Slot Mask Size
|
||||
|
||||
#pragma parameter bogus_deconvergence22 "[ HORIZONTAL DECONVERGENCE ]:" 0.0 0.0 1.0 1.0
|
||||
|
@ -186,7 +200,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#define COMPAT_TEXTURE(c,d) texture(c,d)
|
||||
#define TEX0 vTexCoord
|
||||
|
||||
#define SourceSize global.SourceSize
|
||||
#define OutputSize global.OutputSize
|
||||
#define gl_FragCoord (vTexCoord * OutputSize.xy)
|
||||
|
||||
|
@ -198,7 +211,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.000001;
|
||||
vTexCoord = TexCoord * 1.00000;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -246,14 +259,19 @@ vec3 Mask(vec2 pos, float mx)
|
|||
{
|
||||
vec2 pos0 = pos;
|
||||
pos.y = floor(pos.y/masksize);
|
||||
float next_line = float(fract(pos.y*0.5) > 0.25);
|
||||
pos0.x = pos0.x + next_line * mshift;
|
||||
float stagg_lvl = 1.0; if (fract(abs(mshift)) > 0.25 && abs(mshift) > 1.25) stagg_lvl = 2.0;
|
||||
float next_line = float(fract((pos.y/stagg_lvl)*0.5) > 0.25);
|
||||
pos0.x = (mshift > -0.25) ? (pos0.x + next_line * floor(mshift)) : (pos0.x + floor(pos.y / stagg_lvl) * floor(abs(mshift)));
|
||||
pos = floor(pos0/masksize);
|
||||
|
||||
vec3 mask = vec3(maskDark, maskDark, maskDark);
|
||||
vec3 one = vec3(1.0);
|
||||
float dark_compensate = mix(max( clamp( mix (mcut, maskstr, mx),0.0, 1.0) - 0.4, 0.0) + 1.0, 1.0, mx);
|
||||
float mc = 1.0 - max(maskstr, 0.0);
|
||||
|
||||
// brightness correcture masks 5-12
|
||||
float sm = 0.45; if(shadowMask == 8.0 || shadowMask == 11.0) sm = 0.7;
|
||||
float dark_compensate = mix(max( clamp( mix (mcut, maskstr, mx),0.0, 1.0) - sm, 0.0) + 1.0, 1.0, mx);
|
||||
|
||||
float mc = 1.0 - max(maskstr, 0.0);
|
||||
|
||||
// No mask
|
||||
if (shadowMask == -1.0)
|
||||
|
@ -413,25 +431,41 @@ vec3 Mask(vec2 pos, float mx)
|
|||
}
|
||||
|
||||
// RRGGBBX mask
|
||||
else
|
||||
else if (shadowMask == 12.0)
|
||||
{
|
||||
mask = vec3(0.0);
|
||||
pos.x = floor(mod(pos.x,7.0));
|
||||
if (pos.x < 1.0) mask = 0.0.xxx;
|
||||
else if (pos.x < 3.0) mask.r = 1.0;
|
||||
else if (pos.x < 5.0) mask.g = 1.0;
|
||||
if (pos.x < 0.5) mask = 0.0.xxx;
|
||||
else if (pos.x < 2.5) mask.r = 1.0;
|
||||
else if (pos.x < 4.5) mask.g = 1.0;
|
||||
else mask.b = 1.0;
|
||||
mask = clamp(mix( mix(one, mask, mcut), mix(one, mask, maskstr), mx), 0.0, 1.0) * dark_compensate;
|
||||
}
|
||||
mask = clamp(mix( mix(one, mask, mcut), mix(one, mask, maskstr), mx), 0.0, 1.0) * dark_compensate;
|
||||
}
|
||||
|
||||
// 4k mask
|
||||
else
|
||||
{
|
||||
mask = vec3(0.0);
|
||||
pos.x = floor(mod(pos.x,6.0));
|
||||
if (pos.x < 0.5) mask = 0.0.xxx;
|
||||
else if (pos.x < 1.5) mask.r = 1.0;
|
||||
else if (pos.x < 2.5) mask.rg = 1.0.xx;
|
||||
else if (pos.x < 3.5) mask.rgb = 1.0.xxx;
|
||||
else if (pos.x < 4.5) mask.gb = 1.0.xx;
|
||||
else mask.b = 1.0;
|
||||
mask = clamp(mix( mix(one, mask, mcut), mix(one, mask, maskstr), mx), 0.0, 1.0) * dark_compensate;
|
||||
}
|
||||
|
||||
return mask;
|
||||
float maskmin = min(min(mask.r,mask.g),mask.b);
|
||||
return (mask - maskmin) * maskboost + maskmin;
|
||||
}
|
||||
|
||||
float SlotMask(vec2 pos, float m)
|
||||
{
|
||||
if (slotmask == 0.0 && slotmask1 == 0.0) return 1.0;
|
||||
if ((slotmask + slotmask1) == 0.0) return 1.0;
|
||||
else
|
||||
{
|
||||
if (shadowMask == 2.0 || shadowMask == 6.0) pos.x = pos.x + 1.0;
|
||||
pos = floor(pos/slotms);
|
||||
float mlen = slotwidth*2.0;
|
||||
float px = fract(pos.x/mlen);
|
||||
|
@ -512,7 +546,7 @@ void main()
|
|||
vec2 texcoord = TEX0.xy;
|
||||
|
||||
if (IOS > 0.0 && !interb){
|
||||
vec2 ofactor = OutputSize.xy/SourceSize.xy;
|
||||
vec2 ofactor = OutputSize.xy/global.OriginalSize.xy;
|
||||
vec2 intfactor = (IOS < 2.5) ? floor(ofactor) : ceil(ofactor);
|
||||
vec2 diff = ofactor/intfactor;
|
||||
float scan = diff.y;
|
||||
|
@ -538,10 +572,18 @@ void main()
|
|||
bool frames = (floor(mod(float(global.FrameCount), refresh1)) == refresh2);
|
||||
bool not_same = (same2 + same3 + same4 + same5) > 0.25;
|
||||
|
||||
if ( not_same || frames || interb )
|
||||
if ( not_same || frames || interb || global.fcompat > 0.5)
|
||||
|
||||
{
|
||||
|
||||
vec4 SourceSize = global.OriginalSize;
|
||||
float SourceY = SourceSize.y;
|
||||
float sy = 1.0;
|
||||
if (global.intres == 1.0) sy = SourceY/224.0;
|
||||
if (global.intres > 0.25 && global.intres != 1.0) sy = global.intres;
|
||||
SourceSize*=vec4(1.0, 1.0/sy, 1.0, sy);
|
||||
|
||||
|
||||
float gamma_in = 1.0/COMPAT_TEXTURE(LinearizePass, vec2(0.25,0.25)).a;
|
||||
|
||||
// Calculating texel coordinates
|
||||
|
@ -564,6 +606,8 @@ if ( not_same || frames || interb )
|
|||
|
||||
pC4.y = floor(OGL2Pos) * ps.y + 0.5*ps.y;
|
||||
pC4.x = pos.x;
|
||||
|
||||
if (global.intres == 0.5) pC4.y = floor(pC4.y * global.OriginalSize.y)*global.OriginalSize.w + 0.5*global.OriginalSize.w;
|
||||
|
||||
if (interb) pC4.y = pos.y - inters * SourceSize.w;
|
||||
|
||||
|
@ -578,6 +622,8 @@ if ( not_same || frames || interb )
|
|||
|
||||
if (interb) pC4.y = pos.y + inters * SourceSize.w; else
|
||||
pC4+=dy;
|
||||
|
||||
if (global.intres == 0.5) pC4.y = floor((pos.y + 0.33*dy.y) * global.OriginalSize.y)*global.OriginalSize.w + 0.5*global.OriginalSize.w;
|
||||
|
||||
vec3 color2 = COMPAT_TEXTURE(Source, pC4 ).rgb;
|
||||
vec3 dcolor2 = color2;
|
||||
|
@ -630,16 +676,21 @@ if (!interb)
|
|||
float mc1 = max(max(color1.r,color1.g),color1.b) + eps;
|
||||
float mc2 = max(max(color2.r,color2.g),color2.b) + eps;
|
||||
|
||||
cref1 = color1 / mc1; cref1=cref1*cref1; cref1*=cref1;
|
||||
cref2 = color2 / mc2; cref2=cref2*cref2; cref2*=cref2;
|
||||
cref1 = color1 / mc1;
|
||||
cref2 = color2 / mc2;
|
||||
|
||||
w1 = max( mix(w1*mix(one, cref1, scans), w1, wf1*min((1.0+0.15*scans), 1.2)), 0.0); w1 = min(w1*color1, mc1)/(color1 + eps);
|
||||
w2 = max( mix(w2*mix(one, cref2, scans), w2, wf2*min((1.0+0.15*scans), 1.2)), 0.0); w2 = min(w2*color2, mc2)/(color2 + eps);
|
||||
float scanpow1 = (scans > 0.0) ? 1.0 : pow(f1, 0.33);
|
||||
float scanpow2 = (scans > 0.0) ? 1.0 : pow(f2, 0.33);
|
||||
w1 = pow(w1, mix(2.0*abs(scans).xxx + 1.0, 1.0.xxx, mix(1.0.xxx, cref1, scanpow1)));
|
||||
w2 = pow(w2, mix(2.0*abs(scans).xxx + 1.0, 1.0.xxx, mix(1.0.xxx, cref2, scanpow2)));
|
||||
|
||||
// Scanline Deconvergence
|
||||
|
||||
vec3 cd1 = one; vec3 cd2 = one; float vm = sqrt(abs(vertmask));
|
||||
|
||||
vec3 cd1 = one; vec3 cd2 = one;
|
||||
|
||||
if (abs(vertmask) > 0.025)
|
||||
{
|
||||
float vm = sqrt(abs(vertmask));
|
||||
float v_high1 = 1.0 + 0.3*vm;
|
||||
float v_high2 = 1.0 + 0.6*vm;
|
||||
float v_low = 1.0 - vm;
|
||||
|
@ -657,8 +708,9 @@ if (!interb)
|
|||
cd1 = mix(one, vec3(v_high1, v_low, v_high1), ds1);
|
||||
cd2 = mix(one, vec3(v_low, v_high2, v_low), ds2);
|
||||
}
|
||||
}
|
||||
|
||||
color = gc(color1)*w1*cd1 + gc(color2)*w2*cd2;
|
||||
color = (gc(color1)*w1*cd1 + gc(color2)*w2*cd2)/mix(1.0.xxx, w1+w2, no_scanlines);
|
||||
color = min(color, 1.0);
|
||||
}
|
||||
|
||||
|
@ -679,7 +731,7 @@ if (!interb)
|
|||
float smask = SlotMask(gl_FragCoord.xy * 1.000001, mx);
|
||||
cmask*= Mask(gl_FragCoord.xy * 1.000001, mx);
|
||||
|
||||
if (mask_layout > 0.5) cmask = cmask.rbg;
|
||||
if (mask_layout > 0.5) cmask = cmask.bgr;
|
||||
|
||||
color = color*cmask;
|
||||
color = min(color,1.0);
|
||||
|
@ -697,13 +749,14 @@ if (!interb)
|
|||
float maxb = max(max(Glow.r, Glow.g),Glow.b);
|
||||
Glow = pow(Glow, 1.4.xxx);
|
||||
vec3 Bloom = Glow;
|
||||
|
||||
|
||||
if(bloom > 0.025)
|
||||
{
|
||||
vec3 Bloom1 = min(Bloom*(orig1+color), max(0.5*(colmx + orig1 - color),0.0));
|
||||
Bloom1 = 0.5*(Bloom1 + mix(Bloom1, mix(colmx*orig1, Bloom1, 0.5), 1.0-color));
|
||||
|
||||
Bloom1 = Bloom1 * mix(1.0, 2.0-colmx, bloom_dist);
|
||||
|
||||
color = color + bloom * Bloom1;
|
||||
}
|
||||
|
||||
color = min(color, mix(one, cmask, mclip));
|
||||
if (!interb) color = declip(color, pow(w3,0.60));
|
||||
|
|
|
@ -64,6 +64,9 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
float dctypey;
|
||||
float post_br;
|
||||
float noisetype;
|
||||
float maskboost;
|
||||
float smoothmask;
|
||||
float gamma_c;
|
||||
} global;
|
||||
|
||||
|
||||
|
@ -81,18 +84,18 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter bloom_dist " Bloom Distribution" 0.0 0.0 3.0 0.05
|
||||
#define bloom_dist global.bloom_dist // bloom effect distribution
|
||||
|
||||
#pragma parameter halation " Halation Strength" 0.0 0.0 2.0 0.025
|
||||
#pragma parameter halation " Halation Strength" 0.0 -2.0 2.0 0.025
|
||||
#define halation global.halation // halation effect
|
||||
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.02
|
||||
#define gamma_c global.gamma_c // adjust brightness
|
||||
|
||||
#pragma parameter brightboost " Bright Boost Dark Pixels" 1.40 0.25 10.0 0.05
|
||||
#define brightboost params.brightboost // adjust brightness
|
||||
|
||||
#pragma parameter brightboost1 " Bright Boost Bright Pixels" 1.10 0.25 3.00 0.025
|
||||
#define brightboost1 params.brightboost1 // adjust brightness
|
||||
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.025
|
||||
#define gamma_c global.gamma_c // adjust brightness
|
||||
|
||||
#pragma parameter bogus_screen "[ SCREEN OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter IOS " Integer Scaling: Odd:Y, Even:'X'+Y" 0.0 0.0 4.0 1.0
|
||||
|
@ -130,7 +133,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
|
||||
#pragma parameter bogus_masks "[ CRT MASK OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter shadowMask " CRT Mask: 0:CGWG, 1-4:Lottes, 5-12:'Trinitron'" 0.0 -1.0 12.0 1.0
|
||||
#pragma parameter shadowMask " CRT Mask: 0:CGWG, 1-4:Lottes, 5-13:'Trinitron'" 0.0 -1.0 13.0 1.0
|
||||
#define shadowMask params.shadowMask // Mask Style
|
||||
|
||||
#pragma parameter maskstr " Mask Strength (0, 5-12)" 0.3 -0.5 1.0 0.025
|
||||
|
@ -139,6 +142,9 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter mcut " Mask 5-12 Low Strength" 1.10 0.0 2.0 0.05
|
||||
#define mcut params.mcut // Mask 5-12 dark color strength
|
||||
|
||||
#pragma parameter maskboost " CRT Mask Boost" 1.0 1.0 3.0 0.05
|
||||
#define maskboost global.maskboost // Mask Boost
|
||||
|
||||
#pragma parameter masksize " CRT Mask Size" 1.0 1.0 4.0 1.0
|
||||
#define masksize params.masksize // Mask Size
|
||||
|
||||
|
@ -148,7 +154,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter maskLight " Lottes maskLight" 1.5 0.0 2.0 0.05
|
||||
#define maskLight params.maskLight // Light "Phosphor"
|
||||
|
||||
#pragma parameter mshift " Mask Shift/Stagger" 0.0 -8.0 8.0 1.0
|
||||
#pragma parameter mshift " Mask Shift/Stagger" 0.0 -8.0 8.0 0.5
|
||||
#define mshift params.mshift // mask 'line' shift/stagger
|
||||
|
||||
#pragma parameter mask_layout " Mask Layout: RGB or BGR (check LCD panel) " 0.0 0.0 1.0 1.0
|
||||
|
@ -172,9 +178,12 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter slotms " Slot Mask Size" 1.0 1.0 4.0 1.0
|
||||
#define slotms global.slotms // Slot Mask Size
|
||||
|
||||
#pragma parameter mclip " Keep Mask effect with clipping" 0.50 0.0 1.0 0.05
|
||||
#pragma parameter mclip " Keep Mask effect with clipping" 0.0 0.0 1.0 0.05
|
||||
#define mclip global.mclip //
|
||||
|
||||
#pragma parameter smoothmask " Smooth Masks in bright scanlines" 0.0 0.0 1.0 1.0
|
||||
#define smoothmask global.smoothmask
|
||||
|
||||
#pragma parameter gamma_out "Gamma out" 2.4 1.0 5.0 0.05
|
||||
#define gamma_out global.gamma_out // output gamma
|
||||
|
||||
|
@ -222,7 +231,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -237,17 +246,22 @@ layout(set = 0, binding = 5) uniform sampler2D Source;
|
|||
|
||||
// Shadow mask (1-4 from PD CRT Lottes shader).
|
||||
|
||||
vec3 Mask(vec2 pos, float mx)
|
||||
vec3 Mask(vec2 pos, float mx, float mb)
|
||||
{
|
||||
vec2 pos0 = pos;
|
||||
pos.y = floor(pos.y/masksize);
|
||||
float next_line = float(fract(pos.y*0.5) > 0.25);
|
||||
pos0.x = (mshift > -0.25) ? (pos0.x + next_line * mshift) : (pos0.x + pos.y * mshift);
|
||||
float stagg_lvl = 1.0; if (fract(abs(mshift)) > 0.25 && abs(mshift) > 1.25) stagg_lvl = 2.0;
|
||||
float next_line = float(fract((pos.y/stagg_lvl)*0.5) > 0.25);
|
||||
pos0.x = (mshift > -0.25) ? (pos0.x + next_line * floor(mshift)) : (pos0.x + floor(pos.y / stagg_lvl) * floor(abs(mshift)));
|
||||
pos = floor(pos0/masksize);
|
||||
|
||||
vec3 mask = vec3(maskDark, maskDark, maskDark);
|
||||
vec3 one = vec3(1.0);
|
||||
float dark_compensate = mix(max( clamp( mix (mcut, maskstr, mx),0.0, 1.0) - 0.4, 0.0) + 1.0, 1.0, mx);
|
||||
|
||||
// brightness correcture masks 5-12
|
||||
float sm = 0.45; if(shadowMask == 8.0 || shadowMask == 11.0 || shadowMask == 13.0) sm = 0.7;
|
||||
float dark_compensate = mix(max( clamp( mix (mcut, maskstr, mx),0.0, 1.0) - sm, 0.0) + 1.0, 1.0, mx);
|
||||
|
||||
float mc = 1.0 - max(maskstr, 0.0);
|
||||
|
||||
// No mask
|
||||
|
@ -400,18 +414,33 @@ vec3 Mask(vec2 pos, float mx)
|
|||
}
|
||||
|
||||
// RRGGBBX mask
|
||||
else
|
||||
else if (shadowMask == 12.0)
|
||||
{
|
||||
mask = vec3(0.0);
|
||||
pos.x = floor(mod(pos.x,7.0));
|
||||
if (pos.x < 1.0) mask = 0.0.xxx;
|
||||
else if (pos.x < 3.0) mask.r = 1.0;
|
||||
else if (pos.x < 5.0) mask.g = 1.0;
|
||||
if (pos.x < 0.5) mask = 0.0.xxx;
|
||||
else if (pos.x < 2.5) mask.r = 1.0;
|
||||
else if (pos.x < 4.5) mask.g = 1.0;
|
||||
else mask.b = 1.0;
|
||||
mask = clamp(mix( mix(one, mask, mcut), mix(one, mask, maskstr), mx), 0.0, 1.0) * dark_compensate;
|
||||
}
|
||||
|
||||
// 4k mask
|
||||
else
|
||||
{
|
||||
mask = vec3(0.0);
|
||||
pos.x = floor(mod(pos.x,6.0));
|
||||
if (pos.x < 0.5) mask = 0.0.xxx;
|
||||
else if (pos.x < 1.5) mask.r = 1.0;
|
||||
else if (pos.x < 2.5) mask.rg = 1.0.xx;
|
||||
else if (pos.x < 3.5) mask.rgb = 1.0.xxx;
|
||||
else if (pos.x < 4.5) mask.gb = 1.0.xx;
|
||||
else mask.b = 1.0;
|
||||
mask = clamp(mix( mix(one, mask, mcut), mix(one, mask, maskstr), mx), 0.0, 1.0) * dark_compensate;
|
||||
}
|
||||
|
||||
return mask;
|
||||
float maskmin = min(min(mask.r,mask.g),mask.b);
|
||||
return (mask - maskmin) * (1.0 + (maskboost-1.0)*mb) + maskmin;
|
||||
}
|
||||
|
||||
float SlotMask(vec2 pos, float m)
|
||||
|
@ -419,6 +448,7 @@ float SlotMask(vec2 pos, float m)
|
|||
if ((slotmask + slotmask1) == 0.0) return 1.0;
|
||||
else
|
||||
{
|
||||
if (shadowMask == 2.0 || shadowMask == 6.0) pos.x = pos.x + 1.0;
|
||||
pos = floor(pos/slotms);
|
||||
float mlen = slotwidth*2.0;
|
||||
float px = fract(pos.x/mlen);
|
||||
|
@ -430,7 +460,7 @@ float SlotMask(vec2 pos, float m)
|
|||
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vec2 Warp(vec2 pos)
|
||||
{
|
||||
|
@ -484,6 +514,11 @@ vec3 declip(vec3 c, float b)
|
|||
return c;
|
||||
}
|
||||
|
||||
float igc(float mc)
|
||||
{
|
||||
return pow(mc, gamma_c);
|
||||
}
|
||||
|
||||
// noise function:
|
||||
// Dedicated to the public domain.
|
||||
// If you want a real license, you may consider this MIT/BSD/CC0/WTFPL-licensed (take your pick).
|
||||
|
@ -563,7 +598,7 @@ void main()
|
|||
vec2 texcoord = TEX0.xy;
|
||||
|
||||
if (IOS > 0.0 && !interb){
|
||||
vec2 ofactor = OutputSize.xy/SourceSize.xy;
|
||||
vec2 ofactor = OutputSize.xy/global.OriginalSize.xy;
|
||||
vec2 intfactor = (IOS < 2.5) ? floor(ofactor) : ceil(ofactor);
|
||||
vec2 diff = ofactor/intfactor;
|
||||
float scan = diff.y;
|
||||
|
@ -576,23 +611,31 @@ void main()
|
|||
vec2 pos1 = TEX0.xy;
|
||||
vec2 pos = Warp(texcoord);
|
||||
vec2 pos0 = Warp(TEX0.xy);
|
||||
vec3 color0 = COMPAT_TEXTURE(Source,pos1).rgb;
|
||||
float c0 = max(max(color0.r, color0.g),color0.b);
|
||||
|
||||
// color and bloom fetching
|
||||
vec3 color = COMPAT_TEXTURE(Source,pos1).rgb;
|
||||
vec3 Bloom = COMPAT_TEXTURE(BloomPass, pos).rgb;
|
||||
fetch_pixel(color, Bloom, pos1, pos);
|
||||
|
||||
if ((abs(global.deconrr) + abs(global.deconrry) + abs(global.deconrg) + abs(global.deconrgy) + abs(global.deconrb) + abs(global.deconrby)) > 0.2)
|
||||
fetch_pixel(color, Bloom, pos1, pos); // deconvergence
|
||||
|
||||
float cm = max(max(color.r,color.g),color.b);
|
||||
float cm = igc(max(max(color.r,color.g),color.b));
|
||||
float mx1 = COMPAT_TEXTURE(Source, pos1 ).a;
|
||||
float colmx = max(mx1, cm);
|
||||
float w3 = min((c0 + 0.0005) / (pow(colmx, gamma_in/1.4) + 0.0005), 1.0);
|
||||
float w3 = min((cm + 0.0001) / (colmx + 0.0005), 1.0);
|
||||
|
||||
vec2 dx = vec2(0.001, 0.0);
|
||||
float mx0 = COMPAT_TEXTURE(Source, pos1 - dx).a;
|
||||
float mx2 = COMPAT_TEXTURE(Source, pos1 + dx).a;
|
||||
float mx = max(max(mx0,mx1),max(mx2,cm));
|
||||
float mxg = max(max(mx0,mx1),max(mx2,cm));
|
||||
float mx = pow(mxg, 1.40/gamma_in);
|
||||
|
||||
// mask boost tweak
|
||||
|
||||
dx = vec2(global.OriginalSize.z, 0.0)*0.25;
|
||||
mx0 = COMPAT_TEXTURE(Source, pos1 - dx).a;
|
||||
mx2 = COMPAT_TEXTURE(Source, pos1 + dx).a;
|
||||
float mb = 1.0 - min(abs(mx0-mx2)/(0.5+mx1), 1.0);
|
||||
|
||||
vec3 one = vec3(1.0);
|
||||
|
||||
|
@ -604,33 +647,29 @@ void main()
|
|||
vec2 maskcoord = gl_FragCoord.xy * 1.000001;
|
||||
|
||||
float smask = SlotMask(maskcoord, mx);
|
||||
cmask*= Mask(maskcoord, mx);
|
||||
cmask*= Mask(maskcoord, mx, mb);
|
||||
|
||||
if (mask_layout > 0.5) cmask = cmask.rbg;
|
||||
if (mask_layout > 0.5) cmask = cmask.bgr;
|
||||
|
||||
cmask*=smask;
|
||||
vec3 cmask1 = cmask;
|
||||
float smask1 = smask;
|
||||
|
||||
if (mask_bloom > 0.025)
|
||||
{
|
||||
float maxb = max(max(Bloom.r,Bloom.g),Bloom.b);
|
||||
maxb = pow(sqrt(maxb*mix(maxb, colmx, 0.75)),0.275);
|
||||
vec3 mBloom = 0.5*(1.5*Bloom+0.5*maxb) * mix(1.0, 2.0-colmx, (bloom_dist + 0.5));
|
||||
float maskmx = 1.0; if (shadowMask > 0.5 || shadowMask < 4.5) maskmx = maskLight; else if (shadowMask > 6.5 && shadowMask < 10.5) maskmx = 1.0; else maskmx = max(max(cmask.r,cmask.g),cmask.b);
|
||||
cmask = min(cmask + maxb*mBloom*mask_bloom, maskmx);
|
||||
smask = min(smask + 0.9*maxb*max(max(mBloom.r,mBloom.g),mBloom.b)*mask_bloom, 1.0);
|
||||
float maxbl = max(max(max(Bloom.r,Bloom.g),Bloom.b), mxg);
|
||||
maxbl = maxbl * mix(1.0, 2.0-colmx, bloom_dist);
|
||||
cmask = max(min(cmask + maxbl*mask_bloom, 1.0), cmask);
|
||||
}
|
||||
|
||||
|
||||
color = pow(color, vec3(mask_gamma/gamma_in));
|
||||
color = color*cmask;
|
||||
color = min(color,1.0);
|
||||
color = color*smask;
|
||||
color = pow(color, vec3(gamma_in/mask_gamma));
|
||||
|
||||
cmask = min(cmask*smask, 1.0);
|
||||
cmask1 = min(cmask1*smask1, 1.0);
|
||||
cmask = min(cmask, 1.0);
|
||||
cmask1 = min(cmask1, 1.0);
|
||||
|
||||
float bb = mix(brightboost, brightboost1, colmx);
|
||||
float bb = mix(brightboost, brightboost1, mx);
|
||||
if (interb) bb = (abs(intera-0.5)<0.1) ? pow(0.80*bb, 0.65) : pow(bb, 0.70);
|
||||
color*=bb;
|
||||
|
||||
|
@ -641,14 +680,14 @@ void main()
|
|||
|
||||
vec3 Bloom1 = Bloom;
|
||||
|
||||
if (abs(bloom) > 0.025)
|
||||
{
|
||||
if (bloom < -0.01) Bloom1 = plant(Bloom, maxb);
|
||||
|
||||
Bloom1 = min(Bloom1*(orig1+color), max(0.5*(colmx + orig1 - color),0.001*Bloom1));
|
||||
Bloom1 = 0.5*(Bloom1 + mix(Bloom1, mix(colmx*orig1, Bloom1, 0.5), 1.0-color));
|
||||
|
||||
Bloom1 = Bloom1 * mix(1.0, 2.0-colmx, bloom_dist);
|
||||
|
||||
color = color + abs(bloom) * Bloom1;
|
||||
color = pow(pow(color, vec3(mask_gamma/gamma_in)) + abs(bloom) * pow(Bloom1, vec3(mask_gamma/gamma_in)), vec3(gamma_in/mask_gamma));
|
||||
}
|
||||
|
||||
color = min(color, mix(one, cmask1, mclip));
|
||||
|
||||
|
@ -657,6 +696,13 @@ void main()
|
|||
if (halation > 0.01) {
|
||||
Bloom = mix(0.5*(Bloom + Bloom*Bloom), 0.75*Bloom*Bloom, colmx);
|
||||
color = color + 2.0*max((2.0*mix(maxb*maxb, maxb, colmx)-0.5*max(max(Ref.r,Ref.g),Ref.b)),0.25)*mix(1.0,w3,0.5*colmx)*mix(one,cmask,0.6)*Bloom*halation; }
|
||||
else
|
||||
if (halation < 0.01) {
|
||||
float mbl = max(max(Bloom.r,Bloom.g),Bloom.b);
|
||||
Bloom = plant(Bloom + Ref + orig1 + Bloom*Bloom*Bloom, min(mbl*mbl,0.75));
|
||||
color = color + 2.0*mix(1.0,w3,0.5*colmx)*mix(one,cmask,0.5)*Bloom*(-halation); }
|
||||
|
||||
if (smoothmask > 0.5) { w3 = mix(1.0, w3, smoothstep(0.3, 0.6, mx1)); color = max(min(color/w3, 1.0)*w3, min(color,color*(1.0-w3))); }
|
||||
|
||||
Glow = mix(Glow, 0.25*color, 0.7*colmx);
|
||||
if (glow >= 0.0) color = color + 0.5*Glow*glow; else { cmask*=cmask; cmask*=cmask; color = color + (-glow)*cmask*Glow; }
|
||||
|
|
|
@ -34,7 +34,6 @@ layout(push_constant) uniform Push
|
|||
float iscans;
|
||||
float downsample_levelx;
|
||||
float downsample_levely;
|
||||
float prescalex;
|
||||
} params;
|
||||
|
||||
|
||||
|
@ -59,7 +58,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter iscan " Interlacing Scanline Effect" 0.20 0.0 1.0 0.05
|
||||
#define iscan params.iscan // interlacing effect scanlining
|
||||
|
||||
#pragma parameter intres " Internal Resolution Y: 224p/240p, 1.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with main pass, values must match
|
||||
#pragma parameter intres " Internal Resolution Y: 0.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with main pass, values must match
|
||||
|
||||
#define intres params.intres // interlace resolution
|
||||
|
||||
|
@ -69,9 +68,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter downsample_levely " Downsampling-Y (High-res content, pre-scalers)" 0.0 0.0 2.0 0.05
|
||||
#define downsample_levely params.downsample_levely // downsample level
|
||||
|
||||
#pragma parameter prescalex " Prescale-X Factor (for xBR...pre-shader)" 1.0 1.0 4.0 1.0 // Joint parameter with main pass, values must match
|
||||
#define prescalex params.prescalex // prescale-x factor
|
||||
|
||||
#pragma parameter iscans " Interlacing (Scanline) Saturation" 0.25 0.0 1.0 0.05
|
||||
#define iscans params.iscans // interlace saturation
|
||||
|
||||
|
@ -83,7 +79,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
Interlacing
|
||||
|
||||
Copyright (C) 2020 guest(r) - guest.r@gmail.com
|
||||
Copyright (C) 2020 - 2022 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -33,6 +33,7 @@ layout(push_constant) uniform Push
|
|||
float interm;
|
||||
float inters;
|
||||
float iscan;
|
||||
float intres;
|
||||
} params;
|
||||
|
||||
|
||||
|
@ -53,6 +54,9 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter interm " Interlace Mode: OFF, Normal 1-3, Interpolation 4-5" 1.0 0.0 5.0 1.0
|
||||
#define interm params.interm // interlace mode
|
||||
|
||||
#pragma parameter intres " Internal Resolution Y: 0.5...y-dowsample" 0.0 0.0 3.0 0.5 // Joint parameter with main pass, values must match
|
||||
#define intres params.intres // interlace resolution
|
||||
|
||||
#pragma parameter inters " Interlacing Effect Smoothness" 0.0 0.0 0.5 0.05 // // Joint parameter with main pass, values must match
|
||||
#define inters params.inters // interlacing effect smoothing
|
||||
|
||||
|
@ -68,7 +72,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -105,7 +109,9 @@ void main()
|
|||
|
||||
float r = m1;
|
||||
|
||||
if (inter <= params.OriginalSize.y && interm > 0.5)
|
||||
float yres_div = 1.0; if (intres > 1.25) yres_div = intres;
|
||||
|
||||
if (inter <= params.OriginalSize.y/yres_div && interm > 0.5 && intres != 1.0 && intres != 0.5)
|
||||
{
|
||||
intera = 0.25;
|
||||
float line_no = clamp(floor(mod(params.OriginalSize.y*vTexCoord.y, 2.0)), 0.0, 1.0);
|
||||
|
|
|
@ -66,7 +66,7 @@ layout(push_constant) uniform Push
|
|||
|
||||
#pragma parameter pre_bb " Brightness Adjustment" 1.0 0.0 2.0 0.01
|
||||
|
||||
#pragma parameter contr " Contrast Adjustment" 0.0 -1.0 1.0 0.05
|
||||
#pragma parameter contr " Contrast Adjustment" 0.0 -2.0 2.0 0.05
|
||||
|
||||
#define WP params.WP
|
||||
#define wp_saturation params.wp_saturation
|
||||
|
@ -227,10 +227,8 @@ vec3 plant (vec3 tar, float r)
|
|||
}
|
||||
|
||||
float contrast(float x)
|
||||
{
|
||||
float y = 2.0*x-1.0;
|
||||
y = (sin(y*1.57079632679)+1.0)*0.5;
|
||||
return mix(x, y, params.contr);
|
||||
{
|
||||
return max(mix(x, smoothstep(0.0, 1.0, x), params.contr),0.0);
|
||||
}
|
||||
|
||||
void main()
|
||||
|
@ -332,10 +330,8 @@ void main()
|
|||
color = plant(color, contrast(max(max(color.r,color.g),color.b)));
|
||||
|
||||
p = 2.2;
|
||||
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
color = pow(color, vec3(p));
|
||||
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
|
||||
vec3 warmer = D65_to_D55*color;
|
||||
warmer = ToSRGB*warmer;
|
||||
|
|
|
@ -40,6 +40,11 @@ layout(push_constant) uniform Push
|
|||
float contr;
|
||||
} params;
|
||||
|
||||
|
||||
#pragma parameter bogus_compat "[ COMPATIBILITY AND PERFORMANCE ]:" 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter fcompat " Compatibility Mode (slower, use if glitchy)" 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter bogus_color "[ COLOR TWEAKS ]:" 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter TNTC " LUT Colors: Trin.1 | Trin.2 | Nec Mult. | NTSC" 0.0 0.0 4.0 1.0
|
||||
|
@ -58,7 +63,7 @@ layout(push_constant) uniform Push
|
|||
|
||||
#pragma parameter pre_bb " Brightness Adjustment" 1.0 0.0 2.0 0.01
|
||||
|
||||
#pragma parameter contr " Contrast Adjustment" 0.0 -1.0 1.0 0.05
|
||||
#pragma parameter contr " Contrast Adjustment" 0.0 -2.0 2.0 0.05
|
||||
|
||||
#pragma parameter sega_fix " Sega Brightness Fix" 0.0 0.0 1.0 1.0
|
||||
|
||||
|
@ -155,10 +160,8 @@ vec3 plant (vec3 tar, float r)
|
|||
}
|
||||
|
||||
float contrast(float x)
|
||||
{
|
||||
float y = 2.0*x-1.0;
|
||||
y = (sin(y*1.57079632679)+1.0)*0.5;
|
||||
return mix(x, y, params.contr);
|
||||
{
|
||||
return max(mix(x, smoothstep(0.0, 1.0, x), params.contr),0.0);
|
||||
}
|
||||
|
||||
void main()
|
||||
|
@ -232,10 +235,8 @@ void main()
|
|||
color = plant(color, contrast(max(max(color.r,color.g),color.b)));
|
||||
|
||||
float p = 2.2;
|
||||
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
color = pow(color, vec3(p));
|
||||
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
|
||||
vec3 warmer = D65_to_D55*color;
|
||||
warmer = ToSRGB*warmer;
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
|
||||
layout(push_constant) uniform Push
|
||||
{
|
||||
vec4 SourceSize;
|
||||
vec4 OriginalSize;
|
||||
vec4 OutputSize;
|
||||
uint FrameCount;
|
||||
float PR, PG, PB;
|
||||
} params;
|
||||
|
||||
|
@ -30,11 +34,9 @@ layout(push_constant) uniform Push
|
|||
#pragma parameter internal_res " Internal Resolution" 1.0 1.0 8.0 0.10
|
||||
|
||||
#pragma parameter bogus_afterglow "[ AFTERGLOW SETTINGS ]:" 0.0 0.0 1.0 1.0
|
||||
#pragma parameter PR " Persistence Red" 0.32 0.0 0.50 0.01
|
||||
#pragma parameter PG " Persistence Green" 0.32 0.0 0.50 0.01
|
||||
#pragma parameter PB " Persistence Blue" 0.32 0.0 0.50 0.01
|
||||
#pragma parameter AS " Afterglow Strength" 0.20 0.0 0.60 0.01
|
||||
#pragma parameter sat " Afterglow saturation" 0.50 0.0 1.0 0.01
|
||||
#pragma parameter PR " Persistence Red" 0.32 0.0 0.50 0.01
|
||||
#pragma parameter PG " Persistence Green" 0.32 0.0 0.50 0.01
|
||||
#pragma parameter PB " Persistence Blue" 0.32 0.0 0.50 0.01
|
||||
|
||||
#define PR params.PR
|
||||
#define PG params.PG
|
||||
|
@ -69,11 +71,21 @@ layout(set = 0, binding = 3) uniform sampler2D AfterglowPassFeedback;
|
|||
|
||||
void main()
|
||||
{
|
||||
vec3 color = COMPAT_TEXTURE(OriginalHistory0, TEX0.xy).rgb;
|
||||
vec2 dx = vec2(params.OriginalSize.z, 0.0);
|
||||
vec2 dy = vec2(0.0, params.OriginalSize.w);
|
||||
|
||||
vec3 color0 = COMPAT_TEXTURE(OriginalHistory0, TEX0.xy).rgb;
|
||||
vec3 color1 = COMPAT_TEXTURE(OriginalHistory0, TEX0.xy - dx).rgb;
|
||||
vec3 color2 = COMPAT_TEXTURE(OriginalHistory0, TEX0.xy + dx).rgb;
|
||||
vec3 color3 = COMPAT_TEXTURE(OriginalHistory0, TEX0.xy - dy).rgb;
|
||||
vec3 color4 = COMPAT_TEXTURE(OriginalHistory0, TEX0.xy + dy).rgb;
|
||||
|
||||
vec3 color = (2.5 * color0 + color1 + color2 + color3 + color4)/6.5;
|
||||
|
||||
vec3 accumulate = COMPAT_TEXTURE(AfterglowPassFeedback, TEX0.xy).rgb;
|
||||
|
||||
float w = 1.0;
|
||||
if ((color.r + color.g + color.b < 5.0/255.0)) { w = 0.0; }
|
||||
if ((color0.r + color0.g + color0.b < 5.0/255.0)) { w = 0.0; }
|
||||
|
||||
vec3 result = mix( max(mix(color, accumulate, 0.49 + vec3(PR, PG, PB))- 2.0/255.0, 0.0), color, w);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
Gaussian blur - horizontal pass, dynamic range, resizable
|
||||
|
||||
Copyright (C) 2021 guest(r) - guest.r@gmail.com
|
||||
Copyright (C) 2020 - 2022 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -29,6 +29,7 @@ layout(push_constant) uniform Push
|
|||
uint FrameCount;
|
||||
float SIZEHB;
|
||||
float SIGMA_HB;
|
||||
float BLOOMCUT_H;
|
||||
} params;
|
||||
|
||||
#pragma parameter bogus_glow "[ GLOW/BLOOM PASS SETTINGS ]:" 0.0 0.0 1.0 1.0
|
||||
|
@ -39,6 +40,9 @@ layout(push_constant) uniform Push
|
|||
#pragma parameter SIGMA_HB " Horizontal Bloom/Halation/Glow Sigma" 1.0 0.25 15.0 0.05
|
||||
#define SIGMA_HB params.SIGMA_HB
|
||||
|
||||
#pragma parameter BLOOMCUT_H " Horizontal Bloom/Halation/(Glow) Substract" 0.0 0.0 0.5 0.01
|
||||
#define BLOOMCUT_H params.BLOOMCUT_H
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
|
@ -86,7 +90,7 @@ void main()
|
|||
do
|
||||
{
|
||||
pixel = COMPAT_TEXTURE(LinearizePass, tex + n*dx);
|
||||
w = gaussian(n+f);
|
||||
w = max(gaussian(n+f) - BLOOMCUT_H, 0.0);
|
||||
pixel.a = max(max(pixel.r, pixel.g),pixel.b);
|
||||
pixel.a*=pixel.a*pixel.a;
|
||||
color = color + w * pixel;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
Gaussian blur - vertical pass, dynamic range, resizable
|
||||
|
||||
Copyright (C) 2020 guest(r) - guest.r@gmail.com
|
||||
Copyright (C) 2020 - 2022 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -30,6 +30,7 @@ layout(push_constant) uniform Push
|
|||
uint FrameCount;
|
||||
float SIZEVB;
|
||||
float SIGMA_VB;
|
||||
float BLOOMCUT_V;
|
||||
} params;
|
||||
|
||||
|
||||
|
@ -39,6 +40,9 @@ layout(push_constant) uniform Push
|
|||
#pragma parameter SIGMA_VB " Vertical Bloom/Halation/Glow Sigma" 1.0 0.25 15.0 0.05
|
||||
#define SIGMA_VB params.SIGMA_VB
|
||||
|
||||
#pragma parameter BLOOMCUT_V " Vertical Bloom/Halation/(Glow) Substract" 0.0 0.0 0.5 0.01
|
||||
#define BLOOMCUT_V params.BLOOMCUT_V
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
{
|
||||
mat4 MVP;
|
||||
|
@ -87,7 +91,7 @@ void main()
|
|||
do
|
||||
{
|
||||
pixel = COMPAT_TEXTURE(Source, tex + n*dy);
|
||||
w = gaussian(n+f);
|
||||
w = max(gaussian(n+f) - BLOOMCUT_V, 0.0);
|
||||
pixel.a*=pixel.a*pixel.a;
|
||||
color = color + w * pixel;
|
||||
wsum = wsum + w;
|
||||
|
|
|
@ -35,8 +35,6 @@ layout(push_constant) uniform Push
|
|||
float S_SHARP;
|
||||
float HARNG;
|
||||
float HSHARP;
|
||||
float prescalex;
|
||||
float prescaley;
|
||||
float spike;
|
||||
float SIGMA_VER;
|
||||
float VSHARPNESS;
|
||||
|
@ -57,7 +55,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter internal_res " Internal Resolution" 1.0 1.0 8.0 0.10
|
||||
#define internal_res params.internal_res
|
||||
|
||||
#pragma parameter HSHARPNESS " Horizontal Filter Range" 1.0 1.0 8.0 0.25
|
||||
#pragma parameter HSHARPNESS " Horizontal Filter Range" 1.0 1.0 8.0 0.05
|
||||
#define HSHARPNESS params.HSHARPNESS
|
||||
|
||||
#pragma parameter SIGMA_HOR " Horizontal Blur Sigma" 0.50 0.1 7.0 0.025
|
||||
|
@ -74,7 +72,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
|
||||
#pragma parameter bogus_vfiltering "[ VERTICAL/INTERLACING FILTERING OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter VSHARPNESS " Vertical Filter Range" 1.0 1.0 8.0 0.25
|
||||
#pragma parameter VSHARPNESS " Vertical Filter Range" 1.0 1.0 8.0 0.05
|
||||
#define VSHARPNESS global.VSHARPNESS
|
||||
|
||||
#pragma parameter SIGMA_VER " Vertical Blur Sigma" 0.50 0.1 7.0 0.025
|
||||
|
@ -92,11 +90,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter spike " Scanline Spike Removal" 1.0 0.0 2.0 0.10
|
||||
#define spike params.spike
|
||||
|
||||
#pragma parameter prescalex " Prescale-X Factor (for xBR...pre-shader...)" 1.0 1.0 5.0 0.25 // Joint parameter with main pass, values must match
|
||||
#define prescalex params.prescalex // prescale-x factor
|
||||
|
||||
#pragma parameter prescaley " Prescale-Y Factor (for xBR...pre-shader...)" 1.0 1.0 5.0 0.25 // Joint parameter with Linearize Pass pass, values must match
|
||||
#define prescaley params.prescaley // prescale-y factor
|
||||
|
||||
#define COMPAT_TEXTURE(c,d) texture(c,d)
|
||||
#define TEX0 vTexCoord
|
||||
|
@ -112,7 +105,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -129,7 +122,9 @@ float gaussian(float x)
|
|||
|
||||
void main()
|
||||
{
|
||||
vec4 SourceSize = params.OriginalSize * vec4(prescalex, prescaley, 1.0/prescalex, 1.0/prescaley);
|
||||
vec2 prescalex = vec2(textureSize(LinearizePass, 0)) / params.OriginalSize.xy;
|
||||
|
||||
vec4 SourceSize = params.OriginalSize * vec4(prescalex.x, prescalex.y, 1.0/prescalex.x, 1.0/prescalex.y);
|
||||
|
||||
float f = fract(SourceSize.x * vTexCoord.x);
|
||||
f = 0.5 - f;
|
||||
|
@ -169,7 +164,7 @@ void main()
|
|||
w = gaussian(n+f) - sharp;
|
||||
fpx = abs(n+f-sign(n)*FPR)/FPR;
|
||||
if (abs(n) <= CLAMPSIZE) { cmax = max(cmax, pixel); cmin = min(cmin, pixel); }
|
||||
if (w < 0.0) w = clamp(w, mix(-maxsharp, 0.0, pow(fpx, HSHARP)), 0.0);
|
||||
if (w < 0.0) w = clamp(w, mix(-maxsharp, 0.0, pow(clamp(fpx,0.0,1.0), HSHARP)), 0.0);
|
||||
|
||||
color = color + w * pixel;
|
||||
wsum = wsum + w;
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
layout(push_constant) uniform Push
|
||||
{
|
||||
float IOS, brightboost, brightboost1, gsl, scanline1, scanline2, beam_min, beam_max, beam_size,
|
||||
glow, vertmask, inters, bloom, halation, scans, gamma_c;
|
||||
glow, vertmask, inters, bloom, halation, scans, gamma_c, no_scanlines;
|
||||
} params;
|
||||
|
||||
layout(std140, set = 0, binding = 0) uniform UBO
|
||||
|
@ -51,7 +51,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
float S_SHARPV;
|
||||
float VARNG;
|
||||
float VSHARP;
|
||||
float prescaley;
|
||||
float internal_res;
|
||||
float scangamma;
|
||||
float sborder;
|
||||
|
@ -63,7 +62,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
|
||||
#pragma parameter bogus_vfiltering "[ VERTICAL/INTERLACING FILTERING OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter VSHARPNESS " Vertical Filter Range" 1.0 1.0 8.0 0.25
|
||||
#pragma parameter VSHARPNESS " Vertical Filter Range" 1.0 1.0 8.0 0.05
|
||||
#define VSHARPNESS global.VSHARPNESS
|
||||
|
||||
#pragma parameter SIGMA_VER " Vertical Blur Sigma" 0.50 0.1 7.0 0.025
|
||||
|
@ -80,7 +79,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
|
||||
#pragma parameter bogus_screen "[ SCREEN OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter intres " Internal Resolution Y: 224p/240p, 1.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with linearize pass, values must match
|
||||
#pragma parameter intres " Internal Resolution Y: 0.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with linearize pass, values must match
|
||||
|
||||
#pragma parameter IOS " Integer Scaling: Odd:Y, Even:'X'+Y" 0.0 0.0 4.0 1.0
|
||||
#define IOS params.IOS // Smart Integer Scaling
|
||||
|
@ -129,10 +128,10 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter bloom_dist " Bloom Distribution" 0.0 0.0 3.0 0.05
|
||||
#define bloom_dist global.bloom_dist // bloom effect distribution
|
||||
|
||||
#pragma parameter halation " Halation Strength" 0.0 0.0 2.0 0.025
|
||||
#pragma parameter halation " Halation Strength" 0.0 -2.0 2.0 0.025
|
||||
#define halation params.halation // halation effect
|
||||
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.02
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.025
|
||||
#define gamma_c params.gamma_c // adjust brightness
|
||||
|
||||
#pragma parameter brightboost " Bright Boost Dark Pixels" 1.40 0.25 10.0 0.05
|
||||
|
@ -149,10 +148,10 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter scanline1 " Scanline Beam Shape Center" 6.0 -20.0 20.0 0.5
|
||||
#define scanline1 params.scanline1 // scanline param, vertical sharpness
|
||||
|
||||
#pragma parameter scanline2 " Scanline Beam Shape Edges" 8.0 3.0 70.0 1.0
|
||||
#pragma parameter scanline2 " Scanline Beam Shape Edges" 8.0 0.0 70.0 1.0
|
||||
#define scanline2 params.scanline2 // scanline param, vertical sharpness
|
||||
|
||||
#pragma parameter beam_min " Scanline Shape Dark Pixels" 1.20 0.25 5.0 0.05
|
||||
#pragma parameter beam_min " Scanline Shape Dark Pixels" 1.20 0.25 10.0 0.05
|
||||
#define beam_min params.beam_min // dark area beam min - narrow
|
||||
|
||||
#pragma parameter beam_max " Scanline Shape Bright Pixels" 1.00 0.4 3.5 0.025
|
||||
|
@ -164,17 +163,17 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter vertmask " Scanline Color Deconvergence" 0.0 -1.0 1.0 0.1
|
||||
#define vertmask params.vertmask // Scanline deconvergence colors
|
||||
|
||||
#pragma parameter scans " Scanline Saturation / Mask Falloff" 0.60 0.0 2.5 0.05
|
||||
#pragma parameter scans " Scanline Saturation / Mask Falloff" 0.50 -5.0 5.0 0.10
|
||||
#define scans params.scans // scanline saturation
|
||||
|
||||
#pragma parameter scan_falloff " Scanline Falloff" 1.0 0.25 2.0 0.05
|
||||
#pragma parameter scan_falloff " Scanline Falloff" 1.0 0.20 2.0 0.05
|
||||
#define scan_falloff global.scan_falloff // scanline falloff
|
||||
|
||||
#pragma parameter scangamma " Scanline Gamma" 2.40 0.5 5.0 0.05
|
||||
#define scangamma global.scangamma
|
||||
|
||||
#pragma parameter prescaley " Prescale-Y Factor (for xBR...pre-shader...)" 1.0 1.0 5.0 0.25 // Joint parameter with Linearize Pass pass, values must match
|
||||
#define prescaley global.prescaley // prescale-y factor
|
||||
#pragma parameter no_scanlines " No-scanline mode" 0.0 0.0 1.0 1.0
|
||||
#define no_scanlines params.no_scanlines
|
||||
|
||||
#pragma parameter internal_res " Internal Resolution" 1.0 1.0 8.0 0.10
|
||||
#define internal_res global.internal_res
|
||||
|
@ -193,7 +192,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -269,7 +268,7 @@ vec3 v_resample (vec2 tex0, vec4 Size) {
|
|||
float f = fract(Size.y * tex0.y);
|
||||
f = 0.5 - f;
|
||||
vec2 tex = tex0;
|
||||
tex.y = floor(Size.y *tex.y)*Size.w + 0.5*Size.w;
|
||||
tex.y = floor(Size.y * tex.y)*Size.w + 0.5*Size.w;
|
||||
vec3 color = 0.0.xxx;
|
||||
vec2 dy = vec2(0.0, Size.w);
|
||||
|
||||
|
@ -297,7 +296,7 @@ vec3 v_resample (vec2 tex0, vec4 Size) {
|
|||
w = gaussian(n+f) - sharp;
|
||||
fpx = abs(n+f-sign(n)*FPR)/FPR;
|
||||
if (abs(n) <= CLAMPSIZE) { cmax = max(cmax, pixel); cmin = min(cmin, pixel); }
|
||||
if (w < 0.0) w = clamp(w, mix(-maxsharp, 0.0, pow(fpx, VSHARP)), 0.0);
|
||||
if (w < 0.0) w = clamp(w, mix(-maxsharp, 0.0, pow(clamp(fpx,0.0,1.0), VSHARP)), 0.0);
|
||||
|
||||
color = color + w * pixel;
|
||||
wsum = wsum + w;
|
||||
|
@ -316,6 +315,8 @@ vec3 v_resample (vec2 tex0, vec4 Size) {
|
|||
|
||||
void main()
|
||||
{
|
||||
vec2 prescalex = vec2(textureSize(LinearizePass, 0)) / global.OriginalSize.xy;
|
||||
|
||||
vec4 SourceSize = vec4(global.SourceSize.x, global.OriginalSize.y, global.SourceSize.z, global.OriginalSize.w);
|
||||
float gamma_in = 1.0/COMPAT_TEXTURE(LinearizePass, vec2(0.25,0.25)).a;
|
||||
float intera = COMPAT_TEXTURE(LinearizePass, vec2(0.75,0.25)).a;
|
||||
|
@ -323,17 +324,16 @@ void main()
|
|||
|
||||
float SourceY = SourceSize.y;
|
||||
float sy = 1.0;
|
||||
if (global.intres == 0.5) sy = SourceY/224.0; else
|
||||
if (global.intres == 1.0) sy = SourceY/240.0; else
|
||||
if (global.intres > 1.25) sy = global.intres;
|
||||
SourceSize*=vec4(1.0, 1.0/sy, 1.0, sy);
|
||||
if (global.intres == 1.0) sy = SourceY/224.0;
|
||||
if (global.intres > 0.25 && global.intres != 1.0) sy = global.intres;
|
||||
SourceSize*=vec4(1.0, 1.0/sy, 1.0, sy);
|
||||
|
||||
// Calculating texel coordinates
|
||||
|
||||
vec2 texcoord = TEX0.xy;
|
||||
|
||||
if (IOS > 0.0 && !interb){
|
||||
vec2 ofactor = OutputSize.xy/SourceSize.xy;
|
||||
vec2 ofactor = OutputSize.xy/global.OriginalSize.xy;
|
||||
vec2 intfactor = (IOS < 2.5) ? floor(ofactor) : ceil(ofactor);
|
||||
vec2 diff = ofactor/intfactor;
|
||||
float scan = diff.y;
|
||||
|
@ -360,15 +360,21 @@ void main()
|
|||
|
||||
pC4.y = floor(OGL2Pos) * ps.y + 0.5*ps.y;
|
||||
pC4.x = pos.x;
|
||||
|
||||
if (global.intres == 0.5 && prescalex.y < 1.5) pC4.y = floor(pC4.y * global.OriginalSize.y)*global.OriginalSize.w + 0.5*global.OriginalSize.w;
|
||||
|
||||
vec3 color1 = COMPAT_TEXTURE(Pass1, pC4 ).rgb;
|
||||
vec3 scolor1 = COMPAT_TEXTURE(Pass1, pC4 ).aaa;
|
||||
|
||||
color1 = pow(color1, vec3(scangamma/gamma_in));
|
||||
|
||||
float prescaley = float(textureSize(LinearizePass, 0).y) / global.OriginalSize.y;
|
||||
|
||||
if (interb) color1 = v_resample(pos, SourceSize * vec4(1.0, prescaley, 1.0, 1.0/prescaley));
|
||||
|
||||
pC4+=dy;
|
||||
|
||||
if (global.intres == 0.5 && prescalex.y < 1.5) pC4.y = floor((pos.y + 0.33*dy.y) * global.OriginalSize.y)*global.OriginalSize.w + 0.5*global.OriginalSize.w;
|
||||
|
||||
vec3 color2 = COMPAT_TEXTURE(Pass1, pC4 ).rgb;
|
||||
vec3 scolor2 = COMPAT_TEXTURE(Pass1, pC4 ).aaa;
|
||||
|
@ -377,7 +383,7 @@ void main()
|
|||
|
||||
// calculating scanlines
|
||||
|
||||
vec3 ctmp = color1; vec3 mcolor = scolor1; float w3 = 1.0; vec3 color = color1;
|
||||
vec3 ctmp = color1; float w3 = 1.0; vec3 color = color1;
|
||||
vec3 one = vec3(1.0);
|
||||
|
||||
if (!interb)
|
||||
|
@ -416,16 +422,21 @@ if (!interb)
|
|||
float mc1 = max(max(color1.r,color1.g),color1.b) + eps;
|
||||
float mc2 = max(max(color2.r,color2.g),color2.b) + eps;
|
||||
|
||||
cref1 = color1 / mc1; cref1=cref1*cref1; cref1*=cref1;
|
||||
cref2 = color2 / mc2; cref2=cref2*cref2; cref2*=cref2;
|
||||
cref1 = color1 / mc1;
|
||||
cref2 = color2 / mc2;
|
||||
|
||||
w1 = max( mix(w1*mix(one, cref1, scans), w1, wf1*min((1.0+0.15*scans), 1.2)), 0.0); w1 = min(w1*color1, mc1)/(color1 + eps);
|
||||
w2 = max( mix(w2*mix(one, cref2, scans), w2, wf2*min((1.0+0.15*scans), 1.2)), 0.0); w2 = min(w2*color2, mc2)/(color2 + eps);
|
||||
float scanpow1 = (scans > 0.0) ? 1.0 : pow(f1, 0.375);
|
||||
float scanpow2 = (scans > 0.0) ? 1.0 : pow(f2, 0.375);
|
||||
w1 = pow(w1, mix(2.0*abs(scans).xxx + 1.0, 1.0.xxx, mix(1.0.xxx, cref1, scanpow1)));
|
||||
w2 = pow(w2, mix(2.0*abs(scans).xxx + 1.0, 1.0.xxx, mix(1.0.xxx, cref2, scanpow2)));
|
||||
|
||||
// Scanline Deconvergence
|
||||
|
||||
vec3 cd1 = one; vec3 cd2 = one; float vm = sqrt(abs(vertmask));
|
||||
vec3 cd1 = one; vec3 cd2 = one;
|
||||
|
||||
if (abs(vertmask) > 0.025)
|
||||
{
|
||||
float vm = sqrt(abs(vertmask));
|
||||
float v_high1 = 1.0 + 0.3*vm;
|
||||
float v_high2 = 1.0 + 0.6*vm;
|
||||
float v_low = 1.0 - vm;
|
||||
|
@ -443,8 +454,9 @@ if (!interb)
|
|||
cd1 = mix(one, vec3(v_high1, v_low, v_high1), ds1);
|
||||
cd2 = mix(one, vec3(v_low, v_high2, v_low), ds2);
|
||||
}
|
||||
}
|
||||
|
||||
color = gc(color1)*w1*cd1 + gc(color2)*w2*cd2;
|
||||
color = (gc(color1)*w1*cd1 + gc(color2)*w2*cd2)/mix(1.0.xxx, w1+w2, no_scanlines);
|
||||
color = min(color, 1.0);
|
||||
}
|
||||
|
||||
|
@ -453,7 +465,7 @@ if (!interb)
|
|||
color = gc(color1);
|
||||
}
|
||||
|
||||
float colmx = pow(max(max(ctmp.r,ctmp.g),ctmp.b), 1.40/gamma_in);
|
||||
float colmx = max(max(ctmp.r,ctmp.g),ctmp.b);
|
||||
|
||||
if (!interb) color = pow( color, vec3(gamma_in/scangamma) );
|
||||
|
||||
|
|
|
@ -66,7 +66,10 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
float deconrby;
|
||||
float dctypex;
|
||||
float dctypey;
|
||||
float post_br;
|
||||
float post_br;
|
||||
float maskboost;
|
||||
float smoothmask;
|
||||
float gamma_c;
|
||||
} global;
|
||||
|
||||
|
||||
|
@ -84,18 +87,18 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter bloom_dist " Bloom Distribution" 0.0 0.0 3.0 0.05
|
||||
#define bloom_dist global.bloom_dist // bloom effect distribution
|
||||
|
||||
#pragma parameter halation " Halation Strength" 0.0 0.0 2.0 0.025
|
||||
#pragma parameter halation " Halation Strength" 0.0 -2.0 2.0 0.025
|
||||
#define halation global.halation // halation effect
|
||||
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.02
|
||||
#define gamma_c global.gamma_c // adjust brightness
|
||||
|
||||
#pragma parameter brightboost " Bright Boost Dark Pixels" 1.40 0.25 10.0 0.05
|
||||
#define brightboost params.brightboost // adjust brightness
|
||||
|
||||
#pragma parameter brightboost1 " Bright Boost Bright Pixels" 1.10 0.25 3.00 0.025
|
||||
#define brightboost1 params.brightboost1 // adjust brightness
|
||||
|
||||
#pragma parameter gamma_c " Gamma correct" 1.0 0.50 2.0 0.025
|
||||
#define gamma_c global.gamma_c // adjust brightness
|
||||
|
||||
#pragma parameter bogus_screen "[ SCREEN OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter IOS " Integer Scaling: Odd:Y, Even:'X'+Y" 0.0 0.0 4.0 1.0
|
||||
|
@ -133,7 +136,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
|
||||
#pragma parameter bogus_masks "[ CRT MASK OPTIONS ]: " 0.0 0.0 1.0 1.0
|
||||
|
||||
#pragma parameter shadowMask " CRT Mask: 0:CGWG, 1-4:Lottes, 5-12:'Trinitron'" 0.0 -1.0 12.0 1.0
|
||||
#pragma parameter shadowMask " CRT Mask: 0:CGWG, 1-4:Lottes, 5-13:'Trinitron'" 0.0 -1.0 13.0 1.0
|
||||
#define shadowMask params.shadowMask // Mask Style
|
||||
|
||||
#pragma parameter maskstr " Mask Strength (0, 5-12)" 0.3 -0.5 1.0 0.025
|
||||
|
@ -142,6 +145,9 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter mcut " Mask 5-12 Low Strength" 1.10 0.0 2.0 0.05
|
||||
#define mcut params.mcut // Mask 5-12 dark color strength
|
||||
|
||||
#pragma parameter maskboost " CRT Mask Boost" 1.0 1.0 3.0 0.05
|
||||
#define maskboost global.maskboost // Mask Boost
|
||||
|
||||
#pragma parameter masksize " CRT Mask Size" 1.0 1.0 4.0 1.0
|
||||
#define masksize params.masksize // Mask Size
|
||||
|
||||
|
@ -151,7 +157,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter maskLight " Lottes maskLight" 1.5 0.0 2.0 0.05
|
||||
#define maskLight params.maskLight // Light "Phosphor"
|
||||
|
||||
#pragma parameter mshift " Mask Shift/Stagger" 0.0 -8.0 8.0 1.0
|
||||
#pragma parameter mshift " Mask Shift/Stagger" 0.0 -8.0 8.0 0.5
|
||||
#define mshift params.mshift // mask 'line' shift/stagger
|
||||
|
||||
#pragma parameter mask_layout " Mask Layout: RGB or BGR (check LCD panel) " 0.0 0.0 1.0 1.0
|
||||
|
@ -175,9 +181,12 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter slotms " Slot Mask Size" 1.0 1.0 4.0 1.0
|
||||
#define slotms global.slotms // Slot Mask Size
|
||||
|
||||
#pragma parameter mclip " Keep Mask effect with clipping" 0.50 0.0 1.0 0.05
|
||||
#pragma parameter mclip " Keep Mask effect with clipping" 0.0 0.0 1.0 0.05
|
||||
#define mclip global.mclip //
|
||||
|
||||
#pragma parameter smoothmask " Smooth Masks in bright scanlines" 0.0 0.0 1.0 1.0
|
||||
#define smoothmask global.smoothmask
|
||||
|
||||
#pragma parameter gamma_out "Gamma out" 1.75 1.0 5.0 0.05
|
||||
#define gamma_out global.gamma_out // output gamma
|
||||
|
||||
|
@ -225,7 +234,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
@ -240,17 +249,22 @@ layout(set = 0, binding = 5) uniform sampler2D Source;
|
|||
|
||||
// Shadow mask (1-4 from PD CRT Lottes shader).
|
||||
|
||||
vec3 Mask(vec2 pos, float mx)
|
||||
vec3 Mask(vec2 pos, float mx, float mb)
|
||||
{
|
||||
vec2 pos0 = pos;
|
||||
pos.y = floor(pos.y/masksize);
|
||||
float next_line = float(fract(pos.y*0.5) > 0.25);
|
||||
pos0.x = (mshift > -0.25) ? (pos0.x + next_line * mshift) : (pos0.x + pos.y * mshift);
|
||||
float stagg_lvl = 1.0; if (fract(abs(mshift)) > 0.25 && abs(mshift) > 1.25) stagg_lvl = 2.0;
|
||||
float next_line = float(fract((pos.y/stagg_lvl)*0.5) > 0.25);
|
||||
pos0.x = (mshift > -0.25) ? (pos0.x + next_line * floor(mshift)) : (pos0.x + floor(pos.y / stagg_lvl) * floor(abs(mshift)));
|
||||
pos = floor(pos0/masksize);
|
||||
|
||||
vec3 mask = vec3(maskDark, maskDark, maskDark);
|
||||
vec3 one = vec3(1.0);
|
||||
float dark_compensate = mix(max( clamp( mix (mcut, maskstr, mx),0.0, 1.0) - 0.4, 0.0) + 1.0, 1.0, mx);
|
||||
|
||||
// brightness correcture masks 5-12
|
||||
float sm = 0.45; if(shadowMask == 8.0 || shadowMask == 11.0 || shadowMask == 13.0) sm = 0.7;
|
||||
float dark_compensate = mix(max( clamp( mix (mcut, maskstr, mx),0.0, 1.0) - sm, 0.0) + 1.0, 1.0, mx);
|
||||
|
||||
float mc = 1.0 - max(maskstr, 0.0);
|
||||
|
||||
// No mask
|
||||
|
@ -403,18 +417,33 @@ vec3 Mask(vec2 pos, float mx)
|
|||
}
|
||||
|
||||
// RRGGBBX mask
|
||||
else
|
||||
else if (shadowMask == 12.0)
|
||||
{
|
||||
mask = vec3(0.0);
|
||||
pos.x = floor(mod(pos.x,7.0));
|
||||
if (pos.x < 1.0) mask = 0.0.xxx;
|
||||
else if (pos.x < 3.0) mask.r = 1.0;
|
||||
else if (pos.x < 5.0) mask.g = 1.0;
|
||||
if (pos.x < 0.5) mask = 0.0.xxx;
|
||||
else if (pos.x < 2.5) mask.r = 1.0;
|
||||
else if (pos.x < 4.5) mask.g = 1.0;
|
||||
else mask.b = 1.0;
|
||||
mask = clamp(mix( mix(one, mask, mcut), mix(one, mask, maskstr), mx), 0.0, 1.0) * dark_compensate;
|
||||
}
|
||||
|
||||
// 4k mask
|
||||
else
|
||||
{
|
||||
mask = vec3(0.0);
|
||||
pos.x = floor(mod(pos.x,6.0));
|
||||
if (pos.x < 0.5) mask = 0.0.xxx;
|
||||
else if (pos.x < 1.5) mask.r = 1.0;
|
||||
else if (pos.x < 2.5) mask.rg = 1.0.xx;
|
||||
else if (pos.x < 3.5) mask.rgb = 1.0.xxx;
|
||||
else if (pos.x < 4.5) mask.gb = 1.0.xx;
|
||||
else mask.b = 1.0;
|
||||
mask = clamp(mix( mix(one, mask, mcut), mix(one, mask, maskstr), mx), 0.0, 1.0) * dark_compensate;
|
||||
}
|
||||
|
||||
return mask;
|
||||
float maskmin = min(min(mask.r,mask.g),mask.b);
|
||||
return (mask - maskmin) * (1.0 + (maskboost-1.0)*mb) + maskmin;
|
||||
}
|
||||
|
||||
float SlotMask(vec2 pos, float m)
|
||||
|
@ -422,6 +451,7 @@ float SlotMask(vec2 pos, float m)
|
|||
if ((slotmask + slotmask1) == 0.0) return 1.0;
|
||||
else
|
||||
{
|
||||
if (shadowMask == 2.0 || shadowMask == 6.0) pos.x = pos.x + 1.0;
|
||||
pos = floor(pos/slotms);
|
||||
float mlen = slotwidth*2.0;
|
||||
float px = fract(pos.x/mlen);
|
||||
|
@ -433,7 +463,7 @@ float SlotMask(vec2 pos, float m)
|
|||
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vec2 Warp(vec2 pos)
|
||||
{
|
||||
|
@ -487,6 +517,11 @@ vec3 declip(vec3 c, float b)
|
|||
return c;
|
||||
}
|
||||
|
||||
float igc(float mc)
|
||||
{
|
||||
return pow(mc, gamma_c);
|
||||
}
|
||||
|
||||
// noise function:
|
||||
// Dedicated to the public domain.
|
||||
// If you want a real license, you may consider this MIT/BSD/CC0/WTFPL-licensed (take your pick).
|
||||
|
@ -567,7 +602,7 @@ void main()
|
|||
vec2 texcoord = TEX0.xy;
|
||||
|
||||
if (IOS > 0.0 && !interb){
|
||||
vec2 ofactor = OutputSize.xy/SourceSize.xy;
|
||||
vec2 ofactor = OutputSize.xy/global.OriginalSize.xy;
|
||||
vec2 intfactor = (IOS < 2.5) ? floor(ofactor) : ceil(ofactor);
|
||||
vec2 diff = ofactor/intfactor;
|
||||
float scan = diff.y;
|
||||
|
@ -580,25 +615,33 @@ void main()
|
|||
vec2 pos1 = TEX0.xy;
|
||||
vec2 pos = Warp(texcoord);
|
||||
vec2 pos0 = Warp(TEX0.xy);
|
||||
vec3 color0 = COMPAT_TEXTURE(Source,pos1).rgb;
|
||||
float c0 = max(max(color0.r, color0.g),color0.b);
|
||||
|
||||
// color and bloom fetching
|
||||
vec3 color = COMPAT_TEXTURE(Source,pos1).rgb;
|
||||
vec3 Bloom = COMPAT_TEXTURE(BloomPass, pos).rgb;
|
||||
fetch_pixel(color, Bloom, pos1, pos);
|
||||
|
||||
if ((abs(global.deconrr) + abs(global.deconrry) + abs(global.deconrg) + abs(global.deconrgy) + abs(global.deconrb) + abs(global.deconrby)) > 0.2)
|
||||
fetch_pixel(color, Bloom, pos1, pos); // deconvergence
|
||||
|
||||
float cm = max(max(color.r,color.g),color.b);
|
||||
float cm = igc(max(max(color.r,color.g),color.b));
|
||||
float mx1 = COMPAT_TEXTURE(Source, pos1 ).a;
|
||||
float colmx = max(mx1, cm);
|
||||
float w3 = min((c0 + 0.0005) / (pow(colmx, gamma_in/1.4) + 0.0005), 1.0);
|
||||
float w3 = min((cm + 0.0001) / (colmx + 0.0005), 1.0);
|
||||
|
||||
vec2 dx = vec2(0.001, 0.0);
|
||||
float mx0 = COMPAT_TEXTURE(Source, pos1 - dx).a;
|
||||
float mx2 = COMPAT_TEXTURE(Source, pos1 + dx).a;
|
||||
float mx = max(max(mx0,mx1),max(mx2,cm));
|
||||
float mxg = max(max(mx0,mx1),max(mx2,cm));
|
||||
float mx = pow(mxg, 1.40/gamma_in);
|
||||
|
||||
vec3 one = vec3(1.0);
|
||||
|
||||
// mask boost tweak
|
||||
|
||||
dx = vec2(global.OriginalSize.z, 0.0)*0.25;
|
||||
mx0 = COMPAT_TEXTURE(Source, pos1 - dx).a;
|
||||
mx2 = COMPAT_TEXTURE(Source, pos1 + dx).a;
|
||||
float mb = 1.0 - min(abs(mx0-mx2)/(0.5+mx1), 1.0);
|
||||
|
||||
// Apply Mask
|
||||
|
||||
|
@ -608,33 +651,29 @@ void main()
|
|||
vec2 maskcoord = gl_FragCoord.xy * 1.000001;
|
||||
|
||||
float smask = SlotMask(maskcoord, mx);
|
||||
cmask*= Mask(maskcoord, mx);
|
||||
cmask*= Mask(maskcoord, mx, mb);
|
||||
|
||||
if (mask_layout > 0.5) cmask = cmask.rbg;
|
||||
if (mask_layout > 0.5) cmask = cmask.bgr;
|
||||
|
||||
cmask*=smask;
|
||||
vec3 cmask1 = cmask;
|
||||
float smask1 = smask;
|
||||
|
||||
if (mask_bloom > 0.025)
|
||||
{
|
||||
float maxb = max(max(Bloom.r,Bloom.g),Bloom.b);
|
||||
maxb = pow(sqrt(maxb*mix(maxb, colmx, 0.75)),0.275);
|
||||
vec3 mBloom = 0.5*(1.5*Bloom+0.5*maxb) * mix(1.0, 2.0-colmx, (bloom_dist + 0.5));
|
||||
float maskmx = 1.0; if (shadowMask > 0.5 || shadowMask < 4.5) maskmx = maskLight; else if (shadowMask > 6.5 && shadowMask < 10.5) maskmx = 1.0; else maskmx = max(max(cmask.r,cmask.g),cmask.b);
|
||||
cmask = min(cmask + maxb*mBloom*mask_bloom, maskmx);
|
||||
smask = min(smask + 0.9*maxb*max(max(mBloom.r,mBloom.g),mBloom.b)*mask_bloom, 1.0);
|
||||
float maxbl = max(max(max(Bloom.r,Bloom.g),Bloom.b), mxg);
|
||||
maxbl = maxbl * mix(1.0, 2.0-colmx, bloom_dist);
|
||||
cmask = max(min(cmask + maxbl*mask_bloom, 1.0), cmask);
|
||||
}
|
||||
|
||||
color = pow(color, vec3(mask_gamma/gamma_in));
|
||||
color = color*cmask;
|
||||
color = min(color,1.0);
|
||||
color = color*smask;
|
||||
color = pow(color, vec3(gamma_in/mask_gamma));
|
||||
|
||||
cmask = min(cmask*smask, 1.0);
|
||||
cmask1 = min(cmask1*smask1, 1.0);
|
||||
cmask = min(cmask, 1.0);
|
||||
cmask1 = min(cmask1, 1.0);
|
||||
|
||||
float bb = mix(brightboost, brightboost1, colmx);
|
||||
float bb = mix(brightboost, brightboost1, mx);
|
||||
if (interb) bb = (abs(intera-0.5)<0.1) ? pow(0.80*bb, 0.65) : pow(bb, 0.70);
|
||||
color*=bb;
|
||||
|
||||
|
@ -645,14 +684,14 @@ void main()
|
|||
|
||||
vec3 Bloom1 = Bloom;
|
||||
|
||||
if (abs(bloom) > 0.025)
|
||||
{
|
||||
if (bloom < -0.01) Bloom1 = plant(Bloom, maxb);
|
||||
|
||||
Bloom1 = min(Bloom1*(orig1+color), max(0.5*(colmx + orig1 - color),0.001*Bloom1));
|
||||
Bloom1 = 0.5*(Bloom1 + mix(Bloom1, mix(colmx*orig1, Bloom1, 0.5), 1.0-color));
|
||||
|
||||
Bloom1 = Bloom1 * mix(1.0, 2.0-colmx, bloom_dist);
|
||||
|
||||
color = color + abs(bloom) * Bloom1;
|
||||
color = pow(pow(color, vec3(mask_gamma/gamma_in)) + abs(bloom) * pow(Bloom1, vec3(mask_gamma/gamma_in)), vec3(gamma_in/mask_gamma));
|
||||
}
|
||||
|
||||
color = min(color, mix(one, cmask1, mclip));
|
||||
|
||||
|
@ -661,6 +700,13 @@ void main()
|
|||
if (halation > 0.01) {
|
||||
Bloom = mix(0.5*(Bloom + Bloom*Bloom), 0.75*Bloom*Bloom, colmx);
|
||||
color = color + 2.0*max((2.0*mix(maxb*maxb, maxb, colmx)-0.5*max(max(Ref.r,Ref.g),Ref.b)),0.25)*mix(1.0,w3,0.5*colmx)*mix(one,cmask,0.6)*Bloom*halation; }
|
||||
else
|
||||
if (halation < 0.01) {
|
||||
float mbl = max(max(Bloom.r,Bloom.g),Bloom.b);
|
||||
Bloom = plant(Bloom + Ref + orig1 + Bloom*Bloom*Bloom, min(mbl*mbl,0.75));
|
||||
color = color + 2.0*mix(1.0,w3,0.5*colmx)*mix(one,cmask,0.5)*Bloom*(-halation); }
|
||||
|
||||
if (smoothmask > 0.5) { w3 = mix(1.0, w3, smoothstep(0.3, 0.6, mx1)); color = max(min(color/w3, 1.0)*w3, min(color,color*(1.0-w3))); }
|
||||
|
||||
Glow = mix(Glow, 0.25*color, 0.7*colmx);
|
||||
if (glow >= 0.0) color = color + 0.5*Glow*glow; else { cmask*=cmask; cmask*=cmask; color = color + (-glow)*cmask*Glow; }
|
||||
|
|
|
@ -33,8 +33,6 @@ layout(push_constant) uniform Push
|
|||
float iscan;
|
||||
float intres;
|
||||
float iscans;
|
||||
float prescalex;
|
||||
float prescaley;
|
||||
} params;
|
||||
|
||||
|
||||
|
@ -59,15 +57,9 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
#pragma parameter iscan " Interlacing Scanline Effect" 0.20 0.0 1.0 0.05
|
||||
#define iscan params.iscan // interlacing effect scanlining
|
||||
|
||||
#pragma parameter intres " Internal Resolution Y: 224p/240p, 1.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with main pass, values must match
|
||||
#pragma parameter intres " Internal Resolution Y: 0.5...y-dowsample" 0.0 0.0 6.0 0.5 // Joint parameter with main pass, values must match
|
||||
#define intres params.intres // interlace resolution
|
||||
|
||||
#pragma parameter prescalex " Prescale-X Factor (for xBR...pre-shader...)" 1.0 1.0 5.0 0.25 // Joint parameter with main pass, values must match
|
||||
#define prescalex params.prescalex // prescale-x factor
|
||||
|
||||
#pragma parameter prescaley " Prescale-Y Factor (for xBR...pre-shader...)" 1.0 1.0 5.0 0.25 // Joint parameter with main pass, values must match
|
||||
#define prescaley params.prescaley // prescale-y factor
|
||||
|
||||
#pragma parameter iscans " Interlacing (Scanline) Saturation" 0.25 0.0 1.0 0.05
|
||||
#define iscans params.iscans // interlace saturation
|
||||
|
||||
|
@ -79,7 +71,7 @@ layout(location = 0) out vec2 vTexCoord;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord * 1.0001;
|
||||
vTexCoord = TexCoord * 1.00001;
|
||||
}
|
||||
|
||||
#pragma stage fragment
|
||||
|
|
|
@ -73,7 +73,7 @@ layout(push_constant) uniform Push
|
|||
|
||||
#pragma parameter pre_bb " Brightness Adjustment" 1.0 0.0 2.0 0.01
|
||||
|
||||
#pragma parameter contr " Contrast Adjustment" 0.0 -1.0 1.0 0.05
|
||||
#pragma parameter contr " Contrast Adjustment" 0.0 -2.0 2.0 0.05
|
||||
|
||||
#pragma parameter sega_fix " Sega Brightness Fix" 0.0 0.0 1.0 1.0
|
||||
|
||||
|
@ -236,10 +236,8 @@ vec3 plant (vec3 tar, float r)
|
|||
}
|
||||
|
||||
float contrast(float x)
|
||||
{
|
||||
float y = 2.0*x-1.0;
|
||||
y = (sin(y*1.57079632679)+1.0)*0.5;
|
||||
return mix(x, y, params.contr);
|
||||
{
|
||||
return max(mix(x, smoothstep(0.0, 1.0, x), params.contr),0.0);
|
||||
}
|
||||
|
||||
void main()
|
||||
|
@ -345,10 +343,8 @@ void main()
|
|||
color = plant(color, contrast(max(max(color.r,color.g),color.b)));
|
||||
|
||||
p = 2.2;
|
||||
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
color = pow(color, vec3(p));
|
||||
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
|
||||
vec3 warmer = D65_to_D55*color;
|
||||
warmer = ToSRGB*warmer;
|
||||
|
|
Loading…
Reference in a new issue