mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-26 01:11:32 +11:00
updates (#412)
* Update crt-consumer.slang Removed NTSC as it conflicts with saturation/hue, and can be used as a separate pass anyway. Fixed some mistakes. Massive speed-up from 120 fps to 450 fps on Intel HD630. * Update crt-gdv-mini-ultra.slang Removed NTSC, some corrections too. * Update zfast_crt_composite.slang * Update fake-crt-geom.slang
This commit is contained in:
parent
aaf83724d3
commit
2b0ae3e422
|
@ -48,7 +48,6 @@ layout(push_constant) uniform Push
|
|||
#pragma parameter double_slot "Slot Mask Height: 2x1 or 4x1" 1.0 1.0 2.0 1.0
|
||||
#pragma parameter slotms "Slot Mask Size" 1.0 1.0 2.0 1.0
|
||||
#pragma parameter GAMMA_OUT " Gamma Out" 2.2 0.0 4.0 0.1
|
||||
#pragma parameter intensity " NTSC colors intensity" 0.0 0.0 1.0 0.05
|
||||
#pragma parameter sat " Saturation" 1.0 0.0 2.0 0.05
|
||||
#pragma parameter contrast " Contrast, 1.0:Off" 1.0 0.00 2.00 0.05
|
||||
#pragma parameter WP " Color Temperature %" 0.0 -100.0 100.0 5.0
|
||||
|
@ -107,7 +106,6 @@ layout(std140, set = 0, binding = 0) uniform UBO
|
|||
float alloff;
|
||||
float postbr;
|
||||
float PRE_SCALE;
|
||||
float intensity;
|
||||
float preserve;
|
||||
} global;
|
||||
|
||||
|
@ -417,61 +415,6 @@ const mat3 XYZ_to_D50 = mat3(
|
|||
-1.4678519, 1.9161415, -0.2545973,
|
||||
-0.4685105, 0.0334540, 1.4216174);
|
||||
|
||||
/////NTSC COLOR CONVERSION
|
||||
|
||||
vec3 DecodeGamma(vec3 color, float gamma)
|
||||
{
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
color.r = (color.r <= 0.00313066844250063) ?
|
||||
color.r * 12.92 : 1.055 * pow(color.r, 1.0 / gamma) - 0.055;
|
||||
color.g = (color.g <= 0.00313066844250063) ?
|
||||
color.g * 12.92 : 1.055 * pow(color.g, 1.0 / gamma) - 0.055;
|
||||
color.b = (color.b <= 0.00313066844250063) ?
|
||||
color.b * 12.92 : 1.055 * pow(color.b, 1.0 / gamma) - 0.055;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
vec3 XYZtoSRGB(vec3 XYZ)
|
||||
{
|
||||
const mat3x3 m = mat3x3(
|
||||
3.2404542,-1.5371385,-0.4985314,
|
||||
-0.9692660, 1.8760108, 0.0415560,
|
||||
0.0556434,-0.2040259, 1.0572252);
|
||||
return XYZ * m;
|
||||
}
|
||||
|
||||
vec3 sRGB(vec3 c)
|
||||
{
|
||||
vec3 v = XYZtoSRGB(c);
|
||||
v = DecodeGamma(v, 2.4); //Companding
|
||||
|
||||
return v;
|
||||
}
|
||||
vec3 RGBtoXYZ(vec3 RGB)
|
||||
{
|
||||
const mat3x3 m = mat3x3(
|
||||
0.6068909, 0.1735011, 0.2003480,
|
||||
0.2989164, 0.5865990, 0.1144845,
|
||||
0.0000000, 0.0660957, 1.1162243);
|
||||
return RGB * m;
|
||||
}
|
||||
|
||||
// conversion from NTSC RGB Reference White D65 ( color space used by NA/Japan TV's ) to XYZ
|
||||
vec3 NTSC(vec3 c)
|
||||
{
|
||||
vec3 v = vec3(pow(c.r, 2.2), pow(c.g, 2.2), pow(c.b, 2.2)); //Inverse Companding
|
||||
return RGBtoXYZ(v);
|
||||
}
|
||||
|
||||
// NTSC RGB to sRGB
|
||||
vec3 NTSCtoSRGB( vec3 c )
|
||||
{
|
||||
return sRGB(NTSC( c ));
|
||||
}
|
||||
|
||||
////NTSC COLOR CONVERSION
|
||||
|
||||
|
||||
|
||||
|
@ -542,8 +485,7 @@ void main()
|
|||
|
||||
color = hue * color;
|
||||
|
||||
color = (2.0*pow(color,vec3(2.9))) - pow(color,vec3(3.8));
|
||||
color = mix(color.rgb, NTSCtoSRGB(color.rgb), global.intensity);
|
||||
color = (2.0*pow(color,vec3(2.8))) - pow(color,vec3(3.6));
|
||||
|
||||
float lum = color.r * 0.3 + color.g * 0.6 + color.b * 0.1;
|
||||
|
||||
|
@ -566,7 +508,7 @@ void main()
|
|||
|
||||
|
||||
color = pow(color,vec3(1.0 / global.GAMMA_OUT));
|
||||
if (global.glow != 0.0) color += glow0(coords,color);
|
||||
if (global.glow_str != 0.0) color += glow0(coords,color);
|
||||
|
||||
if (global.sat != 1.0) color = saturation(color);
|
||||
if (global.corner != 0.0) color *= corner0(pC4);
|
||||
|
|
|
@ -51,34 +51,10 @@ layout(push_constant) uniform Push
|
|||
float G;
|
||||
float B;
|
||||
float thres;
|
||||
float intensity;
|
||||
} params;
|
||||
|
||||
// Parameter lines go here:
|
||||
|
||||
#pragma parameter gamma_out_red "Gamma out Red" 2.2 1.0 4.0 0.1
|
||||
#define gamma_out_red params.gamma_out_red
|
||||
|
||||
#pragma parameter gamma_out_green "Gamma out Green" 2.2 1.0 4.0 0.1
|
||||
#define gamma_out_green params.gamma_out_green
|
||||
|
||||
#pragma parameter gamma_out_blue "Gamma out Blue" 2.2 1.0 4.0 0.1
|
||||
#define gamma_out_blue params.gamma_out_blue
|
||||
|
||||
#pragma parameter intensity "NTSC colors intensity" 1.0 0.0 1.0 0.05
|
||||
#define intensity params.intensity
|
||||
|
||||
|
||||
|
||||
#pragma parameter brightboost "Bright boost" 1.2 0.5 2.0 0.05
|
||||
#define brightboost params.brightboost
|
||||
|
||||
#pragma parameter sat "Saturation adjustment" 1.2 0.0 2.0 0.05
|
||||
#define sat params.sat
|
||||
|
||||
#pragma parameter glow "Glow Strength" 0.2 0.0 1.0 0.01
|
||||
#define glow params.glow
|
||||
|
||||
#pragma parameter scanline "Scanline Adjust" 10.0 1.0 15.0 1.0
|
||||
#define scanline params.scanline
|
||||
|
||||
|
@ -91,25 +67,25 @@ layout(push_constant) uniform Push
|
|||
#pragma parameter h_sharp "Horizontal Sharpness" 2.5 1.0 5.0 0.05
|
||||
#define h_sharp params.h_sharp
|
||||
|
||||
#pragma parameter shadowMask "CRT Mask: 0:CGWG, 1-4:Lottes, 5-6:Trinitron" 11.0 -1.0 11.0 1.0
|
||||
#pragma parameter shadowMask " CRT Mask: 0:CGWG, 1-4:Lottes, 5-6:Trinitron" 11.0 -1.0 11.0 1.0
|
||||
#define shadowMask params.shadowMask
|
||||
|
||||
#pragma parameter thres "Mask Effect Threshold" 0.4 0.0 0.9 0.02
|
||||
#pragma parameter thres " Mask Effect Threshold" 0.4 0.0 0.9 0.02
|
||||
#define thres params.thres
|
||||
|
||||
#pragma parameter masksize "CRT Mask Size (2.0 is nice in 4k)" 1.0 1.0 2.0 1.0
|
||||
#pragma parameter masksize " CRT Mask Size (2.0 is nice in 4k)" 1.0 1.0 2.0 1.0
|
||||
#define masksize params.masksize
|
||||
|
||||
#pragma parameter mcut "Mask 5-7-10 cutoff" 0.2 0.0 0.5 0.05
|
||||
#pragma parameter mcut " Mask 5-7-10 cutoff" 0.2 0.0 0.5 0.05
|
||||
#define mcut params.mcut
|
||||
|
||||
#pragma parameter maskDark "Lottes maskDark" 0.0 0.0 2.0 0.1
|
||||
#pragma parameter maskDark " Lottes maskDark" 0.0 0.0 2.0 0.1
|
||||
#define maskDark params.maskDark
|
||||
|
||||
#pragma parameter maskLight "Lottes maskLight" 1.5 0.0 2.0 0.1
|
||||
#pragma parameter maskLight " Lottes maskLight" 1.5 0.0 2.0 0.1
|
||||
#define maskLight params.maskLight
|
||||
|
||||
#pragma parameter CGWG "CGWG Mask Str." 1.0 0.0 1.0 0.1
|
||||
#pragma parameter CGWG " CGWG Mask Str." 1.0 0.0 1.0 0.1
|
||||
#define CGWG params.CGWG
|
||||
|
||||
#pragma parameter warpX "CurvatureX (default 0.03)" 0.0 0.0 0.25 0.01
|
||||
|
@ -121,6 +97,25 @@ layout(push_constant) uniform Push
|
|||
#pragma parameter vignette "Vignette On/Off" 0.0 0.0 1.0 1.0
|
||||
#define vignette params.vignette
|
||||
|
||||
#pragma parameter gamma_out_red " Gamma out Red" 2.2 1.0 4.0 0.1
|
||||
#define gamma_out_red params.gamma_out_red
|
||||
|
||||
#pragma parameter gamma_out_green " Gamma out Green" 2.2 1.0 4.0 0.1
|
||||
#define gamma_out_green params.gamma_out_green
|
||||
|
||||
#pragma parameter gamma_out_blue " Gamma out Blue" 2.2 1.0 4.0 0.1
|
||||
#define gamma_out_blue params.gamma_out_blue
|
||||
|
||||
#pragma parameter brightboost " Bright boost" 1.2 0.5 2.0 0.05
|
||||
#define brightboost params.brightboost
|
||||
|
||||
#pragma parameter sat " Saturation adjustment" 1.2 0.0 2.0 0.05
|
||||
#define sat params.sat
|
||||
|
||||
#pragma parameter glow "Glow Strength" 0.2 0.0 1.0 0.01
|
||||
#define glow params.glow
|
||||
|
||||
|
||||
#pragma parameter mono "Mono Display On/Off" 0.0 0.0 1.0 1.0
|
||||
#define mono params.mono
|
||||
|
||||
|
@ -372,8 +367,8 @@ mat3 vign( float l )
|
|||
vec2 vpos = vTexCoord;
|
||||
|
||||
vpos *= 1.0 - vpos.xy;
|
||||
float vig = vpos.x * vpos.y * 40.0;
|
||||
vig = min(pow(vig, 0.2), 1.0);
|
||||
float vig = vpos.x * vpos.y * 45.0;
|
||||
vig = min(pow(vig, 0.15), 1.0);
|
||||
if (vignette == 0.0) vig=1.0;
|
||||
|
||||
return mat3(vig, 0, 0,
|
||||
|
@ -439,62 +434,6 @@ vec3 glow0 (vec2 texcoord, vec3 col)
|
|||
|
||||
|
||||
|
||||
/////NTSC COLOR CONVERSION
|
||||
|
||||
vec3 DecodeGamma(vec3 color, float gamma)
|
||||
{
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
color.r = (color.r <= 0.00313066844250063) ?
|
||||
color.r * 12.92 : 1.055 * pow(color.r, 1.0 / gamma) - 0.055;
|
||||
color.g = (color.g <= 0.00313066844250063) ?
|
||||
color.g * 12.92 : 1.055 * pow(color.g, 1.0 / gamma) - 0.055;
|
||||
color.b = (color.b <= 0.00313066844250063) ?
|
||||
color.b * 12.92 : 1.055 * pow(color.b, 1.0 / gamma) - 0.055;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
||||
vec3 XYZtoSRGB(vec3 XYZ)
|
||||
{
|
||||
const mat3x3 m = mat3x3(
|
||||
3.2404542,-1.5371385,-0.4985314,
|
||||
-0.9692660, 1.8760108, 0.0415560,
|
||||
0.0556434,-0.2040259, 1.0572252);
|
||||
return XYZ * m;
|
||||
}
|
||||
|
||||
vec3 sRGB(vec3 c)
|
||||
{
|
||||
vec3 v = XYZtoSRGB(c);
|
||||
v = DecodeGamma(v, 2.4); //Companding
|
||||
|
||||
return v;
|
||||
}
|
||||
vec3 RGBtoXYZ(vec3 RGB)
|
||||
{
|
||||
const mat3x3 m = mat3x3(
|
||||
0.6068909, 0.1735011, 0.2003480,
|
||||
0.2989164, 0.5865990, 0.1144845,
|
||||
0.0000000, 0.0660957, 1.1162243);
|
||||
return RGB * m;
|
||||
}
|
||||
|
||||
// conversion from NTSC RGB Reference White D65 ( color space used by NA/Japan TV's ) to XYZ
|
||||
vec3 NTSC(vec3 c)
|
||||
{
|
||||
vec3 v = vec3(pow(c.r, 2.2), pow(c.g, 2.2), pow(c.b, 2.2)); //Inverse Companding
|
||||
return RGBtoXYZ(v);
|
||||
}
|
||||
|
||||
// NTSC RGB to sRGB
|
||||
vec3 NTSCtoSRGB( vec3 c )
|
||||
{
|
||||
return sRGB(NTSC( c ));
|
||||
}
|
||||
|
||||
////NTSC COLOR CONVERSION
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 pos = Warp(vTexCoord);
|
||||
|
@ -528,8 +467,8 @@ void main()
|
|||
float luma2 = color2.r*0.3+color2.g*0.6+color2.b*0.1;
|
||||
|
||||
|
||||
color1 = (2.0*pow(color1,vec3(2.9))) - pow(color1,vec3(3.8));
|
||||
color2 = (2.0*pow(color2,vec3(2.9))) - pow(color2,vec3(3.8));
|
||||
color1 = (2.0*pow(color1,vec3(2.8))) - pow(color1,vec3(3.6));
|
||||
color2 = (2.0*pow(color2,vec3(2.8))) - pow(color2,vec3(3.6));
|
||||
|
||||
color1 = color1 * mix(Mask(vTexCoord * global.OutputSize.xy, color1),vec3(1.0),luma1*thres);
|
||||
color2 = color2 * mix(Mask(vTexCoord * global.OutputSize.xy, color2),vec3(1.0),luma2*thres);
|
||||
|
@ -561,8 +500,6 @@ void main()
|
|||
}
|
||||
|
||||
else color = color;
|
||||
if (intensity != 0.0)
|
||||
color = mix(color.rgb, NTSCtoSRGB(color.rgb), intensity);
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ layout(push_constant) uniform Push
|
|||
float SHARPNESS;
|
||||
float SPEEDUP;
|
||||
float WP;
|
||||
float sat;
|
||||
|
||||
} params;
|
||||
|
||||
|
@ -28,10 +29,10 @@ layout(push_constant) uniform Push
|
|||
#pragma parameter warpY "warpY" 0.04 0.0 0.125 0.01
|
||||
#define warpY params.warpY
|
||||
|
||||
#pragma parameter corner_round "Corner Roundness" 0.030 0.005 0.100 0.005
|
||||
#pragma parameter corner_round "Corner Roundness" 0.020 0.005 0.100 0.01
|
||||
#define corner_round params.corner_round
|
||||
|
||||
#pragma parameter SHARPNESS "Blurriness" 0.5 0.0 0.5 0.01
|
||||
#pragma parameter SHARPNESS " Blurriness" 0.5 0.0 0.5 0.01
|
||||
#define SHARPNESS params.SHARPNESS
|
||||
|
||||
#pragma parameter SCANLINE "Scanline Intensity" 0.60 0.0 1.0 0.05
|
||||
|
@ -40,10 +41,13 @@ layout(push_constant) uniform Push
|
|||
#pragma parameter cgwg "CGWG mask brightness " 0.6 0.0 1.0 0.1
|
||||
#define cgwg params.cgwg
|
||||
|
||||
#pragma parameter boost "Bright boost " 1.00 1.00 2.00 0.02
|
||||
#pragma parameter boost " Bright boost " 1.00 1.00 2.00 0.02
|
||||
#define boost params.boost
|
||||
|
||||
#pragma parameter WP "Color Temperature" 0.0 -0.25 0.25 0.01
|
||||
#pragma parameter sat " Saturation" 1.0 0.0 2.0 0.05
|
||||
#define sat params.sat
|
||||
|
||||
#pragma parameter WP " Color Temperature" 0.0 -0.25 0.25 0.01
|
||||
#define WP params.WP
|
||||
|
||||
#pragma parameter SPEEDUP "Speed-up. Warp,Gamma,Corner disabled" 0.0 0.0 1.0 1.0
|
||||
|
@ -164,6 +168,12 @@ void main()
|
|||
if (SPEEDUP == 0.0 ) color = color*corner(tc);
|
||||
color.rgb *= vec3(1.0+WP,1.0,1.0-WP);
|
||||
|
||||
vec3 lumweight=vec3(0.3,0.6,0.1);
|
||||
float gray = dot(color,lumweight);
|
||||
vec3 graycolour = vec3(gray);
|
||||
color = vec3(mix(graycolour,color,sat));
|
||||
|
||||
|
||||
FragColor = vec4(color,1.0) ;
|
||||
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ layout(location = 1) out float maskFade;
|
|||
void main()
|
||||
{
|
||||
gl_Position = global.MVP * Position;
|
||||
vTexCoord = TexCoord;
|
||||
vTexCoord = TexCoord*1.0001;
|
||||
maskFade = 0.3333*MASK_FADE;
|
||||
}
|
||||
|
||||
|
@ -86,14 +86,14 @@ void main()
|
|||
float SCANAMOUNT = mix(HIGHSCANAMOUNT1,HIGHSCANAMOUNT2,lum);
|
||||
float scanLine = SCANAMOUNT * sin(2.0*pi*pos.y*params.SourceSize.y);
|
||||
|
||||
float whichmask = fract(gl_FragCoord.x*-0.4999);
|
||||
float whichmask = fract((pos.x*params.OutputSize.x)*0.4999);
|
||||
float mask = 1.0 + float(whichmask < 0.5) * -MASK_DARK;
|
||||
|
||||
//Gamma-like
|
||||
colour*=mix(2.0,1.0,lum);
|
||||
colour*=mix(1.5,1.0,lum);
|
||||
|
||||
colour = vec3(mix(graycolour,colour.rgb,sat));
|
||||
colour = vec3(mix(graycolour,colour,sat));
|
||||
|
||||
colour.rgb *= mix(mask*(1.0-scanLine), 1.0-scanLine, dot(colour.rgb,vec3(maskFade)));
|
||||
colour.rgb *= mix(mask*(1.0-scanLine), 1.0-scanLine, dot(colour,vec3(maskFade)));
|
||||
FragColor.rgb = colour.rgb;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue