Merge pull request #453 from metallic77/slang

Update zfast_crt_composite.slang
This commit is contained in:
hizzlekizzle 2023-06-19 10:17:16 -05:00 committed by GitHub
commit 4fbac6b177
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,16 +19,17 @@ layout(push_constant) uniform Push
vec4 OriginalSize; vec4 OriginalSize;
vec4 OutputSize; vec4 OutputSize;
uint FrameCount; uint FrameCount;
float pi, blurx, blury, HIGHSCANAMOUNT1, HIGHSCANAMOUNT2, MASK_DARK, MASK_FADE, sat; float pi, blurx, blury, HIGHSCANAMOUNT1, HIGHSCANAMOUNT2, MASK_DARK, MASK_FADE, sat, FLICK;
} params; } params;
#pragma parameter blurx "Convergence X-Axis" 0.45 -1.0 2.0 0.05 #pragma parameter blurx "Convergence X-Axis" 0.45 -1.0 2.0 0.05
#pragma parameter blury "Convergence Y-Axis" -0.25 -1.0 1.0 0.05 #pragma parameter blury "Convergence Y-Axis" -0.25 -1.0 1.0 0.05
#pragma parameter HIGHSCANAMOUNT1 "Scanline Amount (Low)" 0.3 0.0 1.0 0.05 #pragma parameter HIGHSCANAMOUNT1 "Scanline Amount (Low)" 0.4 0.0 1.0 0.05
#pragma parameter HIGHSCANAMOUNT2 "Scanline Amount (High)" 0.2 0.0 1.0 0.05 #pragma parameter HIGHSCANAMOUNT2 "Scanline Amount (High)" 0.3 0.0 1.0 0.05
#pragma parameter MASK_DARK "Mask Effect Amount" 0.25 0.0 1.0 0.05 #pragma parameter MASK_DARK "Mask Effect Amount" 0.3 0.0 1.0 0.05
#pragma parameter MASK_FADE "Mask/Scanline Fade" 0.8 0.0 1.0 0.05 #pragma parameter MASK_FADE "Mask/Scanline Fade" 0.7 0.0 1.0 0.05
#pragma parameter sat "Saturation" 1.1 0.0 3.0 0.05 #pragma parameter sat "Saturation" 1.0 0.0 3.0 0.05
#pragma parameter FLICK "Flicker" 10.0 0.0 50.0 1.0
#define pi 3.14159 #define pi 3.14159
#define blurx params.blurx #define blurx params.blurx
@ -39,6 +40,10 @@ float pi, blurx, blury, HIGHSCANAMOUNT1, HIGHSCANAMOUNT2, MASK_DARK, MASK_FADE,
#define MASK_DARK params.MASK_DARK #define MASK_DARK params.MASK_DARK
#define MASK_FADE params.MASK_FADE #define MASK_FADE params.MASK_FADE
#define sat params.sat #define sat params.sat
#define FLICK params.FLICK
#define SourceSize params.SourceSize
#define OriginalSize params.OriginalSize
#define OutputSize params.OutputSize
layout(std140, set = 0, binding = 0) uniform UBO layout(std140, set = 0, binding = 0) uniform UBO
{ {
@ -65,35 +70,43 @@ layout(location = 1) in float maskFade;
layout(location = 0) out vec4 FragColor; layout(location = 0) out vec4 FragColor;
layout(set = 0, binding = 2) uniform sampler2D Source; layout(set = 0, binding = 2) uniform sampler2D Source;
#define blur_y blury/(SourceSize.y*2.0)
#define blur_x blurx/(SourceSize.x*2.0)
#define iTimer (float(params.FrameCount)*2.0)
#define flicker FLICK/1000.0
void main() void main()
{ {
vec2 pos = vTexCoord.xy; vec2 pos = vTexCoord;
float cent = floor(vTexCoord.y*SourceSize.y)+0.5;
float ycoord = cent*SourceSize.w;
pos = vec2(vTexCoord.x,ycoord);
vec3 sample1 = sin(iTimer)*flicker + texture(Source,vec2(pos.x + blur_x, pos.y - blur_y)).rgb;
vec3 sample2 = 0.5*texture(Source,pos).rgb;
vec3 sample3 = sin(iTimer)*flicker + texture(Source,vec2(pos.x - blur_x, pos.y + blur_y)).rgb;
vec3 sample1 = texture(Source,vec2(pos.x + blurx/1000.0, pos.y - blury/1000.0)).rgb; vec3 colour = vec3 (sample1.r*0.5 + sample2.r,
vec3 sample2 = texture(Source,pos).rgb; sample1.g*0.25 + sample2.g + sample3.g*0.25,
vec3 sample3 = texture(Source,vec2(pos.x - blurx/1000.0, pos.y + blury/1000.0)).rgb; sample2.b + sample3.b*0.5);
vec3 colour = vec3 (sample1.r*0.5+sample2.r*0.5, sample1.g*0.25 + sample2.g*0.5 + sample3.g*0.25, sample2.b*0.5 + sample3.b*0.5); vec3 lumweight=vec3(0.22,0.71,0.07);
float lum = colour.r*0.4 + colour.g*0.4 + colour.b*0.2; float lum = dot(colour,lumweight);
vec3 lumweight=vec3(0.3,0.6,0.1); vec3 graycolour = vec3(lum);
float gray = dot(colour,lumweight); colour = vec3(mix(graycolour,colour.rgb,sat));
vec3 graycolour = vec3(gray);
//Gamma-like float SCANAMOUNT = mix(HIGHSCANAMOUNT1,HIGHSCANAMOUNT2,max(max(colour.r,colour.g),colour.b));
colour*=mix(0.4,1.0,lum);
float SCANAMOUNT = mix(HIGHSCANAMOUNT1,HIGHSCANAMOUNT2,lum); float scanLine = SCANAMOUNT * sin(fract(vTexCoord.y*SourceSize.y)*3.14159)+1.0-SCANAMOUNT;
float scanLine = SCANAMOUNT * sin(2.0*pi*pos.y*params.SourceSize.y);
if (OriginalSize.y > 400.0) scanLine = 1.0;
float whichmask = fract((pos.x*params.OutputSize.x)*0.4999);
float mask = 1.0 + float(whichmask < 0.5) * -MASK_DARK;
//Gamma-like float whichmask = fract(vTexCoord.x*OutputSize.x*0.4999);
colour*=mix(1.5,1.0,lum); float mask = 1.0 + float(whichmask < 0.5) * -MASK_DARK;
colour = vec3(mix(graycolour,colour,sat));
colour.rgb *= mix(mask*(1.0-scanLine), 1.0-scanLine, dot(colour,vec3(maskFade))); colour *= colour;
colour.rgb *= mix(mask*scanLine, scanLine, dot(colour.rgb,vec3(maskFade)));
colour = sqrt(colour);
FragColor.rgb = colour.rgb; FragColor.rgb = colour.rgb;
} }