mirror of
https://github.com/holub/mame
synced 2025-07-05 09:57:47 +03:00
Fixed Bloom Level Alignment
- fixed target dimensions of bloom levels, which results in a much better alignment especially for game with very low resolution (therefore current bloom settings might look a little less intense than before) - small cleanups (nw)
This commit is contained in:
parent
f5e3032d98
commit
d15d53c728
@ -57,6 +57,11 @@ uniform float2 SourceRect;
|
|||||||
|
|
||||||
uniform bool PrepareVector;
|
uniform bool PrepareVector;
|
||||||
|
|
||||||
|
static const float2 Coord0Offset = float2(-0.5f, -0.5f);
|
||||||
|
static const float2 Coord1Offset = float2( 0.5f, -0.5f);
|
||||||
|
static const float2 Coord2Offset = float2(-0.5f, 0.5f);
|
||||||
|
static const float2 Coord3Offset = float2( 0.5f, 0.5f);
|
||||||
|
|
||||||
VS_OUTPUT vs_main(VS_INPUT Input)
|
VS_OUTPUT vs_main(VS_INPUT Input)
|
||||||
{
|
{
|
||||||
VS_OUTPUT Output = (VS_OUTPUT)0;
|
VS_OUTPUT Output = (VS_OUTPUT)0;
|
||||||
@ -72,14 +77,12 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||||||
Output.Color = Input.Color;
|
Output.Color = Input.Color;
|
||||||
|
|
||||||
float2 TexCoord = Input.Position.xy / ScreenDims;
|
float2 TexCoord = Input.Position.xy / ScreenDims;
|
||||||
TexCoord += PrepareVector
|
TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
|
||||||
? 0.5f / TargetDims // half texel offset correction (DX9) - only for vector grpahics
|
|
||||||
: 0.0f;
|
|
||||||
|
|
||||||
Output.TexCoord01.xy = TexCoord + float2(-0.5f, -0.5f) * TargetTexelDims;
|
Output.TexCoord01.xy = TexCoord + Coord0Offset * TargetTexelDims;
|
||||||
Output.TexCoord01.zw = TexCoord + float2( 0.5f, -0.5f) * TargetTexelDims;
|
Output.TexCoord01.zw = TexCoord + Coord1Offset * TargetTexelDims;
|
||||||
Output.TexCoord23.xy = TexCoord + float2(-0.5f, 0.5f) * TargetTexelDims;
|
Output.TexCoord23.xy = TexCoord + Coord2Offset * TargetTexelDims;
|
||||||
Output.TexCoord23.zw = TexCoord + float2( 0.5f, 0.5f) * TargetTexelDims;
|
Output.TexCoord23.zw = TexCoord + Coord3Offset * TargetTexelDims;
|
||||||
|
|
||||||
return Output;
|
return Output;
|
||||||
}
|
}
|
||||||
|
@ -78,19 +78,19 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||||||
// Defocus Pixel Shader
|
// Defocus Pixel Shader
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
float2 Coord1Offset = float2( 0.75f, 0.50f);
|
|
||||||
float2 Coord2Offset = float2( 0.25f, 1.00f);
|
|
||||||
float2 Coord3Offset = float2(-0.50f, 0.75f);
|
|
||||||
float2 Coord4Offset = float2(-1.00f, 0.25f);
|
|
||||||
float2 Coord5Offset = float2(-0.75f, -0.50f);
|
|
||||||
float2 Coord6Offset = float2(-0.25f, -1.00f);
|
|
||||||
float2 Coord7Offset = float2( 0.50f, -0.75f);
|
|
||||||
float2 Coord8Offset = float2( 1.00f, -0.25f);
|
|
||||||
|
|
||||||
uniform float2 Defocus = float2(0.0f, 0.0f);
|
uniform float2 Defocus = float2(0.0f, 0.0f);
|
||||||
|
|
||||||
uniform bool SwapXY = false;
|
uniform bool SwapXY = false;
|
||||||
|
|
||||||
|
static const float2 Coord1Offset = float2( 0.75f, 0.50f);
|
||||||
|
static const float2 Coord2Offset = float2( 0.25f, 1.00f);
|
||||||
|
static const float2 Coord3Offset = float2(-0.50f, 0.75f);
|
||||||
|
static const float2 Coord4Offset = float2(-1.00f, 0.25f);
|
||||||
|
static const float2 Coord5Offset = float2(-0.75f, -0.50f);
|
||||||
|
static const float2 Coord6Offset = float2(-0.25f, -1.00f);
|
||||||
|
static const float2 Coord7Offset = float2( 0.50f, -0.75f);
|
||||||
|
static const float2 Coord8Offset = float2( 1.00f, -0.25f);
|
||||||
|
|
||||||
float4 ps_main(PS_INPUT Input) : COLOR
|
float4 ps_main(PS_INPUT Input) : COLOR
|
||||||
{
|
{
|
||||||
float2 QuadRatio =
|
float2 QuadRatio =
|
||||||
|
@ -54,13 +54,13 @@ uniform float2 TargetDims;
|
|||||||
VS_OUTPUT vs_main(VS_INPUT Input)
|
VS_OUTPUT vs_main(VS_INPUT Input)
|
||||||
{
|
{
|
||||||
VS_OUTPUT Output = (VS_OUTPUT)0;
|
VS_OUTPUT Output = (VS_OUTPUT)0;
|
||||||
|
|
||||||
Output.Position = float4(Input.Position.xyz, 1.0f);
|
Output.Position = float4(Input.Position.xyz, 1.0f);
|
||||||
Output.Position.xy /= ScreenDims;
|
Output.Position.xy /= ScreenDims;
|
||||||
Output.Position.y = 1.0f - Output.Position.y; // flip y
|
Output.Position.y = 1.0f - Output.Position.y; // flip y
|
||||||
Output.Position.xy -= 0.5f; // center
|
Output.Position.xy -= 0.5f; // center
|
||||||
Output.Position.xy *= 2.0f; // zoom
|
Output.Position.xy *= 2.0f; // zoom
|
||||||
|
|
||||||
Output.TexCoord = Input.TexCoord;
|
Output.TexCoord = Input.TexCoord;
|
||||||
Output.TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
|
Output.TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
|
||||||
|
|
||||||
|
@ -1464,8 +1464,8 @@ int shaders::downsample_pass(render_target *rt, int source_index, poly_info *pol
|
|||||||
|
|
||||||
int bloom_index = 0;
|
int bloom_index = 0;
|
||||||
float bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height();
|
float bloom_size = (d3d->get_width() < d3d->get_height()) ? d3d->get_width() : d3d->get_height();
|
||||||
float bloom_width = prepare_vector ? rt->target_width : rt->target_width / hlsl_prescale_x;
|
float bloom_width = d3d->get_width();
|
||||||
float bloom_height = prepare_vector ? rt->target_height : rt->target_height / hlsl_prescale_y;
|
float bloom_height = d3d->get_height();
|
||||||
for (; bloom_size >= 2.0f && bloom_index < 11; bloom_size *= 0.5f)
|
for (; bloom_size >= 2.0f && bloom_index < 11; bloom_size *= 0.5f)
|
||||||
{
|
{
|
||||||
bloom_dims[bloom_index][0] = (float)(int)bloom_width;
|
bloom_dims[bloom_index][0] = (float)(int)bloom_width;
|
||||||
@ -2013,7 +2013,7 @@ bool shaders::register_texture(texture_info *texture)
|
|||||||
enumerate_screens();
|
enumerate_screens();
|
||||||
|
|
||||||
// Find the nearest prescale factor that is over our screen size
|
// Find the nearest prescale factor that is over our screen size
|
||||||
if (hlsl_prescale_x == 0)
|
if (hlsl_prescale_x < 1)
|
||||||
{
|
{
|
||||||
hlsl_prescale_x = 1;
|
hlsl_prescale_x = 1;
|
||||||
while (width * xscale * hlsl_prescale_x <= d3d->get_width())
|
while (width * xscale * hlsl_prescale_x <= d3d->get_width())
|
||||||
@ -2023,7 +2023,7 @@ bool shaders::register_texture(texture_info *texture)
|
|||||||
hlsl_prescale_x--;
|
hlsl_prescale_x--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hlsl_prescale_y == 0)
|
if (hlsl_prescale_y < 1)
|
||||||
{
|
{
|
||||||
hlsl_prescale_y = 1;
|
hlsl_prescale_y = 1;
|
||||||
while (height * yscale * hlsl_prescale_y <= d3d->get_height())
|
while (height * yscale * hlsl_prescale_y <= d3d->get_height())
|
||||||
@ -2033,8 +2033,8 @@ bool shaders::register_texture(texture_info *texture)
|
|||||||
hlsl_prescale_y--;
|
hlsl_prescale_y--;
|
||||||
}
|
}
|
||||||
|
|
||||||
hlsl_prescale_x = ((hlsl_prescale_x == 0) ? 1 : hlsl_prescale_x);
|
hlsl_prescale_x = hlsl_prescale_x < 1 ? 1 : hlsl_prescale_x;
|
||||||
hlsl_prescale_y = ((hlsl_prescale_y == 0) ? 1 : hlsl_prescale_y);
|
hlsl_prescale_y = hlsl_prescale_y < 1 ? 1 : hlsl_prescale_y;
|
||||||
|
|
||||||
if (!add_render_target(d3d, texture, width, height, xscale * hlsl_prescale_x, yscale * hlsl_prescale_y))
|
if (!add_render_target(d3d, texture, width, height, xscale * hlsl_prescale_x, yscale * hlsl_prescale_y))
|
||||||
{
|
{
|
||||||
|
@ -43,9 +43,11 @@ public:
|
|||||||
surface *last_target;
|
surface *last_target;
|
||||||
texture *last_texture;
|
texture *last_texture;
|
||||||
|
|
||||||
|
// real target dimension
|
||||||
int target_width;
|
int target_width;
|
||||||
int target_height;
|
int target_height;
|
||||||
|
|
||||||
|
// only used to identify/find the render target
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|
||||||
@ -66,12 +68,14 @@ public:
|
|||||||
bool init(renderer *d3d, base *d3dintf, int width, int height, int prescale_x, int prescale_y);
|
bool init(renderer *d3d, base *d3dintf, int width, int height, int prescale_x, int prescale_y);
|
||||||
int next_index(int index) { return ++index > 1 ? 0 : index; }
|
int next_index(int index) { return ++index > 1 ? 0 : index; }
|
||||||
|
|
||||||
|
// real target dimension
|
||||||
int target_width;
|
int target_width;
|
||||||
int target_height;
|
int target_height;
|
||||||
|
|
||||||
int prescale_x;
|
int prescale_x;
|
||||||
int prescale_y;
|
int prescale_y;
|
||||||
|
|
||||||
|
// only used to identify/find the render target
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user