Fixed dynamic beam width for invariabel vector intensity

- the vector renderer now tries to detect a invariabel vector intensity
and disables the calculation of a dynamic beam width
This commit is contained in:
ImJezze 2015-11-18 13:37:53 +01:00
parent 8d3ef79c0f
commit 05f83580c0
5 changed files with 31 additions and 30 deletions

View File

@ -925,8 +925,7 @@ render_target::render_target(render_manager &manager, const char *layoutfile, UI
m_base_orientation(ROT0),
m_maxtexwidth(65536),
m_maxtexheight(65536),
m_scale_primitives(true),
m_offset_primitives(true)
m_transform_primitives(true)
{
// determine the base layer configuration based on options
m_base_layerconfig.set_backdrops_enabled(manager.machine().options().use_backdrops());
@ -1661,13 +1660,10 @@ void render_target::add_container_primitives(render_primitive_list &list, const
float yoffs = (container_xform.orientation & ORIENTATION_SWAP_XY) ? container.xoffset() : container.yoffset();
if (container_xform.orientation & ORIENTATION_FLIP_X) xoffs = -xoffs;
if (container_xform.orientation & ORIENTATION_FLIP_Y) yoffs = -yoffs;
if (!m_scale_primitives)
if (!m_transform_primitives)
{
xscale = 1.0f;
yscale = 1.0f;
}
if (!m_offset_primitives)
{
xoffs = 0.0f;
yoffs = 0.0f;
}

View File

@ -898,8 +898,7 @@ public:
void set_orientation(int orientation) { m_orientation = orientation; }
void set_view(int viewindex);
void set_max_texture_size(int maxwidth, int maxheight);
void set_scale_primitives(bool enable) { m_scale_primitives = enable; }
void set_offset_primitives(bool enable) { m_offset_primitives = enable; }
void set_transform_primitives(bool transform_primitives) { m_transform_primitives = transform_primitives; }
// layer config getters
bool backdrops_enabled() const { return m_layerconfig.backdrops_enabled(); }
@ -998,8 +997,8 @@ private:
simple_list<render_container> m_debug_containers; // list of debug containers
INT32 m_clear_extent_count; // number of clear extents
INT32 m_clear_extents[MAX_CLEAR_EXTENTS]; // array of clear extents
bool m_scale_primitives; // determines if the primitive shall be scaled/offset by screen settings,
bool m_offset_primitives; // otherwise the respective render API will handle it (default is true)
bool m_transform_primitives; // determines if the primitives shall be scaled/offset by screen settings,
// otherwise the respective render API will handle it (default is true)
static render_screen_list s_empty_screen_list;
};

View File

@ -131,14 +131,18 @@ const device_type VECTOR = &device_creator<vector_device>;
vector_device::vector_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_video_interface(mconfig, *this),
m_vector_list(NULL)
m_vector_list(NULL),
m_min_intensity(255),
m_max_intensity(0)
{
}
vector_device::vector_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, VECTOR, "VECTOR", tag, owner, clock, "vector_device", __FILE__),
device_video_interface(mconfig, *this),
m_vector_list(NULL)
device_video_interface(mconfig, *this),
m_vector_list(NULL),
m_min_intensity(255),
m_max_intensity(0)
{
}
@ -221,24 +225,18 @@ void vector_device::add_point(int x, int y, rgb_t color, int intensity)
{
point *newpoint;
if (intensity > 255)
{
intensity = 255;
}
intensity = MAX(0, MIN(255, intensity));
m_min_intensity = intensity > 0 ? MIN(m_min_intensity, intensity) : m_min_intensity;
m_max_intensity = intensity > 0 ? MAX(m_max_intensity, intensity) : m_max_intensity;
if (m_flicker && (intensity > 0))
{
float random = (float)(machine().rand() & 255) / 255.0f; // random value between 0.0 and 1.0
intensity -= (int)(intensity * random * m_flicker);
if (intensity < 0)
{
intensity = 0;
}
if (intensity > 255)
{
intensity = 255;
}
intensity = MAX(0, MIN(255, intensity));
}
newpoint = &m_vector_list[m_vector_index];
@ -334,10 +332,17 @@ UINT32 vector_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap,
}
else
{
float intensity = (float)curpoint->intensity / 255.0f;
float intensity_weight = normalized_sigmoid(intensity, m_beam_intensity_weight);
float beam_intensity_width = m_beam_width_min;
float intensity = (float)curpoint->intensity / 255.0f;
// check for dynamic intensity
if (m_min_intensity != m_max_intensity)
{
float intensity_weight = normalized_sigmoid(intensity, m_beam_intensity_weight);
beam_intensity_width = (m_beam_width_max - m_beam_width_min) * intensity_weight + m_beam_width_min;
}
float beam_intensity_width = (m_beam_width_max - m_beam_width_min) * intensity_weight + m_beam_width_min;
float beam_width = beam_intensity_width * (1.0f / (float)VECTOR_WIDTH_DENOM);
coords.x0 = ((float)lastx - xoffs) * xscale;

View File

@ -67,6 +67,8 @@ private:
static float m_beam_intensity_weight;
point *m_vector_list;
static int m_vector_index;
int m_min_intensity;
int m_max_intensity;
float normalized_sigmoid(float n, float k);
};

View File

@ -247,8 +247,7 @@ render_primitive_list *d3d::renderer::get_primitives()
}
if (m_shaders != NULL)
{
window().target()->set_scale_primitives(!m_shaders->enabled());
window().target()->set_offset_primitives(!m_shaders->enabled());
window().target()->set_transform_primitives(!m_shaders->enabled());
}
return &window().target()->get_primitives();
}