diff --git a/docs/hlsl.txt b/docs/hlsl.txt index a679748e233..cbc2ecd6871 100644 --- a/docs/hlsl.txt +++ b/docs/hlsl.txt @@ -2,8 +2,9 @@ HLSL-Related Enable Switches ---------------------------- Name Values Description -hlsl_enable 0/1 Enables HLSL post-processing in Direct3D 9 modes. -yiq_enable 0/1 Enables YIQ-colorspace post-processing. Causes a +hlsl_enable 0 or 1 Enables HLSL post-processing in Direct3D 9 modes. +hlsl_oversampling 0 or 1 Enables HLSL oversampling. +yiq_enable 0 or 1 Enables YIQ-colorspace post-processing. Causes a performance drop but gives a much more authentic NTSC TV appearance on TV-based systems when configured properly. diff --git a/hlsl/downsample.fx b/hlsl/downsample.fx index e89407208be..7b4d003dd7c 100644 --- a/hlsl/downsample.fx +++ b/hlsl/downsample.fx @@ -55,8 +55,6 @@ uniform float2 ScreenDims; uniform float2 TargetDims; uniform float2 QuadDims; -uniform int BloomLevel; - uniform bool VectorScreen; static const float2 Coord0Offset = float2(-0.5f, -0.5f); diff --git a/ini/gameboy.ini b/ini/gameboy.ini index 9c78116a680..d35ed5fe55d 100644 --- a/ini/gameboy.ini +++ b/ini/gameboy.ini @@ -2,7 +2,7 @@ # DIRECT3D POST-PROCESSING OPTIONS # shadow_mask_tile_mode 1 -shadow_mask_alpha 0.25 +shadow_mask_alpha 0.5 shadow_mask_texture monochrome-matrix.png shadow_mask_x_count 2 shadow_mask_y_count 2 @@ -16,20 +16,20 @@ smooth_border 0.0 reflection 0.0 vignetting 0.0 scanline_alpha 0.0 -defocus 0.0,0.0 +defocus 0.5,0.5 converge_x 0.0,0.0,0.0 converge_y 0.0,0.0,0.0 radial_converge_x 0.0,0.0,0.0 radial_converge_y 0.0,0.0,0.0 red_ratio 1.0,0.0,0.0 -grn_ratio 0.0,1.0,0.0 -blu_ratio 0.0,0.0,1.0 -saturation 1.0 -offset 0.0,0.0,0.0 -scale 1.0,1.0,1.0 -power 1.0,1.0,1.0 +grn_ratio 0.1,1.0,0.0 +blu_ratio 0.0,0.05,1.0 +saturation 2.0 +offset 0.0,0.10,0.05 +scale 0.9,0.8,1.0 +power 1.4,1.2,1.8 floor 0.0,0.0,0.0 -phosphor_life 0.5,0.5,0.5 +phosphor_life 0.65,0.65,0.65 # # NTSC POST-PROCESSING OPTIONS @@ -40,7 +40,7 @@ yiq_enable 0 # BLOOM POST-PROCESSING OPTIONS # bloom_blend_mode 1 -bloom_scale 1.0 +bloom_scale 0.5 bloom_overdrive 0.0,0.0,0.0 bloom_lvl0_weight 1.0 bloom_lvl1_weight 0.64 diff --git a/ini/vector.ini b/ini/vector.ini index 487e5a3d9a3..8e7a98b64a9 100644 --- a/ini/vector.ini +++ b/ini/vector.ini @@ -2,7 +2,7 @@ # CORE VECTOR OPTIONS # antialias 1 -beam_width_min 0.50 +beam_width_min 0.75 beam_width_max 4.00 beam_intensity_weight 0.75 flicker 0.15 @@ -10,6 +10,7 @@ flicker 0.15 # # DIRECT3D POST-PROCESSING OPTIONS # +hlsl_oversampling 0 shadow_mask_tile_mode 0 shadow_mask_alpha 0.5 shadow_mask_texture shadow-mask.png @@ -30,7 +31,7 @@ converge_x 0.0,0.0,0.0 converge_y 0.0,0.0,0.0 radial_converge_x 0.0,0.0,0.0 radial_converge_y 0.0,0.0,0.0 -red_ratio 1.0,0.0,0.1 +red_ratio 1.0,0.0,0.0 grn_ratio 0.0,1.0,0.0 blu_ratio 0.0,0.0,1.0 saturation 1.0 @@ -56,7 +57,7 @@ vector_length_ratio 500.0 # bloom_blend_mode 0 bloom_scale 1.50 -bloom_overdrive 1.50,1.50,1.50 +bloom_overdrive 1.00,1.00,1.00 bloom_lvl0_weight 1.00 bloom_lvl1_weight 0.64 bloom_lvl2_weight 0.32 diff --git a/src/emu/video/vector.cpp b/src/emu/video/vector.cpp index 36c303eda42..e6db787d12c 100644 --- a/src/emu/video/vector.cpp +++ b/src/emu/video/vector.cpp @@ -332,32 +332,45 @@ UINT32 vector_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, } else { - float beam_intensity_width = m_beam_width_min; - float intensity = (float)curpoint->intensity / 255.0f; + float intensity_weight = normalized_sigmoid(intensity, m_beam_intensity_weight); - // 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; - } + // check for static intensity + float beam_width = m_min_intensity == m_max_intensity + ? m_beam_width_min + : m_beam_width_min + intensity_weight * (m_beam_width_max - m_beam_width_min); - float beam_width = beam_intensity_width * (1.0f / (float)VECTOR_WIDTH_DENOM); + // normalize width + beam_width *= 1.0f / (float)VECTOR_WIDTH_DENOM; coords.x0 = ((float)lastx - xoffs) * xscale; coords.y0 = ((float)lasty - yoffs) * yscale; coords.x1 = ((float)curpoint->x - xoffs) * xscale; coords.y1 = ((float)curpoint->y - yoffs) * yscale; - // extend zero-length vector line (vector point) by quarter beam_width on both sides - if (fabs(coords.x0 - coords.x1) < FLT_EPSILON && - fabs(coords.y0 - coords.y1) < FLT_EPSILON) + float xdistance = coords.x0 - coords.x1; + float ydistance = coords.y0 - coords.y1; + + // extend zero-length vector line (vector point) by 3/8 beam_width on both sides + if (fabs(xdistance) < FLT_EPSILON && + fabs(ydistance) < FLT_EPSILON) { - coords.x0 += xratio * beam_width * 0.25f; - coords.y0 += yratio * beam_width * 0.25f; - coords.x1 -= xratio * beam_width * 0.25f; - coords.y1 -= yratio * beam_width * 0.25f; + coords.x0 += xratio * beam_width * 0.375f; + coords.y0 += yratio * beam_width * 0.375f; + coords.x1 -= xratio * beam_width * 0.375f; + coords.y1 -= yratio * beam_width * 0.375f; + } + // extend vector line by 3/8 beam_width on both sides + else + { + float length = sqrt(xdistance * xdistance + ydistance * ydistance); + float xdirection = xdistance / length; + float ydirection = ydistance / length; + + coords.x0 += xratio * beam_width * 0.375f * (xdirection / xratio); + coords.y0 += yratio * beam_width * 0.375f * (ydirection / yratio); + coords.x1 -= xratio * beam_width * 0.375f * (xdirection / xratio); + coords.y1 -= yratio * beam_width * 0.375f * (ydirection / yratio); } if (curpoint->intensity != 0 && !render_clip_line(&coords, &clip)) diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp index 62800ecf9c6..9d22e045b91 100644 --- a/src/osd/modules/render/d3d/d3dhlsl.cpp +++ b/src/osd/modules/render/d3d/d3dhlsl.cpp @@ -69,6 +69,7 @@ shaders::shaders() : { master_enable = false; vector_enable = true; + oversampling_enable = false; shadow_texture = nullptr; options = nullptr; paused = true; @@ -664,6 +665,7 @@ void shaders::init(d3d_base *d3dintf, running_machine *machine, renderer_d3d9 *r windows_options &winoptions = downcast(machine->options()); master_enable = winoptions.d3d_hlsl_enable(); + oversampling_enable = winoptions.d3d_hlsl_oversampling(); snap_width = winoptions.d3d_snap_width(); snap_height = winoptions.d3d_snap_height(); @@ -945,7 +947,6 @@ int shaders::create_resources(bool reset) for (int i = 0; i < 13; i++) { effects[i]->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS); - effects[i]->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT); effects[i]->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS); effects[i]->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); effects[i]->add_uniform("QuadDims", uniform::UT_VEC2, uniform::CU_QUAD_DIMS); @@ -1438,7 +1439,6 @@ int shaders::downsample_pass(d3d_render_target *rt, int source_index, poly_info for (int bloom_index = 0; bloom_index < rt->bloom_count; bloom_index++) { curr_effect->set_vector("TargetDims", 2, rt->bloom_dims[bloom_index]); - curr_effect->set_int("BloomLevel", bloom_index + 1); curr_effect->set_texture("DiffuseTexture", bloom_index == 0 ? rt->source_texture[next_index] @@ -1824,6 +1824,9 @@ d3d_render_target* shaders::get_texture_target(render_primitive *prim, texture_i ? static_cast(prim->get_quad_width() + 0.5f) : static_cast(prim->get_quad_height() + 0.5f); + target_width *= oversampling_enable ? 2 : 1; + target_height *= oversampling_enable ? 2 : 1; + // find render target and check if the size of the target quad has changed d3d_render_target *target = find_render_target(texture); if (target != nullptr && target->target_width == target_width && target->target_height == target_height) @@ -1846,6 +1849,9 @@ d3d_render_target* shaders::get_vector_target(render_primitive *prim) int target_width = static_cast(prim->get_quad_width() + 0.5f); int target_height = static_cast(prim->get_quad_height() + 0.5f); + target_width *= oversampling_enable ? 2 : 1; + target_height *= oversampling_enable ? 2 : 1; + // find render target and check of the size of the target quad has changed d3d_render_target *target = find_render_target(d3d->get_width(), d3d->get_height(), 0, 0); if (target != nullptr && target->target_width == target_width && target->target_height == target_height) @@ -1863,7 +1869,10 @@ void shaders::create_vector_target(render_primitive *prim) int target_width = static_cast(prim->get_quad_width() + 0.5f); int target_height = static_cast(prim->get_quad_height() + 0.5f); - osd_printf_verbose("create_vector_target() - %f, %f; %d, %d\n", prim->get_quad_width(), prim->get_quad_height(), (int)(prim->get_quad_width() + 0.5f), (int)(prim->get_quad_height() + 0.5f)); + target_width *= oversampling_enable ? 2 : 1; + target_height *= oversampling_enable ? 2 : 1; + + osd_printf_verbose("create_vector_target() - %d, %d\n", target_width, target_height); if (!add_render_target(d3d, nullptr, d3d->get_width(), d3d->get_height(), target_width, target_height)) { vector_enable = false; @@ -1970,7 +1979,10 @@ bool shaders::register_texture(render_primitive *prim, texture_info *texture) ? static_cast(prim->get_quad_width() + 0.5f) : static_cast(prim->get_quad_height() + 0.5f); - osd_printf_verbose("register_texture() - %f, %f; %d, %d\n", prim->get_quad_width(), prim->get_quad_height(), (int)(prim->get_quad_width() + 0.5f), (int)(prim->get_quad_height() + 0.5f)); + target_width *= oversampling_enable ? 2 : 1; + target_height *= oversampling_enable ? 2 : 1; + + osd_printf_verbose("register_texture() - %d, %d\n", target_width, target_height); if (!add_render_target(d3d, texture, texture->get_width(), texture->get_height(), target_width, target_height)) { return false; @@ -2605,35 +2617,16 @@ void uniform::update() } case CU_SOURCE_DIMS: { - if (shadersys->curr_texture != nullptr) + if (shadersys->curr_texture) { vec2f sourcedims = shadersys->curr_texture->get_rawdims(); m_shader->set_vector("SourceDims", 2, &sourcedims.c.x); } - else - { - vec2f sourcedims = d3d->get_dims(); - m_shader->set_vector("SourceDims", 2, &sourcedims.c.x); - } - break; - } - case CU_SOURCE_RECT: - { - if (shadersys->curr_texture != nullptr) - { - vec2f delta = shadersys->curr_texture->get_uvstop() - shadersys->curr_texture->get_uvstart(); - m_shader->set_vector("SourceRect", 2, &delta.c.x); - } - else - { - float delta[2] = { 1.0f, 1.0f }; - m_shader->set_vector("SourceRect", 2, delta); - } break; } case CU_TARGET_DIMS: { - if (shadersys->curr_render_target != nullptr) + if (shadersys->curr_render_target) { float targetdims[2] = { static_cast(shadersys->curr_render_target->target_width), @@ -2644,7 +2637,7 @@ void uniform::update() } case CU_QUAD_DIMS: { - if (shadersys->curr_poly != nullptr) + if (shadersys->curr_poly) { float quaddims[2] = { // round diff --git a/src/osd/modules/render/d3d/d3dhlsl.h b/src/osd/modules/render/d3d/d3dhlsl.h index 24e03822e80..a4c9f13b9ed 100644 --- a/src/osd/modules/render/d3d/d3dhlsl.h +++ b/src/osd/modules/render/d3d/d3dhlsl.h @@ -45,7 +45,6 @@ public: { CU_SCREEN_DIMS = 0, CU_SOURCE_DIMS, - CU_SOURCE_RECT, CU_TARGET_DIMS, CU_QUAD_DIMS, @@ -384,6 +383,7 @@ private: bool master_enable; // overall enable flag bool vector_enable; // vector post-processing enable flag + bool oversampling_enable; // oversampling enable flag bool paused; // whether or not rendering is currently paused int num_screens; // number of emulated physical screens int curr_screen; // current screen for render target operations diff --git a/src/osd/windows/winmain.cpp b/src/osd/windows/winmain.cpp index 96032fef65b..0efb762a079 100644 --- a/src/osd/windows/winmain.cpp +++ b/src/osd/windows/winmain.cpp @@ -277,8 +277,9 @@ const options_entry windows_options::s_option_entries[] = // post-processing options { nullptr, nullptr, OPTION_HEADER, "DIRECT3D POST-PROCESSING OPTIONS" }, - { WINOPTION_HLSL_ENABLE";hlsl", "0", OPTION_BOOLEAN, "enables HLSL post-processing (PS3.0 required)" }, { WINOPTION_HLSLPATH, "hlsl", OPTION_STRING, "path to hlsl files" }, + { WINOPTION_HLSL_ENABLE";hlsl", "0", OPTION_BOOLEAN, "enables HLSL post-processing (PS3.0 required)" }, + { WINOPTION_HLSL_OVERSAMPLING, "0", OPTION_BOOLEAN, "enables HLSL oversampling" }, { WINOPTION_HLSL_WRITE, nullptr, OPTION_STRING, "enables HLSL AVI writing (huge disk bandwidth suggested)" }, { WINOPTION_HLSL_SNAP_WIDTH, "2048", OPTION_STRING, "HLSL upscaled-snapshot width" }, { WINOPTION_HLSL_SNAP_HEIGHT, "1536", OPTION_STRING, "HLSL upscaled-snapshot height" }, diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index 786954d4119..dd348ee4491 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -26,8 +26,9 @@ #define WINOPTION_MENU "menu" // core post-processing options -#define WINOPTION_HLSL_ENABLE "hlsl_enable" #define WINOPTION_HLSLPATH "hlslpath" +#define WINOPTION_HLSL_ENABLE "hlsl_enable" +#define WINOPTION_HLSL_OVERSAMPLING "hlsl_oversampling" #define WINOPTION_HLSL_WRITE "hlsl_write" #define WINOPTION_HLSL_SNAP_WIDTH "hlsl_snap_width" #define WINOPTION_HLSL_SNAP_HEIGHT "hlsl_snap_height" @@ -128,6 +129,7 @@ public: // core post-processing options const char *screen_post_fx_dir() const { return value(WINOPTION_HLSLPATH); } bool d3d_hlsl_enable() const { return bool_value(WINOPTION_HLSL_ENABLE); } + bool d3d_hlsl_oversampling() const { return bool_value(WINOPTION_HLSL_OVERSAMPLING); } const char *d3d_hlsl_write() const { return value(WINOPTION_HLSL_WRITE); } int d3d_snap_width() const { return int_value(WINOPTION_HLSL_SNAP_WIDTH); } int d3d_snap_height() const { return int_value(WINOPTION_HLSL_SNAP_HEIGHT); }