update crt-guest-dr-venom to latest from guest

This commit is contained in:
hunterk 2020-02-06 11:44:53 -06:00
parent 4cff7c2c23
commit 10708236b1
4 changed files with 142 additions and 116 deletions

View file

@ -1,4 +1,4 @@
shaders = 11
shaders = 10
shader0 = shaders/guest/lut/lut.slang
filter_linear0 = false
@ -14,62 +14,58 @@ SamplerLUT3 = shaders/guest/lut/other1.png
SamplerLUT3_linear = true
shader1 = shaders/guest/color-profiles.slang
filter_linear1 = false
filter_linear1 = true
scale_type1 = source
scale1 = 1.0
shader2 = shaders/guest/d65-d50.slang
filter_linear2 = false
filter_linear2 = true
scale_type2 = source
scale2 = 1.0
alias2 = WhitePointPass
shader3 = shaders/guest/afterglow.slang
filter_linear3 = false
filter_linear3 = true
scale_type3 = source
scale3 = 1.0
alias3 = AfterglowPass
shader4 = shaders/guest/avg-lum0.slang
filter_linear4 = false
shader4 = shaders/guest/avg-lum.slang
filter_linear4 = true
scale_type4 = source
scale4 = 1.0
mipmap_input4 = true
float_framebuffer4 = true
alias4 = AvgLumPass
shader5 = shaders/guest/avg-lum.slang
filter_linear5 = false
shader5 = shaders/guest/linearize.slang
filter_linear5 = true
scale_type5 = source
scale5 = 1.0
mipmap_input5 = true
alias5 = AvgLumPass
float_framebuffer5 = true
alias5 = LinearizePass
shader6 = shaders/guest/linearize.slang
filter_linear6 = false
shader6 = shaders/guest/blur_horiz.slang
filter_linear6 = true
scale_type6 = source
scale6 = 1.0
float_framebuffer6 = true
alias6 = LinearizePass
shader7 = shaders/guest/blur_horiz.slang
filter_linear7 = false
shader7 = shaders/guest/blur_vert.slang
filter_linear7 = true
scale_type7 = source
scale7 = 1.0
float_framebuffer7 = true
alias7 = GlowPass
shader8 = shaders/guest/blur_vert.slang
filter_linear8 = false
shader8 = shaders/guest/linearize_scanlines.slang
filter_linear8 = true
scale_type8 = source
scale8 = 1.0
float_framebuffer8 = true
alias8 = GlowPass
shader9 = shaders/guest/linearize_scanlines.slang
shader9 = shaders/guest/crt-guest-dr-venom.slang
filter_linear9 = true
scale_type9 = source
scale9 = 1.0
float_framebuffer9 = true
shader10 = shaders/guest/crt-guest-dr-venom.slang
filter_linear10 = true
scale_type10 = viewport
scale_x10 = 1.0
scale_y10 = 1.0
scale_type9 = viewport
scale_x9 = 1.0
scale_y9 = 1.0

View file

