mirror of
https://github.com/italicsjenga/slang-shaders.git
synced 2024-11-22 15:51:30 +11:00
update crt-aperture and mame-hlsl
This commit is contained in:
parent
7f6bb268f0
commit
caac993e37
|
@ -21,6 +21,8 @@ layout(push_constant) uniform Push
|
||||||
float MASK_SIZE;
|
float MASK_SIZE;
|
||||||
float SCANLINE_SIZE_MIN;
|
float SCANLINE_SIZE_MIN;
|
||||||
float SCANLINE_SIZE_MAX;
|
float SCANLINE_SIZE_MAX;
|
||||||
|
float SCANLINE_SHAPE;
|
||||||
|
float SCANLINE_OFFSET;
|
||||||
float GAMMA_INPUT;
|
float GAMMA_INPUT;
|
||||||
float GAMMA_OUTPUT;
|
float GAMMA_OUTPUT;
|
||||||
float BRIGHTNESS;
|
float BRIGHTNESS;
|
||||||
|
@ -37,6 +39,8 @@ layout(push_constant) uniform Push
|
||||||
#pragma parameter MASK_SIZE "Mask Size" 1.0 1.0 9.0 1.0
|
#pragma parameter MASK_SIZE "Mask Size" 1.0 1.0 9.0 1.0
|
||||||
#pragma parameter SCANLINE_SIZE_MIN "Scanline Size Min." 0.5 0.5 1.5 0.05
|
#pragma parameter SCANLINE_SIZE_MIN "Scanline Size Min." 0.5 0.5 1.5 0.05
|
||||||
#pragma parameter SCANLINE_SIZE_MAX "Scanline Size Max." 1.5 0.5 1.5 0.05
|
#pragma parameter SCANLINE_SIZE_MAX "Scanline Size Max." 1.5 0.5 1.5 0.05
|
||||||
|
#pragma parameter SCANLINE_SHAPE "Scanline Shape" 2.5 1.0 100.0 0.1
|
||||||
|
#pragma parameter SCANLINE_OFFSET "Scanline Offset" 1.0 0.0 1.0 1.0
|
||||||
#pragma parameter GAMMA_INPUT "Gamma Input" 2.4 1.0 5.0 0.1
|
#pragma parameter GAMMA_INPUT "Gamma Input" 2.4 1.0 5.0 0.1
|
||||||
#pragma parameter GAMMA_OUTPUT "Gamma Output" 2.4 1.0 5.0 0.1
|
#pragma parameter GAMMA_OUTPUT "Gamma Output" 2.4 1.0 5.0 0.1
|
||||||
#pragma parameter BRIGHTNESS "Brightness" 1.5 0.0 2.0 0.05
|
#pragma parameter BRIGHTNESS "Brightness" 1.5 0.0 2.0 0.05
|
||||||
|
@ -56,7 +60,7 @@ mat3x3 get_color_matrix(sampler2D tex, vec2 co, vec2 dx)
|
||||||
return mat3x3(TEX2D(co - dx), TEX2D(co), TEX2D(co + dx));
|
return mat3x3(TEX2D(co - dx), TEX2D(co), TEX2D(co + dx));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 blur(mat3x3 m, float dist, float rad)
|
vec3 blur(mat3 m, float dist, float rad)
|
||||||
{
|
{
|
||||||
vec3 x = vec3(dist - 1.0, dist, dist + 1.0) / rad;
|
vec3 x = vec3(dist - 1.0, dist, dist + 1.0) / rad;
|
||||||
vec3 w = exp2(x * x * -1.0);
|
vec3 w = exp2(x * x * -1.0);
|
||||||
|
@ -104,7 +108,7 @@ vec3 filter_lanczos(sampler2D tex, vec2 co, vec2 tex_size, float sharp)
|
||||||
|
|
||||||
vec3 get_scanline_weight(float x, vec3 col)
|
vec3 get_scanline_weight(float x, vec3 col)
|
||||||
{
|
{
|
||||||
vec3 beam = mix(vec3(params.SCANLINE_SIZE_MIN), vec3(params.SCANLINE_SIZE_MAX), col);
|
vec3 beam = mix(vec3(params.SCANLINE_SIZE_MIN), vec3(params.SCANLINE_SIZE_MAX), pow(col, vec3(1.0 / params.SCANLINE_SHAPE)));
|
||||||
vec3 x_mul = 2.0 / beam;
|
vec3 x_mul = 2.0 / beam;
|
||||||
vec3 x_offset = x_mul * 0.5;
|
vec3 x_offset = x_mul * 0.5;
|
||||||
|
|
||||||
|
@ -138,12 +142,18 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec3 col_glow = filter_gaussian(Source, vTexCoord, params.SourceSize.xy);
|
float scale = floor(params.OutputSize.y * params.SourceSize.w);
|
||||||
vec3 col_soft = filter_lanczos(Source, vTexCoord, params.SourceSize.xy, params.SHARPNESS_IMAGE);
|
float offset = 1.0 / scale * 0.5;
|
||||||
vec3 col_sharp = filter_lanczos(Source, vTexCoord, params.SourceSize.xy, params.SHARPNESS_EDGES);
|
|
||||||
|
if (bool(mod(scale, 2.0))) offset = 0.0;
|
||||||
|
|
||||||
|
vec2 co = (vTexCoord * params.SourceSize.xy - vec2(0.0, offset * params.SCANLINE_OFFSET)) * params.SourceSize.zw;
|
||||||
|
vec3 col_glow = filter_gaussian(Source, co, params.SourceSize.xy);
|
||||||
|
vec3 col_soft = filter_lanczos(Source, co, params.SourceSize.xy, params.SHARPNESS_IMAGE);
|
||||||
|
vec3 col_sharp = filter_lanczos(Source, co, params.SourceSize.xy, params.SHARPNESS_EDGES);
|
||||||
vec3 col = sqrt(col_sharp * col_soft);
|
vec3 col = sqrt(col_sharp * col_soft);
|
||||||
|
|
||||||
col *= get_scanline_weight(fract(vTexCoord.y * params.SourceSize.y), col_soft);
|
col *= get_scanline_weight(fract(co.y * params.SourceSize.y), col_soft);
|
||||||
col_glow = saturate(col_glow - col);
|
col_glow = saturate(col_glow - col);
|
||||||
col += col_glow * col_glow * params.GLOW_HALATION;
|
col += col_glow * col_glow * params.GLOW_HALATION;
|
||||||
col = mix(col, col * get_mask_weight(vTexCoord.x) * params.MASK_COLORS, params.MASK_STRENGTH);
|
col = mix(col, col * get_mask_weight(vTexCoord.x) * params.MASK_COLORS, params.MASK_STRENGTH);
|
||||||
|
|
|
@ -12,6 +12,7 @@ layout(push_constant) uniform Push
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
uint FrameCount;
|
uint FrameCount;
|
||||||
|
vec4 FinalViewportSize;
|
||||||
} params;
|
} params;
|
||||||
|
|
||||||
#include "mame_parameters.inc"
|
#include "mame_parameters.inc"
|
||||||
|
@ -83,8 +84,8 @@ float VignettingAmount = global.vignette_amount;
|
||||||
float ReflectionAmount = global.reflection_amount;
|
float ReflectionAmount = global.reflection_amount;
|
||||||
vec3 LightReflectionColor = vec3(global.reflection_col_r, global.reflection_col_g, global.reflection_col_b); // color temperature 5.000 Kelvin
|
vec3 LightReflectionColor = vec3(global.reflection_col_r, global.reflection_col_g, global.reflection_col_b); // color temperature 5.000 Kelvin
|
||||||
|
|
||||||
vec2 QuadDims = params.SourceSize.xy;
|
vec2 QuadDims = params.OutputSize.xy;
|
||||||
vec2 TargetDims = params.OutputSize.xy;
|
vec2 TargetDims = params.FinalViewportSize.xy;
|
||||||
float TargetScale = 1.0;
|
float TargetScale = 1.0;
|
||||||
|
|
||||||
float GetNoiseFactor(vec3 n, float random)
|
float GetNoiseFactor(vec3 n, float random)
|
||||||
|
|
|
@ -22,11 +22,14 @@ scale2 = 4.0
|
||||||
shader3 = mame_deconverge.slang
|
shader3 = mame_deconverge.slang
|
||||||
alias3 = DeconvergePass
|
alias3 = DeconvergePass
|
||||||
filter_linear3 = true
|
filter_linear3 = true
|
||||||
|
scale_type3 = source
|
||||||
|
scale3 = 0.5
|
||||||
|
|
||||||
shader4 = mame_scanline.slang
|
shader4 = mame_scanline.slang
|
||||||
alias4 = ScanlinePass
|
alias4 = ScanlinePass
|
||||||
filter_linear4 = true
|
filter_linear4 = true
|
||||||
scale_type4 = viewport
|
scale_type4 = source
|
||||||
|
scale4 = 2.0
|
||||||
|
|
||||||
shader5 = mame_focus.slang
|
shader5 = mame_focus.slang
|
||||||
alias5 = FocusPass
|
alias5 = FocusPass
|
||||||
|
@ -43,15 +46,16 @@ filter_linear7 = true
|
||||||
shader8 = mame_chroma.slang
|
shader8 = mame_chroma.slang
|
||||||
alias8 = ChromaPass
|
alias8 = ChromaPass
|
||||||
filter_linear8 = true
|
filter_linear8 = true
|
||||||
|
scale_type8 = source
|
||||||
|
|
||||||
shader9 = mame_downsample.slang
|
shader9 = mame_downsample.slang
|
||||||
alias9 = DownsamplePass
|
alias9 = DownsamplePass
|
||||||
filter_linear9 = true
|
filter_linear9 = true
|
||||||
mipmap_input9 = true
|
|
||||||
|
|
||||||
shader10 = mame_bloom.slang
|
shader10 = mame_bloom.slang
|
||||||
alias10 = BloomPass
|
alias10 = BloomPass
|
||||||
filter_linear10 = true
|
filter_linear10 = true
|
||||||
|
mipmap_input10 = true
|
||||||
|
|
||||||
shader11 = mame_distortion.slang
|
shader11 = mame_distortion.slang
|
||||||
alias11 = DistortionPass
|
alias11 = DistortionPass
|
||||||
|
@ -63,7 +67,7 @@ filter_linear12 = true
|
||||||
|
|
||||||
# mame's textures are available here: https://github.com/mamedev/mame/tree/master/artwork
|
# mame's textures are available here: https://github.com/mamedev/mame/tree/master/artwork
|
||||||
textures = "MaskTexture"
|
textures = "MaskTexture"
|
||||||
MaskTexture = slot-mask.png
|
MaskTexture = aperture-grille.png
|
||||||
|
|
||||||
parameters = "AUTO_PRESCALE;chromaa_x;chromaa_y;chromab_x;chromab_y;chromac_x;chromac_y;ygain_r;ygain_g;ygain_b"
|
parameters = "AUTO_PRESCALE;chromaa_x;chromaa_y;chromab_x;chromab_y;chromac_x;chromac_y;ygain_r;ygain_g;ygain_b"
|
||||||
chromaa_x = "0.630"
|
chromaa_x = "0.630"
|
||||||
|
|
|
@ -54,7 +54,7 @@ layout(location = 0) out vec4 FragColor;
|
||||||
layout(set = 0, binding = 2) uniform sampler2D Source;
|
layout(set = 0, binding = 2) uniform sampler2D Source;
|
||||||
|
|
||||||
#define DiffuseSampler Source
|
#define DiffuseSampler Source
|
||||||
#define SourceDims params.SourceSize.xy
|
#define SourceDims params.OriginalSize.xy
|
||||||
|
|
||||||
float AValue = global.avalue;
|
float AValue = global.avalue;
|
||||||
float BValue = global.bvalue;
|
float BValue = global.bvalue;
|
||||||
|
|
|
@ -148,7 +148,7 @@ bool Chromaticity = bool(global.chromatoggle);
|
||||||
#pragma parameter distortiontoggle "Distortion Toggle" 0.0 0.0 1.0 1.0
|
#pragma parameter distortiontoggle "Distortion Toggle" 0.0 0.0 1.0 1.0
|
||||||
bool Distortion = bool(global.distortiontoggle);
|
bool Distortion = bool(global.distortiontoggle);
|
||||||
#pragma parameter phosphortoggle "Phosphor Toggle" 0.0 0.0 1.0 1.0
|
#pragma parameter phosphortoggle "Phosphor Toggle" 0.0 0.0 1.0 1.0
|
||||||
bool Passthrough = bool(global.phosphortoggle);
|
bool Passthrough = !bool(global.phosphortoggle);
|
||||||
#pragma parameter screenscale_x "Screen Scale X" 1.0 0.5 3.0 0.01
|
#pragma parameter screenscale_x "Screen Scale X" 1.0 0.5 3.0 0.01
|
||||||
#pragma parameter screenscale_y "Screen Scale Y" 1.0 0.5 3.0 0.01
|
#pragma parameter screenscale_y "Screen Scale Y" 1.0 0.5 3.0 0.01
|
||||||
vec2 ScreenScale = vec2(global.screenscale_x, global.screenscale_y);
|
vec2 ScreenScale = vec2(global.screenscale_x, global.screenscale_y);
|
||||||
|
@ -247,7 +247,7 @@ bool SwapXY = bool(global.swapxy);
|
||||||
|
|
||||||
// Scanline Pass
|
// Scanline Pass
|
||||||
#pragma parameter scanlinealpha "Scanline Alpha" 0.5 0.0 1.0 0.01
|
#pragma parameter scanlinealpha "Scanline Alpha" 0.5 0.0 1.0 0.01
|
||||||
#pragma parameter scanlinescale "Scanline Scale" 1.0 1.0 5.0 1.0
|
#pragma parameter scanlinescale "Scanline Scale" 5.0 1.0 5.0 1.0
|
||||||
#pragma parameter scanlineheight "Scanline Height" 1.0 0.0 2.0 0.1
|
#pragma parameter scanlineheight "Scanline Height" 1.0 0.0 2.0 0.1
|
||||||
#pragma parameter scanlinevariation "Scanline Variation" 1.0 0.0 5.0 0.5
|
#pragma parameter scanlinevariation "Scanline Variation" 1.0 0.0 5.0 0.5
|
||||||
#pragma parameter scanlineoffset "Scanline Offset" 1.0 -1.5 3.0 0.1
|
#pragma parameter scanlineoffset "Scanline Offset" 1.0 -1.5 3.0 0.1
|
||||||
|
|
|
@ -12,6 +12,7 @@ layout(push_constant) uniform Push
|
||||||
vec4 OriginalSize;
|
vec4 OriginalSize;
|
||||||
vec4 OutputSize;
|
vec4 OutputSize;
|
||||||
uint FrameCount;
|
uint FrameCount;
|
||||||
|
vec4 FinalViewportSize;
|
||||||
} params;
|
} params;
|
||||||
|
|
||||||
#include "mame_parameters.inc"
|
#include "mame_parameters.inc"
|
||||||
|
@ -35,8 +36,8 @@ float ScanlineOffset = global.scanlineoffset;
|
||||||
float ScanlineBrightScale = global.scanlinebrightscale;
|
float ScanlineBrightScale = global.scanlinebrightscale;
|
||||||
float ScanlineBrightOffset = global.scanlinebrightoffset;
|
float ScanlineBrightOffset = global.scanlinebrightoffset;
|
||||||
|
|
||||||
vec2 QuadDims = params.SourceSize.xy;
|
vec2 QuadDims = params.FinalViewportSize.xy;
|
||||||
vec2 SourceDims = params.SourceSize.xy;
|
vec2 SourceDims = params.OriginalSize.xy;
|
||||||
|
|
||||||
vec2 GetAdjustedCoords(vec2 coord)
|
vec2 GetAdjustedCoords(vec2 coord)
|
||||||
{
|
{
|
||||||
|
@ -102,7 +103,7 @@ void main()
|
||||||
float ColorBrightness = 0.299f * BaseColor.r + 0.587f * BaseColor.g + 0.114 * BaseColor.b;
|
float ColorBrightness = 0.299f * BaseColor.r + 0.587f * BaseColor.g + 0.114 * BaseColor.b;
|
||||||
|
|
||||||
float ScanlineCoord = BaseCoord.y;
|
float ScanlineCoord = BaseCoord.y;
|
||||||
ScanlineCoord += SwapXY
|
ScanlineCoord += (SwapXY)
|
||||||
? QuadDims.x <= SourceDims.x * 2.0f
|
? QuadDims.x <= SourceDims.x * 2.0f
|
||||||
? 0.5f / QuadDims.x // uncenter scanlines if the quad is less than twice the size of the source
|
? 0.5f / QuadDims.x // uncenter scanlines if the quad is less than twice the size of the source
|
||||||
: 0.0f
|
: 0.0f
|
||||||
|
|
Loading…
Reference in a new issue