move mame_hlsl port into crt directory; I guess it's as good as it's gonna get right now

This commit is contained in:
hunterk 2019-04-19 15:52:09 -05:00
parent 77d4efd688
commit 456d7f3c5d
19 changed files with 153 additions and 151 deletions

View File

@ -1,73 +1,76 @@
# info on how the passes come together can be found in mame/src/osd/modules/render/d3d/d3dhlsl.cpp
shaders = 12
shader0 = mame_ntsc.slang
shader0 = shaders/mame_hlsl/shaders/mame_ntsc.slang
filter_linear0 = true
alias0 = NTSCPass
scale_type0 = source
scale0 = 1.0
shader1 = mame_color.slang
shader1 = shaders/mame_hlsl/shaders/mame_color.slang
alias1 = ColorPass
scale_type1 = source
scale1 = 1.0
filter_linear1 = true
shader2 = ../../../../retro/shaders/sharp-bilinear.slang
shader2 = ../retro/shaders/sharp-bilinear.slang
alias2 = PrescalePass
scale_type2 = source
filter_linear2 = true
scale2 = 4.0
shader3 = mame_deconverge.slang
shader3 = shaders/mame_hlsl/shaders/mame_deconverge.slang
alias3 = DeconvergePass
filter_linear3 = true
scale_type3 = source
scale3 = 0.5
shader4 = mame_scanline.slang
shader4 = shaders/mame_hlsl/shaders/mame_scanline.slang
alias4 = ScanlinePass
filter_linear4 = true
scale_type4 = source
scale4 = 2.0
shader5 = mame_focus.slang
shader5 = shaders/mame_hlsl/shaders/mame_focus.slang
alias5 = FocusPass
filter_linear5 = true
shader6 = mame_phosphor.slang
shader6 = shaders/mame_hlsl/shaders/mame_phosphor.slang
alias6 = PhosphorPass
filter_linear6 = true
shader7 = mame_post.slang
shader7 = shaders/mame_hlsl/shaders/mame_post.slang
alias7 = PostPass
filter_linear7 = true
scale_type7 = viewport
shader8 = mame_chroma.slang
shader8 = shaders/mame_hlsl/shaders/mame_chroma.slang
alias8 = ChromaPass
filter_linear8 = true
scale_type8 = source
scale_type8 = viewport
shader9 = mame_downsample.slang
shader9 = shaders/mame_hlsl/shaders/mame_downsample.slang
alias9 = DownsamplePass
filter_linear9 = true
shader10 = mame_bloom.slang
shader10 = shaders/mame_hlsl/shaders/mame_bloom.slang
alias10 = BloomPass
filter_linear10 = true
mipmap_input10 = true
scale_type10 = source
shader11 = mame_distortion.slang
shader11 = shaders/mame_hlsl/shaders/mame_distortion.slang
alias11 = DistortionPass
filter_linear11 = true
shader12 = mame_vector.slang
alias12 = VectorPass
filter_linear12 = true
# doesn't work, so commenting
# shader12 = shaders/mame_hlsl/shaders/mame_vector.slang
# alias12 = VectorPass
# filter_linear12 = true
# mame's textures are available here: https://github.com/mamedev/mame/tree/master/artwork
textures = "MaskTexture"
MaskTexture = aperture-grille.png
MaskTexture = shaders/mame_hlsl/resources/aperture-grille.png
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"

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -96,9 +96,9 @@ vec3 GetNoiseFactor(vec3 n, float random)
{
// smaller n become more noisy
vec3 NoiseFactor;
NoiseFactor.x = 1.0f + random * max(0.0f, 0.25f * pow(E, -8. * n.x));
NoiseFactor.y = 1.0f + random * max(0.0f, 0.25f * pow(E, -8. * n.y));
NoiseFactor.z = 1.0f + random * max(0.0f, 0.25f * pow(E, -8. * n.z));
NoiseFactor.x = 1.0 + random * max(0.0, 0.25 * pow(E, -8. * n.x));
NoiseFactor.y = 1.0 + random * max(0.0, 0.25 * pow(E, -8. * n.y));
NoiseFactor.z = 1.0 + random * max(0.0, 0.25 * pow(E, -8. * n.z));
return NoiseFactor;
}
@ -111,36 +111,36 @@ void main()
}
else
{
vec3 texel = textureLod(DiffuseSampler, vTexCoord, 0.0).rgb;
vec3 texel = texture(DiffuseSampler, vTexCoord).rgb;
vec3 texelA = textureLod(BloomSamplerA, BloomCoord.xy, 1.0).rgb;
vec3 texelB = textureLod(BloomSamplerB, BloomCoord.xy, 2.0).rgb;
vec3 texelC = textureLod(BloomSamplerC, BloomCoord.xy, 3.0).rgb;
vec3 texelD = textureLod(BloomSamplerD, BloomCoord.xy, 4.0).rgb;
vec3 texelE = textureLod(BloomSamplerE, BloomCoord.xy, 5.0).rgb;
vec3 texelF = textureLod(BloomSamplerF, BloomCoord.xy, 6.0).rgb;
vec3 texelG = textureLod(BloomSamplerG, BloomCoord.xy, 7.0).rgb;
vec3 texelH = textureLod(BloomSamplerH, BloomCoord.xy, 8.0).rgb;
vec3 texelA = texture(BloomSamplerA, BloomCoord.xy).rgb;
vec3 texelB = texture(BloomSamplerB, BloomCoord.xy).rgb;
vec3 texelC = texture(BloomSamplerC, BloomCoord.xy).rgb;
vec3 texelD = texture(BloomSamplerD, BloomCoord.xy).rgb;
vec3 texelE = texture(BloomSamplerE, BloomCoord.xy).rgb;
vec3 texelF = texture(BloomSamplerF, BloomCoord.xy).rgb;
vec3 texelG = texture(BloomSamplerG, BloomCoord.xy).rgb;
vec3 texelH = texture(BloomSamplerH, BloomCoord.xy).rgb;
vec3 texelI = vec3(0.0f, 0.0f, 0.0f);
vec3 texelJ = vec3(0.0f, 0.0f, 0.0f);
vec3 texelK = vec3(0.0f, 0.0f, 0.0f);
vec3 texelL = vec3(0.0f, 0.0f, 0.0f);
vec3 texelM = vec3(0.0f, 0.0f, 0.0f);
vec3 texelN = vec3(0.0f, 0.0f, 0.0f);
vec3 texelO = vec3(0.0f, 0.0f, 0.0f);
vec3 texelI = vec3(0.0, 0.0, 0.0);
vec3 texelJ = vec3(0.0, 0.0, 0.0);
vec3 texelK = vec3(0.0, 0.0, 0.0);
vec3 texelL = vec3(0.0, 0.0, 0.0);
vec3 texelM = vec3(0.0, 0.0, 0.0);
vec3 texelN = vec3(0.0, 0.0, 0.0);
vec3 texelO = vec3(0.0, 0.0, 0.0);
// vector screen uses twice -1 as many bloom levels
if (VectorScreen)
{
texelI = textureLod(BloomSamplerI, BloomCoord.xy, 1.0).rgb;
texelJ = textureLod(BloomSamplerJ, BloomCoord.xy, 1.0).rgb;
texelK = textureLod(BloomSamplerK, BloomCoord.xy, 1.0).rgb;
texelL = textureLod(BloomSamplerL, BloomCoord.xy, 1.0).rgb;
texelM = textureLod(BloomSamplerM, BloomCoord.xy, 1.0).rgb;
texelN = textureLod(BloomSamplerN, BloomCoord.xy, 1.0).rgb;
texelO = textureLod(BloomSamplerO, BloomCoord.xy, 1.0).rgb;
texelI = texture(BloomSamplerI, BloomCoord.xy).rgb;
texelJ = texture(BloomSamplerJ, BloomCoord.xy).rgb;
texelK = texture(BloomSamplerK, BloomCoord.xy).rgb;
texelL = texture(BloomSamplerL, BloomCoord.xy).rgb;
texelM = texture(BloomSamplerM, BloomCoord.xy).rgb;
texelN = texture(BloomSamplerN, BloomCoord.xy).rgb;
texelO = texture(BloomSamplerO, BloomCoord.xy).rgb;
}
vec3 blend;
@ -148,7 +148,7 @@ void main()
// brighten
if (BloomBlendMode < 0.5)
{
vec3 bloom = vec3(0.0f, 0.0f, 0.0f);
vec3 bloom = vec3(0.0, 0.0, 0.0);
texel *= Level0Weight;
@ -167,35 +167,35 @@ void main()
else
{
bloom += texelA * (Level1Weight);
bloom += texelB * (Level1Weight + Level2Weight) * 0.5f;
bloom += texelB * (Level1Weight + Level2Weight) * 0.5;
bloom += texelC * (Level2Weight);
bloom += texelD * (Level2Weight + Level3Weight) * 0.5f;
bloom += texelD * (Level2Weight + Level3Weight) * 0.5;
bloom += texelE * (Level3Weight);
bloom += texelF * (Level3Weight + Level4Weight) * 0.5f;
bloom += texelF * (Level3Weight + Level4Weight) * 0.5;
bloom += texelG * (Level4Weight);
bloom += texelH * (Level4Weight + Level5Weight) * 0.5f;
bloom += texelH * (Level4Weight + Level5Weight) * 0.5;
bloom += texelI * (Level5Weight);
bloom += texelJ * (Level5Weight + Level6Weight) * 0.5f;
bloom += texelJ * (Level5Weight + Level6Weight) * 0.5;
bloom += texelK * (Level6Weight);
bloom += texelL * (Level6Weight + Level7Weight) * 0.5f;
bloom += texelL * (Level6Weight + Level7Weight) * 0.5;
bloom += texelM * (Level7Weight);
bloom += texelN * (Level7Weight + Level8Weight) * 0.5f;
bloom += texelN * (Level7Weight + Level8Weight) * 0.5;
bloom += texelO * (Level8Weight);
}
bloom *= BloomScale;
vec3 bloomOverdrive;
bloomOverdrive.r = max(0.0f, texel.r + bloom.r - 1.0f) * BloomOverdrive.r;
bloomOverdrive.g = max(0.0f, texel.g + bloom.g - 1.0f) * BloomOverdrive.g;
bloomOverdrive.b = max(0.0f, texel.b + bloom.b - 1.0f) * BloomOverdrive.b;
bloomOverdrive.r = max(0.0, texel.r + bloom.r - 1.0) * BloomOverdrive.r;
bloomOverdrive.g = max(0.0, texel.g + bloom.g - 1.0) * BloomOverdrive.g;
bloomOverdrive.b = max(0.0, texel.b + bloom.b - 1.0) * BloomOverdrive.b;
bloom.r += bloomOverdrive.g * 0.5f;
bloom.r += bloomOverdrive.b * 0.5f;
bloom.g += bloomOverdrive.r * 0.5f;
bloom.g += bloomOverdrive.b * 0.5f;
bloom.b += bloomOverdrive.r * 0.5f;
bloom.b += bloomOverdrive.g * 0.5f;
bloom.r += bloomOverdrive.g * 0.5;
bloom.r += bloomOverdrive.b * 0.5;
bloom.g += bloomOverdrive.r * 0.5;
bloom.g += bloomOverdrive.b * 0.5;
bloom.b += bloomOverdrive.r * 0.5;
bloom.b += bloomOverdrive.g * 0.5;
vec2 NoiseCoord = vTexCoord;
vec3 NoiseFactor = GetNoiseFactor(bloom, random(NoiseCoord));

View File

@ -34,9 +34,9 @@ layout(set = 0, binding = 2) uniform sampler2D Source;
#define DiffuseSampler Source
vec3 RedRatios = vec3(global.col_red, 0.0f, 0.0f);
vec3 GrnRatios = vec3(0.0f, global.col_grn, 0.0f);
vec3 BluRatios = vec3(0.0f, 0.0f, global.col_blu);
vec3 RedRatios = vec3(global.col_red, 0.0, 0.0);
vec3 GrnRatios = vec3(0.0, global.col_grn, 0.0);
vec3 BluRatios = vec3(0.0, 0.0, global.col_blu);
vec3 Offset = vec3(global.col_offset_x, global.col_offset_y, global.col_offset_z);
vec3 Scale = vec3(global.col_scale_x, global.col_scale_y, global.col_scale_z);
float Saturation = global.col_saturation;

View File

@ -33,25 +33,25 @@ void main()
gl_Position = global.MVP * Position;
// imaginary texel dimensions independed from screen dimension, but ratio
vec2 TexelDims = vec2(1.0f / 1024.);
vec2 TexelDims = vec2(1.0 / 1024.);
TexCoordX = TexCoord.xxx;
TexCoordY = TexCoord.yyy;
// center coordinates
TexCoordX -= 0.5f;
TexCoordY -= 0.5f;
TexCoordX -= 0.5;
TexCoordY -= 0.5;
// radial converge offset to "translate" the most outer pixel as thay would be translated by the linar converge with the same amount
vec2 radialConvergeOffset = vec2(2.0);
// radial converge
TexCoordX *= 1.0f + RadialConvergeX * TexelDims.xxx * radialConvergeOffset.xxx;
TexCoordY *= 1.0f + RadialConvergeY * TexelDims.yyy * radialConvergeOffset.yyy;
TexCoordX *= 1.0 + RadialConvergeX * TexelDims.xxx * radialConvergeOffset.xxx;
TexCoordY *= 1.0 + RadialConvergeY * TexelDims.yyy * radialConvergeOffset.yyy;
// un-center coordinates
TexCoordX += 0.5f;
TexCoordY += 0.5f;
TexCoordX += 0.5;
TexCoordY += 0.5;
// linear converge
TexCoordX += ConvergeX * TexelDims.xxx;

View File

@ -25,11 +25,11 @@ const int ScreenCount = 1;
// Constants
//-----------------------------------------------------------------------------
const float Epsilon = 1.0e-7f;
const float PI = 3.1415927f;
const float E = 2.7182817f;
const float Gelfond = 23.140692f; // e^pi (Gelfond constant)
const float GelfondSchneider = 2.6651442f; // 2^sqrt(2) (Gelfond-Schneider constant)
const float Epsilon = 1.0e-7;
const float PI = 3.1415927;
const float E = 2.7182817;
const float Gelfond = 23.140692; // e^pi (Gelfond constant)
const float GelfondSchneider = 2.6651442; // 2^sqrt(2) (Gelfond-Schneider constant)
//-----------------------------------------------------------------------------
// Functions
@ -41,20 +41,20 @@ float random(vec2 seed)
// irrationals for pseudo randomness
vec2 i = vec2(Gelfond, GelfondSchneider);
return fract(cos(dot(seed, i)) * 123456.0f);
return fract(cos(dot(seed, i)) * 123456.0);
}
// www.dinodini.wordpress.com/2010/04/05/normalized-tunable-sigmoid-functions/
float normalizedSigmoid(float n, float k)
{
// valid for n and k in range of -1.0 and 1.0
return (n - n * k) / (k - abs(n) * 2.0f * k + 1);
return (n - n * k) / (k - abs(n) * 2.0 * k + 1);
}
// www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
float roundBox(vec2 p, vec2 b, float r)
{
return length(max(abs(p) - b + r, 0.0f)) - r;
return length(max(abs(p) - b + r, 0.0)) - r;
}
#pragma stage vertex

View File

@ -25,10 +25,10 @@ layout(location = 1) in vec2 TexCoord;
layout(location = 0) out vec4 TexCoord01;
layout(location = 1) out vec4 TexCoord23;
const vec2 Coord0Offset = vec2(-0.5f, -0.5f);
const vec2 Coord1Offset = vec2( 0.5f, -0.5f);
const vec2 Coord2Offset = vec2(-0.5f, 0.5f);
const vec2 Coord3Offset = vec2( 0.5f, 0.5f);
const vec2 Coord0Offset = vec2(-0.5, -0.5);
const vec2 Coord1Offset = vec2( 0.5, -0.5);
const vec2 Coord2Offset = vec2(-0.5, 0.5);
const vec2 Coord3Offset = vec2( 0.5, 0.5);
void main()
{

View File

@ -41,30 +41,30 @@ vec2 Defocus = vec2(global.defocus_x, global.defocus_y);
const vec2 CoordOffset8[8] =
vec2[8](
// 0.075x² + 0.225x + 0.25
vec2(-1.60f, 0.25f),
vec2(-1.00f, -0.55f),
vec2(-0.55f, 1.00f),
vec2(-0.25f, -1.60f),
vec2( 0.25f, 1.60f),
vec2( 0.55f, -1.00f),
vec2( 1.00f, 0.55f),
vec2( 1.60f, -0.25f)
vec2(-1.60, 0.25),
vec2(-1.00, -0.55),
vec2(-0.55, 1.00),
vec2(-0.25, -1.60),
vec2( 0.25, 1.60),
vec2( 0.55, -1.00),
vec2( 1.00, 0.55),
vec2( 1.60, -0.25)
);
void main()
{
// imaginary texel dimensions independed from source and target dimension
vec2 TexelDims = vec2(1.0f / 1024.0f);
vec2 TexelDims = vec2(1.0 / 1024.0);
vec2 DefocusTexelDims = Defocus * TexelDims;
vec3 texel = texture(DiffuseSampler, vTexCoord).rgb;
float samples = 1.0f;
float samples = 1.0;
for (int i = 0; i < 8; i++)
{
texel += texture(DiffuseSampler, vTexCoord + CoordOffset8[i] * DefocusTexelDims).rgb;
samples += 1.0f;
samples += 1.0;
}
FragColor = vec4(texel / samples, 1.0);

View File

@ -68,7 +68,7 @@ float YFreqResponse = global.yfreqresponse;
float IFreqResponse = global.ifreqresponse;
float QFreqResponse = global.qfreqresponse;
float SignalOffset = global.signaloffset;
float SignalOffset = (global.signaloffset != 0.0) ? float(mod(params.FrameCount, 119)) : global.signaloffset;
vec4 GetCompositeYIQ(vec2 coord)
{

View File

@ -163,13 +163,12 @@ vec2 ScreenOffset = vec2(global.screenoffset_x, global.screenoffset_y);
bool SwapXY = bool(global.swapxy);
// Bloom Pass
#pragma parameter bloomtoggle "Bloom Enable" 0.0 0.0 1.0 1.0
#pragma parameter bloomblendmode "Bloom Blend Mode" 0.0 0.0 1.0 1.0
#pragma parameter bloomscale "Bloom Scale" 0.06 0.0 1.0 0.01
#pragma parameter bloomoverdrive_r "Bloom Overdrive R" 1.0 0.0 1.0 0.01
#pragma parameter bloomoverdrive_g "Bloom Overdrive G" 1.0 0.0 1.0 0.01
#pragma parameter bloomoverdrive_b "Bloom Overdrive B" 1.0 0.0 1.0 0.01
#pragma parameter level0weight "Bloom Level 0 Weight" 1.0 0.0 1.0 0.01
#pragma parameter bloomscale "Bloom Scale" 0.33 0.0 1.0 0.01
#pragma parameter bloomoverdrive_r "Bloom Overdrive R" 1.0 0.0 2.0 0.01
#pragma parameter bloomoverdrive_g "Bloom Overdrive G" 1.0 0.0 2.0 0.01
#pragma parameter bloomoverdrive_b "Bloom Overdrive B" 1.0 0.0 2.0 0.01
#pragma parameter level0weight "Bloom Level 0 Weight" 0.64 0.0 1.0 0.01
#pragma parameter level1weight "Bloom Level 1 Weight" 0.64 0.0 1.0 0.01
#pragma parameter level2weight "Bloom Level 2 Weight" 0.32 0.0 1.0 0.01
#pragma parameter level3weight "Bloom Level 3 Weight" 0.16 0.0 1.0 0.01
@ -207,43 +206,43 @@ bool SwapXY = bool(global.swapxy);
#pragma parameter preparebloom "Prepare Bloom" 0.0 0.0 1.0 1.0
// NTSC Pass
#pragma parameter avalue "A Value" 0.5 0.0 1.0 0.01
#pragma parameter bvalue "B Value" 0.5 0.0 1.0 0.01
#pragma parameter ccvalue "CC Value" 3.5795454 0.0 5.0 0.1
#pragma parameter ovalue "O Value" 0.0 -2.0 2.0 0.1
#pragma parameter pvalue "P Value" 1.0 -2.0 3.0 0.1
#pragma parameter scantime "Scan Time" 52.6 0.0 100.0 1.0
#pragma parameter notchhalfwidth "Notch Half Width" 1.0 0.0 5.0 0.5
#pragma parameter yfreqresponse "Y Freq Response" 6.0 0.0 10.0 0.1
#pragma parameter ifreqresponse "I Freq Response" 1.2 0.0 10.0 0.1
#pragma parameter qfreqresponse "Q Freq Response" 0.6 0.0 10.0 0.1
#pragma parameter signaloffset "Signal Offset" 0.0 -5.0 5.0 0.01
#pragma parameter avalue "A Value" 0.5 -1.0 1.0 0.01
#pragma parameter bvalue "B Value" 0.5 -1.0 1.0 0.01
#pragma parameter ccvalue "CC Value" 3.5795454 0.0 6.0 0.0005
#pragma parameter ovalue "O Value" 0.0 -3.0 3.0 0.1
#pragma parameter pvalue "P Value" 1.0 -3.0 3.0 0.1
#pragma parameter scantime "Scan Time" 52.6 0.0 100.0 0.1
#pragma parameter notchhalfwidth "Notch Half Width" 1.0 0.0 6.0 0.05
#pragma parameter yfreqresponse "Y Freq Response" 6.0 0.0 6.0 0.05
#pragma parameter ifreqresponse "I Freq Response" 1.2 0.0 6.0 0.05
#pragma parameter qfreqresponse "Q Freq Response" 0.6 0.0 6.0 0.05
#pragma parameter signaloffset "Signal Offset" 1.0 0.0 1.0 0.01
// Color Pass
#pragma parameter col_red "Red Shift" 1.0 0.0 1.0 0.01
#pragma parameter col_grn "Green Shift" 1.0 0.0 1.0 0.01
#pragma parameter col_blu "Blue Shift" 1.0 0.0 1.0 0.01
#pragma parameter col_offset_x "Offset X" 0.0 0.0 1.0 0.01
#pragma parameter col_offset_y "Offset Y" 0.0 0.0 1.0 0.01
#pragma parameter col_offset_z "Offset Z" 0.0 0.0 1.0 0.01
#pragma parameter col_scale_x "Scale X" 1.0 0.0 1.0 0.01
#pragma parameter col_scale_y "Scale Y" 1.0 0.0 1.0 0.01
#pragma parameter col_scale_z "Scale Z" 1.0 0.0 1.0 0.01
#pragma parameter col_saturation "Saturation" 1.0 0.0 0.01
#pragma parameter col_red "Red Shift" 1.0 0.0 2.0 0.01
#pragma parameter col_grn "Green Shift" 1.0 0.0 2.0 0.01
#pragma parameter col_blu "Blue Shift" 1.0 0.0 2.0 0.01
#pragma parameter col_offset_x "Offset X" 0.0 -1.0 1.0 0.01
#pragma parameter col_offset_y "Offset Y" 0.0 -1.0 1.0 0.01
#pragma parameter col_offset_z "Offset Z" 0.0 -1.0 1.0 0.01
#pragma parameter col_scale_x "Scale X" 1.0 0.0 2.0 0.01
#pragma parameter col_scale_y "Scale Y" 1.0 0.0 2.0 0.01
#pragma parameter col_scale_z "Scale Z" 1.0 0.0 2.0 0.01
#pragma parameter col_saturation "Saturation" 1.0 0.0 5.0 0.01
// Deconverge Pass
#pragma parameter converge_x_r "Convergence X Red" 0.0 -100.0 100.0 0.5
#pragma parameter converge_x_g "Convergence X Green" 0.0 -100.0 100.0 0.5
#pragma parameter converge_x_b "Convergence X Blue" 0.0 -100.0 100.0 0.5
#pragma parameter converge_y_r "Convergence Y Red" 0.0 -100.0 100.0 0.5
#pragma parameter converge_y_g "Convergence Y Green" 0.0 -100.0 100.0 0.5
#pragma parameter converge_y_b "Convergence Y Blue" 0.0 -100.0 100.0 0.5
#pragma parameter radial_conv_x_r "Radial Conv X Red" 0.0 -100.0 100.0 0.5
#pragma parameter radial_conv_x_g "Radial Conv X Green" 0.0 -100.0 100.0 0.5
#pragma parameter radial_conv_x_b "Radial Conv X Blue" 0.0 -100.0 100.0 0.5
#pragma parameter radial_conv_y_r "Radial Conv Y Red" 0.0 -100.0 100.0 0.5
#pragma parameter radial_conv_y_g "Radial Conv Y Green" 0.0 -100.0 100.0 0.5
#pragma parameter radial_conv_y_b "Radial Conv Y Blue" 0.0 -100.0 100.0 0.5
#pragma parameter converge_x_r "Convergence X Red" 0.0 -10.0 10.0 0.05
#pragma parameter converge_x_g "Convergence X Green" 0.0 -10.0 10.0 0.05
#pragma parameter converge_x_b "Convergence X Blue" 0.0 -10.0 10.0 0.05
#pragma parameter converge_y_r "Convergence Y Red" 0.0 -10.0 10.0 0.05
#pragma parameter converge_y_g "Convergence Y Green" 0.0 -10.0 10.0 0.05
#pragma parameter converge_y_b "Convergence Y Blue" 0.0 -10.0 10.0 0.05
#pragma parameter radial_conv_x_r "Radial Conv X Red" 0.0 -10.0 10.0 0.05
#pragma parameter radial_conv_x_g "Radial Conv X Green" 0.0 -10.0 10.0 0.05
#pragma parameter radial_conv_x_b "Radial Conv X Blue" 0.0 -10.0 10.0 0.05
#pragma parameter radial_conv_y_r "Radial Conv Y Red" 0.0 -10.0 10.0 0.05
#pragma parameter radial_conv_y_g "Radial Conv Y Green" 0.0 -10.0 10.0 0.05
#pragma parameter radial_conv_y_b "Radial Conv Y Blue" 0.0 -10.0 10.0 0.05
// Scanline Pass
#pragma parameter scanlinealpha "Scanline Alpha" 0.5 0.0 1.0 0.01

View File

@ -21,8 +21,8 @@ layout(push_constant) uniform Push
// Constants
//-----------------------------------------------------------------------------
const float PI = 3.1415927f;
const float HalfPI = PI * 0.5f;
const float PI = 3.1415927;
const float HalfPI = PI * 0.5;
//-----------------------------------------------------------------------------
// Scanline Pixel Shader
@ -42,13 +42,13 @@ vec2 SourceDims = params.OriginalSize.xy;
vec2 GetAdjustedCoords(vec2 coord)
{
// center coordinates
coord -= 0.5f;
coord -= 0.5;
// apply screen scale
coord *= ScreenScale;
// un-center coordinates
coord += 0.5f;
coord += 0.5;
// apply screen offset
coord += ScreenOffset;
@ -87,38 +87,38 @@ void main()
// Color
vec4 BaseColor = texture(DiffuseSampler, BaseCoord);
BaseColor.a = 1.0f;
BaseColor.a = 1.0;
/*
// clip border
if (BaseCoord.x < 0.0f || BaseCoord.y < 0.0f ||
BaseCoord.x > 1.0f || BaseCoord.y > 1.0f)
if (BaseCoord.x < 0.0 || BaseCoord.y < 0.0 ||
BaseCoord.x > 1.0 || BaseCoord.y > 1.0)
{
// we don't use the clip function, because we don't clear the render target before
return vec4(0.0f, 0.0f, 0.0f, 1.0f);
return vec4(0.0, 0.0, 0.0, 1.0);
}
*/
float BrightnessOffset = (ScanlineBrightOffset * ScanlineAlpha);
float BrightnessScale = (ScanlineBrightScale * ScanlineAlpha) + (1.0f - ScanlineAlpha);
float BrightnessScale = (ScanlineBrightScale * ScanlineAlpha) + (1.0 - ScanlineAlpha);
float ColorBrightness = 0.299f * BaseColor.r + 0.587f * BaseColor.g + 0.114 * BaseColor.b;
float ColorBrightness = 0.299 * BaseColor.r + 0.587 * BaseColor.g + 0.114 * BaseColor.b;
float ScanlineCoord = BaseCoord.y;
ScanlineCoord += (SwapXY)
? 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.0f
: QuadDims.y <= SourceDims.y * 2.0f
? 0.5f / QuadDims.y // uncenter scanlines if the quad is less than twice the size of the source
: 0.0f;
? QuadDims.x <= SourceDims.x * 2.0
? 0.5 / QuadDims.x // uncenter scanlines if the quad is less than twice the size of the source
: 0.0
: QuadDims.y <= SourceDims.y * 2.0
? 0.5 / QuadDims.y // uncenter scanlines if the quad is less than twice the size of the source
: 0.0;
ScanlineCoord *= SourceDims.y * ScanlineScale * PI;
float ScanlineCoordJitter = ScanlineOffset * HalfPI;
float ScanlineSine = sin(ScanlineCoord + ScanlineCoordJitter);
float ScanlineWide = ScanlineHeight + ScanlineVariation * max(1.0f, ScanlineHeight) * (1.0f - ColorBrightness);
float ScanlineWide = ScanlineHeight + ScanlineVariation * max(1.0f, ScanlineHeight) * (1.0 - ColorBrightness);
float ScanlineAmount = pow(ScanlineSine * ScanlineSine, ScanlineWide);
float ScanlineBrightness = ScanlineAmount * BrightnessScale + BrightnessOffset * BrightnessScale;
BaseColor.rgb *= mix(1.0f, ScanlineBrightness, ScanlineAlpha);
BaseColor.rgb *= mix(1.0, ScanlineBrightness, ScanlineAlpha);
FragColor = BaseColor;
}