summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar Westley M. Martinez <anikom15@gmail.com>2016-12-30 15:40:30 -0800
committerGravatarGravatar Westley M. Martinez <anikom15@gmail.com>2016-12-30 15:40:30 -0800
commit7cda4860ec7ba81b6a05c486c6ef06385224c6b3 (patch) (github)
tree1a8e4012e8f561ae96f6a5ae3230ed3667093d98
parentb2682b7c55c5056042decfa44470fe4d51512fd0 (diff)
downloadmame-7cda4860ec7ba81b6a05c486c6ef06385224c6b3.tar.bz2
mame-7cda4860ec7ba81b6a05c486c6ef06385224c6b3.zip
Scale and phosphor persistence sliders.
hlsl/phosphor.fx: Scale parameter into tau or gamma. src/osd/modules/render/d3d/d3dhlsl.cpp: src/osd/modules/render/d3d/d3dhlsl.h: src/osd/windows/winmain.cpp: src/osd/windows/winmain.h: Combine tau and beta sliders into one slider labeled 'Time Constant'.
-rw-r--r--hlsl/phosphor.fx19
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.cpp26
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.h6
-rw-r--r--src/osd/windows/winmain.cpp5
-rw-r--r--src/osd/windows/winmain.h6
5 files changed, 26 insertions, 36 deletions
diff --git a/hlsl/phosphor.fx b/hlsl/phosphor.fx
index 447bf0242f9..59b2ce98935 100644
--- a/hlsl/phosphor.fx
+++ b/hlsl/phosphor.fx
@@ -99,9 +99,8 @@ uniform bool LCD = false;
uniform int Mode = 0;
uniform float DeltaTime = 0.0f;
uniform float LCDTau = 0.0f;
-uniform float3 Tau = { 0.0f, 0.0f, 0.0f };
+uniform float3 TimeConstant = { 0.0f, 0.0f, 0.0f };
uniform float3 Beta = { 0.0f, 0.0f, 0.0f };
-uniform float3 Gamma = { 0.0f, 0.0f, 0.0f };
float4 ps_main(PS_INPUT Input) : COLOR
{
@@ -122,17 +121,21 @@ float4 ps_main(PS_INPUT Input) : COLOR
b = 0;
}
else if (Mode == 1) {
- r *= Tau.r == 0 ? 0 : exp(-DeltaTime / Tau.r);
- g *= Tau.g == 0 ? 0 : exp(-DeltaTime / Tau.g);
- b *= Tau.b == 0 ? 0 : exp(-DeltaTime / Tau.b);
+ float3 tau = TimeConstant * 0.4342944819;
+
+ r *= tau.r == 0 ? 0 : exp(-DeltaTime / tau.r);
+ g *= tau.g == 0 ? 0 : exp(-DeltaTime / tau.g);
+ b *= tau.b == 0 ? 0 : exp(-DeltaTime / tau.b);
}
else {
+ float3 gamma = 1 / (TimeConstant * 0.04342944819);
+
if (r != 0.0f)
- r = pow(Gamma.r * DeltaTime + pow(1 / r, 1 / Beta.r), -Beta.r);
+ r = pow(gamma.r * DeltaTime + pow(1 / r, 1 / Beta.r), -Beta.r);
if (g != 0.0f)
- g = pow(Gamma.g * DeltaTime + pow(1 / g, 1 / Beta.g), -Beta.g);
+ g = pow(gamma.g * DeltaTime + pow(1 / g, 1 / Beta.g), -Beta.g);
if (b != 0.0f)
- b = pow(Gamma.b * DeltaTime + pow(1 / b, 1 / Beta.b), -Beta.b);
+ b = pow(gamma.b * DeltaTime + pow(1 / b, 1 / Beta.b), -Beta.b);
}
// Prevent burn-in
if (DeltaTime > 0.0f) {
diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp
index c07622127cf..1e0f42a7bd8 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.cpp
+++ b/src/osd/modules/render/d3d/d3dhlsl.cpp
@@ -520,12 +520,10 @@ bool shaders::init(d3d_base *d3dintf, running_machine *machine, renderer_d3d9 *r
get_vector(winoptions.screen_power(), 3, options->power, true);
get_vector(winoptions.screen_floor(), 3, options->floor, true);
options->phosphor_mode = winoptions.screen_phosphor_mode();
- get_vector(winoptions.screen_phosphor_tau(), 3,
- options->phosphor_tau, true);
+ get_vector(winoptions.screen_phosphor_time(), 3,
+ options->phosphor_time, true);
get_vector(winoptions.screen_phosphor_beta(), 3,
options->phosphor_beta, true);
- get_vector(winoptions.screen_phosphor_gamma(), 3,
- options->phosphor_gamma, true);
options->lcd_persistence = winoptions.screen_lcd_persistence();
options->saturation = winoptions.screen_saturation();
options->yiq_enable = winoptions.screen_yiq_enable();
@@ -795,9 +793,8 @@ int shaders::create_resources()
focus_effect->add_uniform("Defocus", uniform::UT_VEC2, uniform::CU_FOCUS_SIZE);
phosphor_effect->add_uniform("Mode", uniform::UT_INT, uniform::CU_PHOSPHOR_MODE);
- phosphor_effect->add_uniform("Tau", uniform::UT_VEC3, uniform::CU_PHOSPHOR_TAU);
+ phosphor_effect->add_uniform("TimeConstant", uniform::UT_VEC3, uniform::CU_PHOSPHOR_TIME);
phosphor_effect->add_uniform("Beta", uniform::UT_VEC3, uniform::CU_PHOSPHOR_BETA);
- phosphor_effect->add_uniform("Gamma", uniform::UT_VEC3, uniform::CU_PHOSPHOR_GAMMA);
phosphor_effect->add_uniform("LCDTau", uniform::UT_FLOAT, uniform::CU_LCD_PERSISTENCE);
post_effect->add_uniform("ShadowAlpha", uniform::UT_FLOAT, uniform::CU_POST_SHADOW_ALPHA);
@@ -1968,9 +1965,8 @@ enum slider_option
SLIDER_POWER,
SLIDER_FLOOR,
SLIDER_PHOSPHOR_MODE,
- SLIDER_PHOSPHOR_TAU,
+ SLIDER_PHOSPHOR_TIME,
SLIDER_PHOSPHOR_BETA,
- SLIDER_PHOSPHOR_GAMMA,
SLIDER_LCD_PERSISTENCE,
SLIDER_BLOOM_BLEND_MODE,
SLIDER_BLOOM_SCALE,
@@ -2051,9 +2047,8 @@ slider_desc shaders::s_sliders[] =
{ "Signal Exponent,", -800, 0, 800, 1, SLIDER_COLOR, SLIDER_SCREEN_TYPE_ANY, SLIDER_POWER, 0.01f, "%2.2f", {} },
{ "Signal Floor,", 0, 0, 100, 1, SLIDER_COLOR, SLIDER_SCREEN_TYPE_ANY, SLIDER_FLOOR, 0.01f, "%2.2f", {} },
{ "Phosphor Persistence Mode,", 0, 0, 2, 1, SLIDER_INT_ENUM, SLIDER_SCREEN_TYPE_RASTER_OR_VECTOR, SLIDER_PHOSPHOR_MODE, 0, "%s", { "Off", "Exponential", "Inverse Power" } },
- { "Phosphor Persistence tau,", 1, 26, 100, 1, SLIDER_COLOR, SLIDER_SCREEN_TYPE_RASTER_OR_VECTOR, SLIDER_PHOSPHOR_TAU, 0.001f, "%3.3f", {} },
- { "Phosphor Persistence beta,", 50, 70, 200, 1, SLIDER_COLOR, SLIDER_SCREEN_TYPE_RASTER_OR_VECTOR, SLIDER_PHOSPHOR_BETA, 0.01f, "%2.2f", {} },
- { "Phosphor Persistence gamma,", 1, 300, 1000, 1, SLIDER_COLOR, SLIDER_SCREEN_TYPE_RASTER_OR_VECTOR, SLIDER_PHOSPHOR_GAMMA, 1, "%.0f", {} },
+ { "Phosphor Persistence Time Constant,",1, 5000, 10000,10, SLIDER_COLOR, SLIDER_SCREEN_TYPE_RASTER_OR_VECTOR, SLIDER_PHOSPHOR_TIME, 0.0001f, "%4.4f", {} },
+ { "Phosphor Persistence beta,", 50, 100, 200, 1, SLIDER_COLOR, SLIDER_SCREEN_TYPE_RASTER_OR_VECTOR, SLIDER_PHOSPHOR_BETA, 0.01f, "%2.2f", {} },
{ "LCD Perisistence,", 0, 20, 100, 1, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_LCD, SLIDER_LCD_PERSISTENCE, 0.001f, "%3.3f", {} },
{ "Bloom Blend Mode", 0, 0, 1, 1, SLIDER_INT_ENUM, SLIDER_SCREEN_TYPE_ANY, SLIDER_BLOOM_BLEND_MODE, 0, "%s", { "Brighten", "Darken" } },
{ "Bloom Scale", 0, 0, 2000, 5, SLIDER_FLOAT, SLIDER_SCREEN_TYPE_ANY, SLIDER_BLOOM_SCALE, 0.001f, "%1.3f", {} },
@@ -2127,9 +2122,8 @@ void *shaders::get_slider_option(int id, int index)
case SLIDER_POWER: return &(options->power[index]);
case SLIDER_FLOOR: return &(options->floor[index]);
case SLIDER_PHOSPHOR_MODE: return &(options->phosphor_mode);
- case SLIDER_PHOSPHOR_TAU: return &(options->phosphor_tau[index]);
+ case SLIDER_PHOSPHOR_TIME: return &(options->phosphor_time[index]);
case SLIDER_PHOSPHOR_BETA: return &(options->phosphor_beta[index]);
- case SLIDER_PHOSPHOR_GAMMA: return &(options->phosphor_gamma[index]);
case SLIDER_LCD_PERSISTENCE: return &(options->lcd_persistence);
case SLIDER_BLOOM_BLEND_MODE: return &(options->bloom_blend_mode);
case SLIDER_BLOOM_SCALE: return &(options->bloom_scale);
@@ -2420,14 +2414,12 @@ void uniform::update()
case CU_PHOSPHOR_MODE:
m_shader->set_int("Mode", options->phosphor_mode);
break;
- case CU_PHOSPHOR_TAU:
- m_shader->set_vector("Tau", 3, options->phosphor_tau);
+ case CU_PHOSPHOR_TIME:
+ m_shader->set_vector("TimeConstant", 3, options->phosphor_time);
break;
case CU_PHOSPHOR_BETA:
m_shader->set_vector("Beta", 3, options->phosphor_beta);
break;
- case CU_PHOSPHOR_GAMMA:
- m_shader->set_vector("Gamma", 3, options->phosphor_gamma);
case CU_LCD_PERSISTENCE:
m_shader->set_float("LCDTau", options->lcd_persistence);
diff --git a/src/osd/modules/render/d3d/d3dhlsl.h b/src/osd/modules/render/d3d/d3dhlsl.h
index 3dda52de423..fd31e2fe679 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.h
+++ b/src/osd/modules/render/d3d/d3dhlsl.h
@@ -78,9 +78,8 @@ public:
CU_FOCUS_SIZE,
CU_PHOSPHOR_MODE,
- CU_PHOSPHOR_TAU,
+ CU_PHOSPHOR_TIME,
CU_PHOSPHOR_BETA,
- CU_PHOSPHOR_GAMMA,
CU_LCD_PERSISTENCE,
@@ -209,9 +208,8 @@ struct hlsl_options
float power[3];
float floor[3];
int phosphor_mode;
- float phosphor_tau[3];
+ float phosphor_time[3];
float phosphor_beta[3];
- float phosphor_gamma[3];
float lcd_persistence;
float saturation;
diff --git a/src/osd/windows/winmain.cpp b/src/osd/windows/winmain.cpp
index 06607e27f42..70a2a467ae6 100644
--- a/src/osd/windows/winmain.cpp
+++ b/src/osd/windows/winmain.cpp
@@ -216,9 +216,8 @@ const options_entry windows_options::s_option_entries[] =
{ WINOPTION_POWER";fs_power", "1.0,1.0,1.0", OPTION_STRING, "signal power value (exponential)" },
{ WINOPTION_FLOOR";fs_floor", "0.0,0.0,0.0", OPTION_STRING, "signal floor level" },
{ WINOPTION_PHOSPHOR_MODE";fs_phosphor_mode", "0", OPTION_STRING, "phosphorescence decay mode (0: off, 1: exponential, 2: inverse-power)" },
- { WINOPTION_PHOSPHOR_TAU";fs_phosphor_tau", "0.026,0.026,0.026", OPTION_STRING, "exponential time constant" },
- { WINOPTION_PHOSPHOR_BETA";fs_phosphor_beta", "0.7,0.7,0.7", OPTION_STRING, "inverse power order" },
- { WINOPTION_PHOSPHOR_GAMMA";fs_phosphor_gamma", "300,300,300", OPTION_STRING, "inverse power time constant" },
+ { WINOPTION_PHOSPHOR_TIME";fs_phosphor_time", "0.5,0.5,0.5", OPTION_STRING, "exponential time constant" },
+ { WINOPTION_PHOSPHOR_BETA";fs_phosphor_beta", "1.0,1.0,1.0", OPTION_STRING, "inverse power order" },
{ WINOPTION_LCD_PERSISTENCE";fs_lcd_persistence", "0.02", OPTION_STRING, "LCD pixel persistence time constant" },
/* NTSC simulation below this line */
{ nullptr, nullptr, OPTION_HEADER, "NTSC POST-PROCESSING OPTIONS" },
diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h
index a5fb11a8055..e613b32d26f 100644
--- a/src/osd/windows/winmain.h
+++ b/src/osd/windows/winmain.h
@@ -69,9 +69,8 @@
#define WINOPTION_POWER "power"
#define WINOPTION_FLOOR "floor"
#define WINOPTION_PHOSPHOR_MODE "phosphor_mode"
-#define WINOPTION_PHOSPHOR_TAU "phosphor_tau"
+#define WINOPTION_PHOSPHOR_TIME "phosphor_time"
#define WINOPTION_PHOSPHOR_BETA "phosphor_beta"
-#define WINOPTION_PHOSPHOR_GAMMA "phosphor_gamma"
#define WINOPTION_LCD_PERSISTENCE "lcd_persistence"
#define WINOPTION_SATURATION "saturation"
#define WINOPTION_YIQ_ENABLE "yiq_enable"
@@ -202,9 +201,8 @@ public:
const char *screen_power() const { return value(WINOPTION_POWER); }
const char *screen_floor() const { return value(WINOPTION_FLOOR); }
int screen_phosphor_mode() const { return int_value(WINOPTION_PHOSPHOR_MODE); }
- const char* screen_phosphor_tau() const { return value(WINOPTION_PHOSPHOR_TAU); }
+ const char* screen_phosphor_time() const { return value(WINOPTION_PHOSPHOR_TIME); }
const char* screen_phosphor_beta() const { return value(WINOPTION_PHOSPHOR_BETA); }
- const char* screen_phosphor_gamma() const { return value(WINOPTION_PHOSPHOR_GAMMA); }
float screen_lcd_persistence() const { return float_value(WINOPTION_LCD_PERSISTENCE); }
float screen_saturation() const { return float_value(WINOPTION_SATURATION); }