mirror of
https://github.com/mamedev/mame.git
synced 2024-11-16 07:48:32 +01:00
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'
This commit is contained in:
parent
801956ff64
commit
f5e3032d98
3 changed files with 40 additions and 28 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
26
hlsl/post.fx
26
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2375,25 +2375,25 @@ static INT32 slider_scanline_alpha(running_machine &machine, void *arg, std::str
|
|||
static INT32 slider_scanline_scale(running_machine &machine, void *arg, std::string *str, INT32 newval)
|
||||
{
|
||||
((hlsl_options*)arg)->params_dirty = true;
|
||||
return slider_set(&(((hlsl_options*)arg)->scanline_scale), 0.05f, "%2.2f", str, newval);
|
||||
return slider_set(&(((hlsl_options*)arg)->scanline_scale), 0.01f, "%2.2f", str, newval);
|
||||
}
|
||||
|
||||
static INT32 slider_scanline_height(running_machine &machine, void *arg, std::string *str, INT32 newval)
|
||||
{
|
||||
((hlsl_options*)arg)->params_dirty = true;
|
||||
return slider_set(&(((hlsl_options*)arg)->scanline_height), 0.05f, "%2.2f", str, newval);
|
||||
return slider_set(&(((hlsl_options*)arg)->scanline_height), 0.01f, "%2.2f", str, newval);
|
||||
}
|
||||
|
||||
static INT32 slider_scanline_bright_scale(running_machine &machine, void *arg, std::string *str, INT32 newval)
|
||||
{
|
||||
((hlsl_options*)arg)->params_dirty = true;
|
||||
return slider_set(&(((hlsl_options*)arg)->scanline_bright_scale), 0.05f, "%2.2f", str, newval);
|
||||
return slider_set(&(((hlsl_options*)arg)->scanline_bright_scale), 0.01f, "%2.2f", str, newval);
|
||||
}
|
||||
|
||||
static INT32 slider_scanline_bright_offset(running_machine &machine, void *arg, std::string *str, INT32 newval)
|
||||
{
|
||||
((hlsl_options*)arg)->params_dirty = true;
|
||||
return slider_set(&(((hlsl_options*)arg)->scanline_bright_offset), 0.05f, "%2.2f", str, newval);
|
||||
return slider_set(&(((hlsl_options*)arg)->scanline_bright_offset), 0.01f, "%2.2f", str, newval);
|
||||
}
|
||||
|
||||
static INT32 slider_scanline_jitter(running_machine &machine, void *arg, std::string *str, INT32 newval)
|
||||
|
@ -2879,10 +2879,10 @@ shaders::slider_desc shaders::s_sliders[] =
|
|||
{ "Screen Reflection", 0, 0, 100, 1, 7, slider_reflection },
|
||||
{ "Image Vignetting", 0, 0, 100, 1, 7, slider_vignetting },
|
||||
{ "Scanline Darkness", 0, 0, 100, 1, 5, slider_scanline_alpha },
|
||||
{ "Scanline Screen Height", 1, 20, 80, 1, 5, slider_scanline_scale },
|
||||
{ "Scanline Indiv. Height", 1, 20, 80, 1, 5, slider_scanline_height },
|
||||
{ "Scanline Brightness", 0, 20, 40, 1, 5, slider_scanline_bright_scale },
|
||||
{ "Scanline Brightness Overdrive", 0, 0, 20, 1, 5, slider_scanline_bright_offset },
|
||||
{ "Scanline Screen Scale", 0, 100, 400, 5, 5, slider_scanline_scale },
|
||||
{ "Scanline Heigth", 0, 100, 400, 5, 5, slider_scanline_height },
|
||||
{ "Scanline Brightness", 0, 100, 200, 1, 5, slider_scanline_bright_scale },
|
||||
{ "Scanline Brightness Overdrive", 0, 0, 100, 1, 5, slider_scanline_bright_offset },
|
||||
{ "Scanline Jitter", 0, 0, 100, 1, 5, slider_scanline_jitter },
|
||||
{ "Hum Bar Darkness", 0, 0, 100, 1, 5, slider_hum_bar_alpha },
|
||||
{ "Defocus X", 0, 0, 100, 1, 7, slider_defocus_x },
|
||||
|
|
Loading…
Reference in a new issue