@ -1,9 +1,9 @@
#version 450
/*
Average Luminance Shader, Smart Smoothing Difference Shader
Average Luminance Shader
Copyright (C) 2018-2019 guest(r) - guest.r@gmail.com
Copyright (C) 2018-2020 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
@ -24,13 +24,15 @@
layout(push_constant) uniform Push
{
uint FrameCount;
vec4 SourceSize;
float STH;
float lsmooth;
} params;
#pragma parameter STH "Smart Smoothing Threshold" 0.7 0.4 1.2 0.05
#pragma parameter lsmooth "Raster Bloom Effect Smoothing" 0.90 0.50 0.99 0.01
#define lsmooth params.lsmooth
#define STH params.STH
#define COMPAT_TEXTURE(c,d) texture(c,d)
#define SourceSize params.SourceSize
#define InputSize SourceSize
@ -56,54 +58,31 @@ void main()
layout(location = 0) in vec2 vTexCoord;
layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source;
layout(set = 0, binding = 3) uniform sampler2D WhitePointPass;
layout(set = 0, binding = 3) uniform sampler2D AvgLumPassFeedback;
#define PassPrev2Texture WhitePointPass
float df (vec3 A, vec3 B)
{
float diff = length(A-B);
float luma = clamp(length(0.5*min(A,B) + 0.25*(A+B) + 1e-8), 0.0001, 1.0);
float diff1 = diff/luma;
return 1.0 - clamp(7.0*(max(1.5*diff,diff1)-STH), 0.0, 0.9999);
}
void main()
{
float xtotal = floor(InputSize.x/64.0);
float ytotal = floor(InputSize.y/64.0);
if (vTexCoord.x > 0.2 || vTexCoord.y > 0.2) discard;
float m = max(log2(SourceSize.x), log2(SourceSize.y));
m = max(m - 1.0, 1.0);
float ltotal = 0.0;
vec2 dx = vec2(SourceSize.z, 0.0)*64.0;
vec2 dy = vec2(0.0, SourceSize.w)*64.0;
vec2 offset = 0.25*(dx+dy);
ltotal+= max(0.0, length(textureLod(Source, vec2(0.25, 0.25), m).rgb));
ltotal+= max(0.0, length(textureLod(Source, vec2(0.25, 0.75), m).rgb));
ltotal+= max(0.0, length(textureLod(Source, vec2(0.75, 0.25), m).rgb));
ltotal+= max(0.0, length(textureLod(Source, vec2(0.75, 0.75), m).rgb));
for (float i = 0.0; i <= xtotal; i++)
{
for (float j = 0.0; j <= ytotal; j++)
{
ltotal+= max(0.25, length(textureLod(Source, i*dx + j*dy + offset, 6.0).rgb));
}
}
ltotal = 0.577350269 * ltotal / ((xtotal+1.0)*(ytotal+1.0));
ltotal*=0.25;
ltotal = pow(0.577350269 * ltotal, 0.6);
float lhistory = texture(AvgLumPassFeedback, vec2(0.1,0.1)).a;
dx = vec2(SourceSize.z, 0.0);
dy = vec2(0.0, SourceSize.w);
vec3 l1 = COMPAT_TEXTURE(PassPrev2Texture, TEX0.xy -dx).xyz;
vec3 ct = COMPAT_TEXTURE(PassPrev2Texture, TEX0.xy ).xyz;
vec3 r1 = COMPAT_TEXTURE(PassPrev2Texture, TEX0.xy +dx).xyz;
vec3 t1 = COMPAT_TEXTURE(PassPrev2Texture, TEX0.xy -dy).xyz;
vec3 b1 = COMPAT_TEXTURE(PassPrev2Texture, TEX0.xy +dy).xyz;
ltotal = mix(ltotal, lhistory, lsmooth);
float dl = df(ct, l1);
float dr = df(ct, r1);
float dt = df(ct, t1);
float db = df(ct, b1);
float resx = dl; float resy = dr; float resz = floor(9.0*dt)/10.0 + floor(9.0*db)/100.0;
FragColor = vec4(resx,resy,resz,pow(ltotal, 0.65));
FragColor = vec4(ltotal);
}

View file

@ -108,7 +108,7 @@ mat3(
const mat3 ToDCI =
mat3(
2.725394, -0.795168, 0.041242,
-1.018003, 1.689732, 0.022647,
-1.018003, 1.689732, -0.087639,
-0.440163, 0.022647, 1.100929
);

View file

@ -38,6 +38,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
vec4 OutputSize;
uint FrameCount;
float bloom;
float interm;
} global;
#pragma parameter TATE "TATE Mode" 0.0 0.0 1.0 1.0
@ -48,13 +49,13 @@ layout(std140, set = 0, binding = 0) uniform UBO
#define OS params.OS // Do overscan
#pragma parameter BLOOM "Raster bloom %" 0.0 0.0 20.0 1.0
#define BLOOM params.BLOOM // Bloom overscan percentage
#pragma parameter brightboost "Bright Boost Dark Pixels" 1.40 0.50 2.00 0.025
#pragma parameter brightboost "Bright Boost Dark Pixels" 1.40 0.50 4.00 0.05
#define brightboost params.brightboost // adjust brightness
#pragma parameter brightboost1 "Bright Boost Bright Pixels" 1.15 0.50 2.00 0.025
#pragma parameter brightboost1 "Bright Boost Bright Pixels" 1.15 0.50 2.00 0.05
#define brightboost1 params.brightboost1 // adjust brightness
#pragma parameter gsl "Scanline Type" 0.0 0.0 2.0 1.0
#define gsl params.gsl // Alternate scanlines
#pragma parameter scanline1 "Scanline beam shape low" 8.0 1.0 15.0 1.0
#pragma parameter scanline1 "Scanline beam shape low" 6.0 1.0 15.0 1.0
#define scanline1 params.scanline1 // scanline param, vertical sharpness
#pragma parameter scanline2 "Scanline beam shape high" 8.0 5.0 23.0 1.0
#define scanline2 params.scanline2 // scanline param, vertical sharpness
@ -66,7 +67,7 @@ layout(std140, set = 0, binding = 0) uniform UBO
#define beam_size params.beam_size // increased max. beam size
#pragma parameter h_sharp "Horizontal sharpness" 5.25 1.5 20.0 0.25
#define h_sharp params.h_sharp // pixel sharpness
#pragma parameter s_sharp "Substractive sharpness" 0.01 0.0 0.50 0.01
#pragma parameter s_sharp "Substractive sharpness (relative)" 0.35 0.0 1.0 0.05
#define s_sharp params.s_sharp // substractive sharpness
#pragma parameter csize "Corner size" 0.0 0.0 0.07 0.01
#define csize params.csize // corner size
@ -100,10 +101,12 @@ layout(std140, set = 0, binding = 0) uniform UBO
#define CGWG params.CGWG // CGWG Mask Strength
#pragma parameter gamma_out "Gamma out" 2.4 1.0 3.5 0.05
#define gamma_out params.gamma_out // output gamma
#pragma parameter spike "Scanline Spike Removal (0.0 - for speedup)" 1.25 0.0 2.0 0.25
#pragma parameter spike "Scanline Spike Removal (0.0 - for speedup)" 1.0 0.0 2.0 0.25
#define spike params.spike
#pragma parameter inter "Scanline Removal Starts at Y res (0.0 - OFF):" 400.0 0.0 800.0 25.0
#define inter params.inter // interlacing alternative
#pragma parameter inter "Interlace Trigger Resolution :" 300.0 0.0 800.0 25.0
#define inter params.inter // interlace resolution
#pragma parameter interm "Interlace Mode (0.0 = OFF):" 1.0 0.0 3.0 1.0
#define interm global.interm // interlace mode
#pragma parameter bloom "Bloom Strength" 0.0 0.0 2.0 0.1
#define bloom global.bloom // bloom effect
@ -140,11 +143,11 @@ layout(set = 0, binding = 5) uniform sampler2D GlowPass;
#define PassPrev4Texture LinearizePass
#define PassPrev2Texture GlowPass
#define eps 1e-10
#define eps 1e-10
float st(float x, float scanline)
float st(float x)
{
return exp2(-scanline*x*x);
return exp2(-10.0*x*x);
}
vec3 sw0(vec3 x, vec3 color, float scanline)
@ -161,16 +164,21 @@ vec3 sw1(vec3 x, vec3 color, float scanline)
vec3 tmp = mix(vec3(1.2*beam_min),vec3(beam_max), color);
vec3 ex = x*tmp;
float br = clamp(0.8*beam_min - 1.0, 0.2, 0.45);
return exp2(-scanline*ex*ex)/(1.0-br+br*color);
vec3 res = exp2(-scanline*ex*ex)/(1.0-br+br*mx);
mx = max(max(res.r,res.g),res.b);
return mix(vec3(mx), res, 0.70);
}
vec3 sw2(vec3 x, vec3 color, float scanline)
{
vec3 tmp = mix(vec3(2.75*beam_min),vec3(beam_max), color);
tmp = mix(vec3(beam_max), tmp, pow(x, vec3(max(max(color.r, color.g),color.b)+0.3)));
float mx = max(max(color.r, color.g),color.b);
vec3 tmp = mix(vec3(2.5*beam_min),vec3(beam_max), color);
tmp = mix(vec3(beam_max), tmp, pow(abs(x), color+0.3));
vec3 ex = x*tmp;
return exp2(-scanline*ex*ex)/(0.6 + 0.4*color);
}
vec3 res = exp2(-scanline*ex*ex)/(0.6 + 0.4*mx);
mx = max(max(res.r,res.g),res.b);
return mix(vec3(mx), res, 0.60);
}
// Shadow mask (1-4 from PD CRT Lottes shader).
vec3 Mask(vec2 pos, vec3 c)
@ -340,7 +348,7 @@ vec3 declip(vec3 c, float b)
void main()
{
float lum = COMPAT_TEXTURE(PassPrev5Texture, vec2(0.33,0.33)).a;
float lum = COMPAT_TEXTURE(PassPrev5Texture, vec2(0.1,0.1)).a;
// Calculating texel coordinates
@ -359,14 +367,15 @@ void main()
vec2 pos = Warp(texcoord*(TextureSize.xy/InputSize.xy))*(InputSize.xy/TextureSize.xy);
vec2 pos0 = Warp(TEX0.xy*(TextureSize.xy/InputSize.xy))*(InputSize.xy/TextureSize.xy);
vec2 coffset = ((TATE < 0.5) ? vec2(0.0,0.5) : vec2(0.5, 0.0));
if ((interm == 1.0 || interm == 2.0) && inter <= mix(SourceSize.y, SourceSize.x, TATE)) coffset = vec2(0.0);
vec2 ps = SourceSize.zw;
vec2 OGL2Pos = pos * SourceSize.xy - ((TATE < 0.5) ?
vec2(0.0,0.5) : vec2(0.5, 0.0));
vec2 OGL2Pos = pos * SourceSize.xy - coffset;
vec2 fp = fract(OGL2Pos);
vec2 dx = vec2(ps.x,0.0);
vec2 dy = vec2(0.0, ps.y);
vec2 pC4 = floor(OGL2Pos) * ps + 0.5*ps;
// Reading the texels
vec2 x2 = 2.0*dx;
@ -383,10 +392,12 @@ void main()
offy = dx;
fpx = fp.y;
}
float s_sharp1 = 0.5*s_sharp;
float zero = exp2(-h_sharp);
float sharp1 = min(zero,s_sharp1);
float f = (TATE < 0.5) ? fp.y : fp.x;
vec2 pC4 = floor(OGL2Pos) * ps + 0.5*ps;
float zero = exp2(-h_sharp);
float sharp1 = s_sharp * zero;
float wl2 = 1.5 + fpx;
float wl1 = 0.5 + fpx;
@ -402,11 +413,11 @@ void main()
float fp1 = 1.-fpx;
float twl2 = max(wl2 - sharp1, (fpx <=0.7) ? mix( -0.09, 0.037, fpx) : 0.0);
float twl1 = max(wl1 - sharp1, (fpx <=0.5) ? 0.0 : mix( -0.30, -0.09, fpx));
float twl2 = max(wl2 - sharp1, min(mix( -0.09, 0.09, fpx),0.0));
float twl1 = max(wl1 - sharp1, mix( -0.275, -0.09, fpx));
float twct = max(wct - sharp1, 0.0);
float twr1 = max(wr1 - sharp1, (fp1 <=0.5) ? 0.0 : mix( -0.30, -0.09, fp1));
float twr2 = max(wr2 - sharp1, (fp1 <=0.7) ? mix( -0.09, 0.037, fp1) : 0.0);
float twr1 = max(wr1 - sharp1, mix( -0.275, -0.09, fp1));
float twr2 = max(wr2 - sharp1, min(mix( -0.09, 0.09, fp1),0.0));
float wtt = 1.0/(twl2+twl1+twct+twr1+twr2);
float wt = 1.0/(wl2+wl1+wct+wr1+wr2);
@ -426,7 +437,7 @@ void main()
vec3 color1 = clamp((l2*twl2 + l1*twl1 + ct*twct + r1*twr1 + r2*twr2)*wtt,0.0,1.0);
vec3 e2 = l2; if (fp.x > 0.5) e2 = r2;
vec3 e2 = l2; if (fpx > 0.5) e2 = r2;
vec3 colmin = min(min(l1,r1), min(ct,e2));
vec3 colmax = max(max(l1,r1), max(ct,e2));
@ -458,7 +469,7 @@ void main()
vec3 color2 = clamp((l2*twl2 + l1*twl1 + ct*twct + r1*twr1 + r2*twr2)*wtt,0.0,1.0);
e2 = l2; if (fp.x > 0.5) e2 = r2;
e2 = l2; if (fpx > 0.5) e2 = r2;
colmin = min(min(l1,r1), min(ct,e2));
colmax = max(max(l1,r1), max(ct,e2));
@ -473,20 +484,39 @@ void main()
scolor2 = mix(color2, scolor2, spike);
}
// calculating scanlines
vec3 color0 = color1;
if ((interm == 1.0 || interm == 2.0) && inter <= mix(SourceSize.y, SourceSize.x, TATE))
{
pC4-= 2.*offy;
float f = (TATE < 0.5) ? fp.y : fp.x;
l2 = COMPAT_TEXTURE(PassPrev4Texture, pC4 -off2).xyz;
l1 = COMPAT_TEXTURE(PassPrev4Texture, pC4 -offx).xyz;
ct = COMPAT_TEXTURE(PassPrev4Texture, pC4 ).xyz;
r1 = COMPAT_TEXTURE(PassPrev4Texture, pC4 +offx).xyz;
r2 = COMPAT_TEXTURE(PassPrev4Texture, pC4 +off2).xyz;
color0 = clamp((l2*twl2 + l1*twl1 + ct*twct + r1*twr1 + r2*twr2)*wtt,0.0,1.0);
e2 = l2; if (fpx > 0.5) e2 = r2;
colmin = min(min(l1,r1), min(ct,e2));
colmax = max(max(l1,r1), max(ct,e2));
if (sharp) color0 = clamp(color0, colmin, colmax);
}
// calculating scanlines
float shape1 = mix(scanline1, scanline2, f);
float shape2 = mix(scanline1, scanline2, 1.0-f);
float wt1 = st(f, shape1);
float wt2 = st(1.0-f, shape2);
float wt1 = st(f);
float wt2 = st(1.0-f);
vec3 color0 = color1*wt1 + color2*wt2;
vec3 color00 = color1*wt1 + color2*wt2;
vec3 scolor0 = scolor1*wt1 + scolor2*wt2;
vec3 ctmp = color0/(wt1+wt2);
vec3 ctmp = color00/(wt1+wt2);
vec3 sctmp = scolor0/(wt1+wt2);
vec3 tmp = pow(ctmp, vec3(1.0/gamma_out));
@ -507,7 +537,27 @@ void main()
vec3 color = color1*w1 + color2*w2;
if (inter != 0.0 && inter <= mix(SourceSize.y, SourceSize.x, TATE)) color = mix(color1, color2, f);
if (interm > 0.5 && inter <= mix(SourceSize.y, SourceSize.x, TATE))
{
float line_no = floor(mod(mix( OGL2Pos.y, OGL2Pos.x, TATE),2.0));
float frame_no = floor(mod(float(global.FrameCount),2.0));
if (interm == 1.0)
{
vec3 icolor1 = mix(color1, color0, abs(line_no-frame_no));
vec3 icolor2 = mix(color1, color2, abs(line_no-frame_no));
color = mix(icolor1, icolor2, f);
}
else if (interm == 2.0)
{
float v0 = exp2(-2.25*2.25);
float v1 = exp2(-2.25*(0.5+f)*(0.5+f)) - v0;
float v2 = exp2(-2.25*(0.5-f)*(0.5-f)) - v0;
float v3 = exp2(-2.25*(1.5-f)*(1.5-f)) - v0;
color = (v1*color0 + v2*color1 + v3*color2)/(v1+v2+v3);
}
else color = mix(color1, color2, f);
}
ctmp = 0.5*(ctmp+tmp);
color*=mix(brightboost, brightboost1, max(max(ctmp.r,ctmp.g),ctmp.b));
@ -538,18 +588,19 @@ void main()
float pmax = 0.85;
Bloom1 = min(Bloom1, pmax*bmax)/pmax;
Bloom1 = mix(min( Bloom1, color), Bloom1, orig1);
Bloom1 = mix(min( Bloom1, color), Bloom1, 0.5*(orig1+color));
Bloom1 = bloom*Bloom1;
color = color + Bloom1;
color = min(color,1.0);
color = declip(color, pow(w3, 0.5));
color = min(color, 1.0);
if (interm < 0.5 || inter > mix(SourceSize.y, SourceSize.x, TATE)) color = declip(color, pow(w3,0.5));
color = min(color, mix(cmask,one,0.5));
color = color + glow*Bloom;
color = min(color, mix(cmask,one,0.5));
color = pow(color, vec3(1.0/gamma_out));
FragColor = vec4(color*corner(pos0), 1.0);
}
}