mirror of
https://github.com/libretro/mame.git
synced 2024-11-24 01:49:53 +00:00
fix vector bloom, nw
This commit is contained in:
parent
1d3030a04e
commit
675796fe23
@ -189,16 +189,16 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
float2 inversePixel = 1.0f / TargetSize;
|
||||
float2 TexCoord = Input.Position.xy * inversePixel + float2(0.5f, 0.5f) * inversePixel;
|
||||
Output.TexCoord01.xy = TexCoord;
|
||||
Output.TexCoord01.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.5f;
|
||||
Output.TexCoord23.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.25f;
|
||||
Output.TexCoord23.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.125f;
|
||||
Output.TexCoord45.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.0625f;
|
||||
Output.TexCoord45.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.03125f;
|
||||
Output.TexCoord67.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.015625f;
|
||||
Output.TexCoord67.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.0078125f;
|
||||
Output.TexCoord89.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.00390625f;
|
||||
Output.TexCoord89.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.001953125f;
|
||||
Output.TexCoordA = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 0.0009765625f;
|
||||
Output.TexCoord01.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.5f;
|
||||
Output.TexCoord23.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.25f;
|
||||
Output.TexCoord23.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.125f;
|
||||
Output.TexCoord45.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.0625f;
|
||||
Output.TexCoord45.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.03125f;
|
||||
Output.TexCoord67.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.015625f;
|
||||
Output.TexCoord67.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.0078125f;
|
||||
Output.TexCoord89.xy = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.00390625f;
|
||||
Output.TexCoord89.zw = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.001953125f;
|
||||
Output.TexCoordA = ((TexCoord - 0.5f) * 1.00f + 0.5f) * 1.0f;//0.0009765625f;
|
||||
|
||||
return Output;
|
||||
}
|
||||
@ -225,17 +225,17 @@ float4 ps_main(PS_INPUT Input) : COLOR
|
||||
float3 texel9 = tex2D(DiffuseSampler9, Input.TexCoord89.zw).rgb;
|
||||
float3 texelA = tex2D(DiffuseSamplerA, Input.TexCoordA).rgb;
|
||||
|
||||
texel0 = texel0 * Level0123Weight.x; // 1.0f;
|
||||
texel1 = texel1 * Level0123Weight.y; // 0.21f;
|
||||
texel2 = texel2 * Level0123Weight.z; // 0.19f;
|
||||
texel3 = texel3 * Level0123Weight.w; // 0.17f;
|
||||
texel4 = texel4 * Level4567Weight.x; // 0.15f;
|
||||
texel5 = texel5 * Level4567Weight.y; // 0.14f;
|
||||
texel6 = texel6 * Level4567Weight.z; // 0.13f;
|
||||
texel7 = texel7 * Level4567Weight.w; // 0.12f;
|
||||
texel8 = texel8 * Level89AWeight.x; // 0.11f;
|
||||
texel9 = texel9 * Level89AWeight.y; // 0.10f;
|
||||
texelA = texelA * Level89AWeight.z; // 0.09f;
|
||||
texel0 = texel0 * Level0123Weight.x;
|
||||
texel1 = texel1 * Level0123Weight.y;
|
||||
texel2 = texel2 * Level0123Weight.z;
|
||||
texel3 = texel3 * Level0123Weight.w;
|
||||
texel4 = texel4 * Level4567Weight.x;
|
||||
texel5 = texel5 * Level4567Weight.y;
|
||||
texel6 = texel6 * Level4567Weight.z;
|
||||
texel7 = texel7 * Level4567Weight.w;
|
||||
texel8 = texel8 * Level89AWeight.x;
|
||||
texel9 = texel9 * Level89AWeight.y;
|
||||
texelA = texelA * Level89AWeight.z;
|
||||
|
||||
float4 sum = float4(texel0 + texel1 + texel2 + texel3 + texel4 +
|
||||
texel5 + texel6 + texel7 + texel8 + texel9 + texelA, 1.0f);
|
||||
|
@ -25,9 +25,6 @@ struct VS_OUTPUT
|
||||
float4 Color : COLOR0;
|
||||
float4 TexCoord01 : TEXCOORD0;
|
||||
float4 TexCoord23 : TEXCOORD1;
|
||||
float4 TexCoord45 : TEXCOORD2;
|
||||
float4 TexCoord67 : TEXCOORD3;
|
||||
float4 TexCoord89 : TEXCOORD4;
|
||||
};
|
||||
|
||||
struct VS_INPUT
|
||||
@ -42,9 +39,6 @@ struct PS_INPUT
|
||||
float4 Color : COLOR0;
|
||||
float4 TexCoord01 : TEXCOORD0;
|
||||
float4 TexCoord23 : TEXCOORD1;
|
||||
float4 TexCoord45 : TEXCOORD2;
|
||||
float4 TexCoord67 : TEXCOORD3;
|
||||
float4 TexCoord89 : TEXCOORD4;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -53,6 +47,7 @@ struct PS_INPUT
|
||||
|
||||
uniform float2 TargetSize;
|
||||
uniform float2 SourceSize;
|
||||
uniform float BloomRescale;
|
||||
|
||||
VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
{
|
||||
@ -64,17 +59,11 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
||||
Output.Position.xy -= 0.5f;
|
||||
Output.Position.xy *= 2.0f;
|
||||
Output.Color = Input.Color;
|
||||
float2 inversePixel = 1.0f / TargetSize;
|
||||
Output.TexCoord01.xy = Input.Position.xy * inversePixel + float2(0.00f + 0.5f, 0.00f + 0.5f) * inversePixel;
|
||||
Output.TexCoord01.zw = Input.Position.xy * inversePixel + float2(0.50f + 0.5f, 0.00f + 0.5f) * inversePixel;
|
||||
Output.TexCoord23.xy = Input.Position.xy * inversePixel + float2(0.25f + 0.5f, 0.25f + 0.5f) * inversePixel;
|
||||
Output.TexCoord23.zw = Input.Position.xy * inversePixel + float2(0.50f + 0.5f, 0.25f + 0.5f) * inversePixel;
|
||||
Output.TexCoord45.xy = Input.Position.xy * inversePixel + float2(0.75f + 0.5f, 0.25f + 0.5f) * inversePixel;
|
||||
Output.TexCoord45.zw = Input.Position.xy * inversePixel + float2(0.00f + 0.5f, 0.50f + 0.5f) * inversePixel;
|
||||
Output.TexCoord67.xy = Input.Position.xy * inversePixel + float2(0.50f + 0.5f, 0.50f + 0.5f) * inversePixel;
|
||||
Output.TexCoord67.zw = Input.Position.xy * inversePixel + float2(0.00f + 0.5f, 0.75f + 0.5f) * inversePixel;
|
||||
Output.TexCoord89.xy = Input.Position.xy * inversePixel + float2(0.25f + 0.5f, 0.75f + 0.5f) * inversePixel;
|
||||
Output.TexCoord89.zw = Input.Position.xy * inversePixel + float2(0.75f + 0.5f, 0.75f + 0.5f) * inversePixel;
|
||||
float2 inversePixel = 1.0f / SourceSize;
|
||||
Output.TexCoord01.xy = Input.Position.xy * inversePixel + float2(0.5f, 0.5f) * inversePixel;
|
||||
Output.TexCoord01.zw = Input.Position.xy * inversePixel + float2(1.5f, 0.5f) * inversePixel;
|
||||
Output.TexCoord23.xy = Input.Position.xy * inversePixel + float2(0.5f, 1.5f) * inversePixel;
|
||||
Output.TexCoord23.zw = Input.Position.xy * inversePixel + float2(1.5f, 1.5f) * inversePixel;
|
||||
|
||||
return Output;
|
||||
}
|
||||
@ -89,13 +78,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
|
||||
float4 texel1 = tex2D(DiffuseSampler, Input.TexCoord01.zw);
|
||||
float4 texel2 = tex2D(DiffuseSampler, Input.TexCoord23.xy);
|
||||
float4 texel3 = tex2D(DiffuseSampler, Input.TexCoord23.zw);
|
||||
float4 texel4 = tex2D(DiffuseSampler, Input.TexCoord45.xy);
|
||||
float4 texel5 = tex2D(DiffuseSampler, Input.TexCoord45.zw);
|
||||
float4 texel6 = tex2D(DiffuseSampler, Input.TexCoord67.xy);
|
||||
float4 texel7 = tex2D(DiffuseSampler, Input.TexCoord67.zw);
|
||||
float4 texel8 = tex2D(DiffuseSampler, Input.TexCoord89.xy);
|
||||
float4 texel9 = tex2D(DiffuseSampler, Input.TexCoord89.zw);
|
||||
float4 outTexel = (texel0 + texel1 + texel2 + texel3 + texel4 + texel5 + texel6 + texel7 + texel8 + texel9) * 0.1f;
|
||||
float4 outTexel = (texel0 + texel1 + texel2 + texel3) * BloomRescale;
|
||||
return float4(outTexel.rgb, 1.0f);
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
|
||||
float lengthModulate = clamp(1.0f - LengthParams.x / LengthParams.z, 0.0f, 1.0f);
|
||||
lengthModulate = lerp(1.0f, timeModulate * lengthModulate, LengthParams.y) * 2.0;
|
||||
|
||||
float4 outColor = Input.Color * float4(lengthModulate, lengthModulate, lengthModulate, 1.0f) * 2.5;
|
||||
float4 outColor = Input.Color * float4(lengthModulate, lengthModulate, lengthModulate, 1.0f) * 8.0;
|
||||
return outColor;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ class texture_manager
|
||||
public:
|
||||
texture_manager() { }
|
||||
texture_manager(renderer *d3d);
|
||||
~texture_manager() { }
|
||||
~texture_manager();
|
||||
|
||||
void update_textures();
|
||||
|
||||
|
@ -224,6 +224,21 @@ shaders::shaders()
|
||||
shaders::~shaders()
|
||||
{
|
||||
global_free(options);
|
||||
cache_target *currcache = cachehead;
|
||||
while(cachehead != NULL)
|
||||
{
|
||||
cachehead = currcache->next;
|
||||
global_free(currcache);
|
||||
currcache = cachehead;
|
||||
}
|
||||
|
||||
render_target *currtarget = targethead;
|
||||
while(targethead != NULL)
|
||||
{
|
||||
targethead = currtarget->next;
|
||||
global_free(currtarget);
|
||||
currtarget = targethead;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -983,6 +998,8 @@ void shaders::init(base *d3dintf, win_window_info *window)
|
||||
options->vector_time_period = winoptions.screen_vector_time_period();
|
||||
options->vector_length_scale = winoptions.screen_vector_length_scale();
|
||||
options->vector_length_ratio = winoptions.screen_vector_length_ratio();
|
||||
options->vector_bloom_scale = winoptions.screen_vector_bloom_scale();
|
||||
options->raster_bloom_scale = winoptions.screen_raster_bloom_scale();
|
||||
options->bloom_level0_weight = winoptions.screen_bloom_lvl0_weight();
|
||||
options->bloom_level1_weight = winoptions.screen_bloom_lvl1_weight();
|
||||
options->bloom_level2_weight = winoptions.screen_bloom_lvl2_weight();
|
||||
@ -2058,6 +2075,7 @@ void shaders::render_quad(poly_info *poly, int vertnum)
|
||||
curr_effect = downsample_effect;
|
||||
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->render_texture[2]);
|
||||
(*d3dintf->effect.set_float)(curr_effect, "BloomRescale", options->raster_bloom_scale);
|
||||
|
||||
int bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height();
|
||||
int bloom_index = 0;
|
||||
@ -2222,6 +2240,7 @@ void shaders::render_quad(poly_info *poly, int vertnum)
|
||||
curr_effect = downsample_effect;
|
||||
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "Diffuse", rt->render_texture[0]);
|
||||
(*d3dintf->effect.set_float)(curr_effect, "BloomRescale", options->vector_bloom_scale);
|
||||
|
||||
int bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height();
|
||||
int bloom_index = 0;
|
||||
@ -2264,6 +2283,15 @@ void shaders::render_quad(poly_info *poly, int vertnum)
|
||||
|
||||
float target_size[2] = { d3d->get_width(), d3d->get_height() };
|
||||
(*d3dintf->effect.set_vector)(curr_effect, "TargetSize", 2, target_size);
|
||||
float weight0123[4] = { options->bloom_level0_weight, options->bloom_level1_weight,
|
||||
options->bloom_level2_weight, options->bloom_level3_weight };
|
||||
float weight4567[4] = { options->bloom_level4_weight, options->bloom_level5_weight,
|
||||
options->bloom_level6_weight, options->bloom_level7_weight };
|
||||
float weight89A[3] = { options->bloom_level8_weight, options->bloom_level9_weight,
|
||||
options->bloom_level10_weight };
|
||||
(*d3dintf->effect.set_vector)(curr_effect, "Level0123Weight", 4, weight0123);
|
||||
(*d3dintf->effect.set_vector)(curr_effect, "Level4567Weight", 4, weight4567);
|
||||
(*d3dintf->effect.set_vector)(curr_effect, "Level89AWeight", 3, weight89A);
|
||||
|
||||
(*d3dintf->effect.set_texture)(curr_effect, "DiffuseA", rt->render_texture[0]);
|
||||
(*d3dintf->effect.set_float)(curr_effect, "DiffuseScaleA", 1.0f);
|
||||
|
@ -117,6 +117,8 @@ struct hlsl_options
|
||||
float vector_length_ratio;
|
||||
|
||||
// Bloom
|
||||
float vector_bloom_scale;
|
||||
float raster_bloom_scale;
|
||||
float bloom_level0_weight;
|
||||
float bloom_level1_weight;
|
||||
float bloom_level2_weight;
|
||||
|
@ -533,6 +533,10 @@ texture_manager::texture_manager(renderer *d3d)
|
||||
mame_printf_verbose("Direct3D: Max texture size = %dx%d\n", (int)m_texture_max_width, (int)m_texture_max_height);
|
||||
}
|
||||
|
||||
texture_manager::~texture_manager()
|
||||
{
|
||||
}
|
||||
|
||||
void texture_manager::create_resources()
|
||||
{
|
||||
// experimental: load a PNG to use for vector rendering; it is treated
|
||||
@ -997,6 +1001,7 @@ try_again:
|
||||
video_config.waitvsync || video_config.syncrefresh) ?
|
||||
D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
|
||||
printf("m_device is %08x%08x\n", (UINT32)((UINT64)m_device >> 32), (UINT32)((UINT64)m_device & 0x00000000ffffffff));
|
||||
// create the D3D device
|
||||
result = (*d3dintf->d3d.create_device)(d3dintf, m_adapter, D3DDEVTYPE_HAL, win_window_list->hwnd,
|
||||
D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE, &m_presentation, &m_device);
|
||||
|
@ -398,6 +398,8 @@ const options_entry windows_options::s_option_entries[] =
|
||||
{ WINOPTION_VECTOR_LENGTH_RATIO";vecsize", "4.0", OPTION_FLOAT, "Vector fade length (4.0 - vectors fade the most at and above 4 pixels, etc.)" },
|
||||
/* Bloom below this line */
|
||||
{ NULL, NULL, OPTION_HEADER, "BLOOM POST-PROCESSING OPTIONS" },
|
||||
{ WINOPTION_VECTOR_BLOOM_SCALE, "0.3", OPTION_FLOAT, "Intensity factor for vector bloom" },
|
||||
{ WINOPTION_RASTER_BLOOM_SCALE, "0.25", OPTION_FLOAT, "Intensity factor for raster bloom" },
|
||||
{ WINOPTION_BLOOM_LEVEL0_WEIGHT, "1.0", OPTION_FLOAT, "Bloom level 0 (full-size target) weight" },
|
||||
{ WINOPTION_BLOOM_LEVEL1_WEIGHT, "0.21", OPTION_FLOAT, "Bloom level 1 (half-size target) weight" },
|
||||
{ WINOPTION_BLOOM_LEVEL2_WEIGHT, "0.19", OPTION_FLOAT, "Bloom level 2 (quarter-size target) weight" },
|
||||
|
@ -133,6 +133,8 @@
|
||||
#define WINOPTION_VECTOR_TIME_PERIOD "vector_time_period"
|
||||
#define WINOPTION_VECTOR_LENGTH_SCALE "vector_length_scale"
|
||||
#define WINOPTION_VECTOR_LENGTH_RATIO "vector_length_ratio"
|
||||
#define WINOPTION_VECTOR_BLOOM_SCALE "vector_bloom_scale"
|
||||
#define WINOPTION_RASTER_BLOOM_SCALE "raster_bloom_scale"
|
||||
#define WINOPTION_BLOOM_LEVEL0_WEIGHT "bloom_lvl0_weight"
|
||||
#define WINOPTION_BLOOM_LEVEL1_WEIGHT "bloom_lvl1_weight"
|
||||
#define WINOPTION_BLOOM_LEVEL2_WEIGHT "bloom_lvl2_weight"
|
||||
@ -256,6 +258,8 @@ public:
|
||||
float screen_vector_time_period() const { return float_value(WINOPTION_VECTOR_TIME_PERIOD); }
|
||||
float screen_vector_length_scale() const { return float_value(WINOPTION_VECTOR_LENGTH_SCALE); }
|
||||
float screen_vector_length_ratio() const { return float_value(WINOPTION_VECTOR_LENGTH_RATIO); }
|
||||
float screen_vector_bloom_scale() const { return float_value(WINOPTION_VECTOR_BLOOM_SCALE); }
|
||||
float screen_raster_bloom_scale() const { return float_value(WINOPTION_RASTER_BLOOM_SCALE); }
|
||||
float screen_bloom_lvl0_weight() const { return float_value(WINOPTION_BLOOM_LEVEL0_WEIGHT); }
|
||||
float screen_bloom_lvl1_weight() const { return float_value(WINOPTION_BLOOM_LEVEL1_WEIGHT); }
|
||||
float screen_bloom_lvl2_weight() const { return float_value(WINOPTION_BLOOM_LEVEL2_WEIGHT); }
|
||||
|
Loading…
Reference in New Issue
Block a user