summaryrefslogtreecommitdiffstats
path: root/hlsl
diff options
context:
space:
mode:
authorGravatarGravatar ImJezze <jezze@gmx.net>2016-02-07 13:32:34 +0100
committerGravatarGravatar ImJezze <jezze@gmx.net>2016-02-07 13:32:34 +0100
commitf5e3032d98257ceaa7800251139f3c6df98f13e8 (patch) (github)
treeb74d7e8c4d52fd0f313c94f530e206c12d60bb1e /hlsl
parent801956ff64182612392a57b23e04d12d893d1a5a (diff)
downloadmame-f5e3032d98257ceaa7800251139f3c6df98f13e8.tar.bz2
mame-f5e3032d98257ceaa7800251139f3c6df98f13e8.zip
Improved Scanline Simulation
- changed the amount of scanline darkness, a setting of 1.0 now becomes fully black (to get the same result as before half your current setting) - scanline height now depends on the brightness of the underlying color - the amount of the scanline brightness and overdrive now depends on the scanline darkness - renamed 'Scanline Screen Height' to 'Scanline Screen Scale' and 'Scanline Indiv. Height' to 'Scanline Height'
Diffstat (limited to 'hlsl')
-rw-r--r--hlsl/artwork_support/post.fx26
-rw-r--r--hlsl/post.fx26
2 files changed, 32 insertions, 20 deletions
diff --git a/hlsl/artwork_support/post.fx b/hlsl/artwork_support/post.fx
index 9a3b693cd61..7547d109788 100644
--- a/hlsl/artwork_support/post.fx
+++ b/hlsl/artwork_support/post.fx
@@ -152,7 +152,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
// Scanline, Shadowmask & Distortion Pixel Shader
//-----------------------------------------------------------------------------
-uniform float HumBarHertzRate = 60.0f / 59.94f - 1.0f; // difference between the 59.94 Hz field rate and 60 Hz line frequency (NTSC)
+uniform float HumBarDesync = 60.0f / 59.94f - 1.0f; // difference between the 59.94 Hz field rate and 60 Hz line frequency (NTSC)
uniform float HumBarAlpha = 0.0f;
uniform float TimeMilliseconds = 0.0f;
@@ -464,21 +464,27 @@ float4 ps_main(PS_INPUT Input) : COLOR
// Scanline Simulation (may not affect vector screen)
if (!PrepareVector && ScanlineAlpha > 0.0f)
{
- float ScanCoord = BaseCoord.y * SourceDims.y * ScanlineScale * PI;
- float ScanCoordJitter = ScanlineOffset * PHI;
- float ScanSine = sin(ScanCoord + ScanCoordJitter);
- float ScanSineScaled = pow(ScanSine * ScanSine, ScanlineHeight);
- float ScanBrightness = ScanSineScaled * ScanlineBrightScale + 1.0f + ScanlineBrightOffset;
+ float BrightnessOffset = (ScanlineBrightOffset * ScanlineAlpha);
+ float BrightnessScale = (ScanlineBrightScale * ScanlineAlpha) + (1.0f - ScanlineAlpha);
- BaseColor.rgb *= lerp(1.0f, ScanBrightness * 0.5f, ScanlineAlpha);
+ float ColorBrightness = 0.299f * BaseColor.r + 0.587f * BaseColor.g + 0.114 * BaseColor.b;
+
+ float ScanlineCoord = BaseCoord.y * SourceDims.y * ScanlineScale * PI;
+ float ScanlineCoordJitter = ScanlineOffset * PHI;
+ float ScanlineSine = sin(ScanlineCoord + ScanlineCoordJitter);
+ float ScanlineWide = ScanlineHeight + max(1.0f, ScanlineHeight) * (1.0f - ColorBrightness);
+ float ScanlineAmount = pow(ScanlineSine * ScanlineSine, ScanlineWide);
+ float ScanlineBrightness = ScanlineAmount * BrightnessScale + BrightnessOffset * BrightnessScale;
+
+ BaseColor.rgb *= lerp(1.0f, ScanlineBrightness, ScanlineAlpha);
}
// Hum Bar Simulation (may not affect vector screen)
if (!PrepareVector && HumBarAlpha > 0.0f)
{
- float HumTimeStep = frac(TimeMilliseconds * HumBarHertzRate);
- float HumBrightness = 1.0 - frac(BaseCoord.y / SourceRect.y + HumTimeStep) * HumBarAlpha;
- BaseColor.rgb *= HumBrightness;
+ float HumBarStep = frac(TimeMilliseconds * HumBarDesync);
+ float HumBarBrightness = 1.0 - frac(BaseCoord.y / SourceRect.y + HumBarStep) * HumBarAlpha;
+ BaseColor.rgb *= HumBarBrightness;
}
}
diff --git a/hlsl/post.fx b/hlsl/post.fx
index deec349e2fc..7bd698c4bb6 100644
--- a/hlsl/post.fx
+++ b/hlsl/post.fx
@@ -119,7 +119,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
// Scanline & Shadowmask Pixel Shader
//-----------------------------------------------------------------------------
-uniform float HumBarHertzRate = 60.0f / 59.94f - 1.0f; // difference between the 59.94 Hz field rate and 60 Hz line frequency (NTSC)
+uniform float HumBarDesync = 60.0f / 59.94f - 1.0f; // difference between the 59.94 Hz field rate and 60 Hz line frequency (NTSC)
uniform float HumBarAlpha = 0.0f;
uniform float TimeMilliseconds = 0.0f;
@@ -244,21 +244,27 @@ float4 ps_main(PS_INPUT Input) : COLOR
// Scanline Simulation (may not affect vector screen)
if (!PrepareVector && ScanlineAlpha > 0.0f)
{
- float ScanCoord = BaseCoord.y * SourceDims.y * ScanlineScale * PI;
- float ScanCoordJitter = ScanlineOffset * PHI;
- float ScanSine = sin(ScanCoord + ScanCoordJitter);
- float ScanSineScaled = pow(ScanSine * ScanSine, ScanlineHeight);
- float ScanBrightness = ScanSineScaled * ScanlineBrightScale + 1.0f + ScanlineBrightOffset;
+ float BrightnessOffset = (ScanlineBrightOffset * ScanlineAlpha);
+ float BrightnessScale = (ScanlineBrightScale * ScanlineAlpha) + (1.0f - ScanlineAlpha);
- BaseColor.rgb *= lerp(1.0f, ScanBrightness * 0.5f, ScanlineAlpha);
+ float ColorBrightness = 0.299f * BaseColor.r + 0.587f * BaseColor.g + 0.114 * BaseColor.b;
+
+ float ScanlineCoord = BaseCoord.y * SourceDims.y * ScanlineScale * PI;
+ float ScanlineCoordJitter = ScanlineOffset * PHI;
+ float ScanlineSine = sin(ScanlineCoord + ScanlineCoordJitter);
+ float ScanlineWide = ScanlineHeight + max(1.0f, ScanlineHeight) * (1.0f - ColorBrightness);
+ float ScanlineAmount = pow(ScanlineSine * ScanlineSine, ScanlineWide);
+ float ScanlineBrightness = ScanlineAmount * BrightnessScale + BrightnessOffset * BrightnessScale;
+
+ BaseColor.rgb *= lerp(1.0f, ScanlineBrightness, ScanlineAlpha);
}
// Hum Bar Simulation (may not affect vector screen)
if (!PrepareVector && HumBarAlpha > 0.0f)
{
- float HumTimeStep = frac(TimeMilliseconds * HumBarHertzRate);
- float HumBrightness = 1.0 - frac(BaseCoord.y / SourceRect.y + HumTimeStep) * HumBarAlpha;
- BaseColor.rgb *= HumBrightness;
+ float HumBarStep = frac(TimeMilliseconds * HumBarDesync);
+ float HumBarBrightness = 1.0 - frac(BaseCoord.y / SourceRect.y + HumBarStep) * HumBarAlpha;
+ BaseColor.rgb *= HumBarBrightness;
}
}