Update crt-geom-mini.slang

This commit is contained in:
metallic77 2023-09-21 09:20:00 +03:00 committed by GitHub
parent 3c51ba2b22
commit 9a07c32dd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,17 +18,18 @@ layout(push_constant) uniform Push
float MASK; float MASK;
float LUM; float LUM;
float INTERL; float INTERL;
float SAT; float SAT, LANC;
} params; } params;
// Parameter lines go here: // Parameter lines go here:
#pragma parameter CURV "CRT-Geom Curvature" 1.0 0.0 1.0 1.0 #pragma parameter CURV "CRT-Geom Curvature" 1.0 0.0 1.0 1.0
#pragma parameter SCAN "CRT-Geom Scanline Weight" 0.25 0.2 0.6 0.05 #pragma parameter SCAN "CRT-Geom Scanline Weight" 0.2 0.2 0.6 0.05
#pragma parameter MASK "CRT-Geom Dotmask Strength" 0.25 0.0 1.0 0.05 #pragma parameter MASK "CRT-Geom Dotmask Strength" 0.2 0.0 1.0 0.05
#pragma parameter LUM "CRT-Geom Luminance" 0.12 0.0 0.5 0.01 #pragma parameter LUM "CRT-Geom Luminance" 0.05 0.0 0.5 0.01
#pragma parameter INTERL "CRT-Geom Interlacing Simulation" 1.0 0.0 1.0 1.0 #pragma parameter INTERL "CRT-Geom Interlacing Simulation" 1.0 0.0 1.0 1.0
#pragma parameter SAT "CRT-Geom Saturation" 1.1 0.0 2.0 0.01 #pragma parameter SAT "CRT-Geom Saturation" 1.1 0.0 2.0 0.01
#pragma parameter LANC "Filter profile: Accurate/Fast" 0.0 0.0 1.0 1.0
#define PI 3.1415926535897932384626433 #define PI 3.1415926535897932384626433
#define SourceSize params.SourceSize #define SourceSize params.SourceSize
@ -42,7 +43,7 @@ layout(push_constant) uniform Push
#define LUM params.LUM #define LUM params.LUM
#define INTERL params.INTERL #define INTERL params.INTERL
#define SAT params.SAT #define SAT params.SAT
#define LANC params.LANC
layout(std140, set = 0, binding = 0) uniform UBO layout(std140, set = 0, binding = 0) uniform UBO
{ {
mat4 MVP; mat4 MVP;
@ -79,7 +80,7 @@ layout(set = 0, binding = 1) uniform sampler2D Source;
float scan(float pos, vec3 color) float scan(float pos, vec3 color)
{ {
float wid = SCAN + 0.1 * dot(color, vec3(0.333))*0.8; float wid = SCAN + 0.1 * max(max(color.r,color.g),color.b);
float weight = pos / wid; float weight = pos / wid;
return LUM + (0.1 + SCAN) * exp(-weight * weight ) / wid; return LUM + (0.1 + SCAN) * exp(-weight * weight ) / wid;
} }
@ -115,8 +116,13 @@ void main()
// Calculate weights in x and y in parallel. // Calculate weights in x and y in parallel.
// These polynomials are piecewise approximation of Lanczos kernel // These polynomials are piecewise approximation of Lanczos kernel
// Calculator here: https://gist.github.com/going-digital/752271db735a07da7617079482394543 // Calculator here: https://gist.github.com/going-digital/752271db735a07da7617079482394543
vec4 l2_w0_o3 = (-1.1828) * f + 1.1298; vec4 l2_w0_o3, l2_w1_o3;
vec4 l2_w1_o3 = (0.0858) * f - 0.0792; if (LANC == 0.0)
{l2_w0_o3 = (((1.5672) * f - 2.6445) * f + 0.0837) * f + 0.9976;
l2_w1_o3 = (((-0.7389) * f + 1.3652) * f - 0.6295) * f - 0.0004;}
else {l2_w0_o3 = (-1.1828) * f + 1.1298;
l2_w1_o3 = (0.0858) * f - 0.0792;}
vec4 w1_2 = l2_w0_o3; vec4 w1_2 = l2_w0_o3;
vec2 w12 = w1_2.xy + w1_2.zw; vec2 w12 = w1_2.xy + w1_2.zw;
@ -153,7 +159,7 @@ void main()
res *= sqrt(scn*msk); res *= sqrt(scn*msk);
float l = dot(vec3(0.29, 0.6, 0.11), res); float l = dot(vec3(0.29, 0.6, 0.11), res);
res *= mix(1.0, 1.1, l); res *= mix(1.0, 1.2, l);
res = mix(vec3(l), res, SAT); res = mix(vec3(l), res, SAT);
if (corn.y <= corn.x && CURV == 1.0 || corn.x < 0.0001 && CURV == 1.0 ) res = vec3(0.0); if (corn.y <= corn.x && CURV == 1.0 || corn.x < 0.0001 && CURV == 1.0 ) res = vec3(0.0);