mirror of
https://github.com/holub/mame
synced 2025-10-04 16:34:53 +03:00
Fixed black border
- fixed black border on the right and bottom side of the screen, caused by the previously added rounded corners
This commit is contained in:
parent
2dbbb67a4c
commit
a7e221a4a7
40
hlsl/post.fx
40
hlsl/post.fx
@ -84,9 +84,10 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||||||
{
|
{
|
||||||
VS_OUTPUT Output = (VS_OUTPUT)0;
|
VS_OUTPUT Output = (VS_OUTPUT)0;
|
||||||
|
|
||||||
float2 ScreenTexelDims = 1.0f / ScreenDims;
|
float4 Position = Input.Position;
|
||||||
float2 SourceTexelDims = 1.0f / SourceDims;
|
Position.xy *= (ScreenDims + 1.0f) / ScreenDims;
|
||||||
|
Position.xy -= 0.5f / ScreenDims;
|
||||||
|
|
||||||
float2 shadowUVOffset = ShadowUVOffset;
|
float2 shadowUVOffset = ShadowUVOffset;
|
||||||
shadowUVOffset = xor(OrientationSwapXY, RotationSwapXY)
|
shadowUVOffset = xor(OrientationSwapXY, RotationSwapXY)
|
||||||
? shadowUVOffset.yx
|
? shadowUVOffset.yx
|
||||||
@ -96,17 +97,16 @@ VS_OUTPUT vs_main(VS_INPUT Input)
|
|||||||
float2 ScreenCoordPrescaleOffset = 0.0f;
|
float2 ScreenCoordPrescaleOffset = 0.0f;
|
||||||
ScreenCoordPrescaleOffset += shadowUVOffset;
|
ScreenCoordPrescaleOffset += shadowUVOffset;
|
||||||
|
|
||||||
Output.ScreenCoord = Input.Position;
|
Output.ScreenCoord = Position.xy;
|
||||||
Output.ScreenCoord += ScreenCoordPrescaleOffset;
|
Output.ScreenCoord += ScreenCoordPrescaleOffset;
|
||||||
|
|
||||||
Output.Position = float4(Input.Position.xyz, 1.0f);
|
Output.Position = float4(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 -= SourceTexelDims * 0.5f;
|
|
||||||
|
|
||||||
Output.Color = Input.Color;
|
Output.Color = Input.Color;
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ static const float Epsilon = 1.0e-7f;
|
|||||||
static const float PI = 3.1415927f;
|
static const float PI = 3.1415927f;
|
||||||
static const float E = 2.7182817f;
|
static const float E = 2.7182817f;
|
||||||
static const float Gelfond = 23.140692f; // e^pi (Gelfond constant)
|
static const float Gelfond = 23.140692f; // e^pi (Gelfond constant)
|
||||||
static const float GelfondSchneider = 2.6651442f; // 2^sqrt(2) (Gelfond–Schneider constant)
|
static const float GelfondSchneider = 2.6651442f; // 2^sqrt(2) (Gelfond–Schneider constant)
|
||||||
|
|
||||||
float nextPowerOfTwo(float n)
|
float nextPowerOfTwo(float n)
|
||||||
{
|
{
|
||||||
@ -217,13 +217,10 @@ float GetRoundCornerFactor(float2 coord, float amount)
|
|||||||
float2 HalfSourceDims = SourceDims * 0.5f;
|
float2 HalfSourceDims = SourceDims * 0.5f;
|
||||||
float2 SourceTexelDims = 1.0f / SourceDims;
|
float2 SourceTexelDims = 1.0f / SourceDims;
|
||||||
|
|
||||||
float2 RoundCoord = coord;
|
|
||||||
|
|
||||||
// bug: offset and scale correction (due to miss-aligned fullscreen quad)
|
|
||||||
RoundCoord *= (1.0f + SourceTexelDims * ScreenRatio * 2.0f);
|
|
||||||
RoundCoord -= SourceTexelDims * ScreenRatio;
|
|
||||||
|
|
||||||
// hint: roundness correction (base on the default ratio of 4:3)
|
// hint: roundness correction (base on the default ratio of 4:3)
|
||||||
|
float2 RoundCoord = coord;
|
||||||
|
RoundCoord -= SourceTexelDims;
|
||||||
|
RoundCoord *= SourceTexelDims + 1.0f;
|
||||||
RoundCoord *= SourceDims / ScreenRatio;
|
RoundCoord *= SourceDims / ScreenRatio;
|
||||||
|
|
||||||
float radius = amount * 50.0f;
|
float radius = amount * 50.0f;
|
||||||
@ -248,6 +245,7 @@ float GetRoundCornerFactor(float2 coord, float amount)
|
|||||||
float4 ps_main(PS_INPUT Input) : COLOR
|
float4 ps_main(PS_INPUT Input) : COLOR
|
||||||
{
|
{
|
||||||
float2 ScreenTexelDims = 1.0f / ScreenDims;
|
float2 ScreenTexelDims = 1.0f / ScreenDims;
|
||||||
|
float2 SourceTexelDims = 1.0f / SourceDims;
|
||||||
|
|
||||||
float2 UsedArea = 1.0f / SourceRect;
|
float2 UsedArea = 1.0f / SourceRect;
|
||||||
float2 HalfRect = SourceRect * 0.5f;
|
float2 HalfRect = SourceRect * 0.5f;
|
||||||
@ -297,9 +295,9 @@ float4 ps_main(PS_INPUT Input) : COLOR
|
|||||||
float2 BaseAreaCoordCentered = BaseCoordCentered;
|
float2 BaseAreaCoordCentered = BaseCoordCentered;
|
||||||
BaseAreaCoordCentered *= UsedArea;
|
BaseAreaCoordCentered *= UsedArea;
|
||||||
|
|
||||||
// Alpha Clipping (1px border in drawd3d does not work for some reason)
|
// // Alpha Clipping (round corners applies smoother clipping when screen is curved)
|
||||||
clip(BaseCoord < ScreenTexelDims ? -1 : 1);
|
// clip((BaseCoord < SourceTexelDims) ? -1 : 1);
|
||||||
clip(BaseCoord > SourceRect + ScreenTexelDims ? -1 : 1);
|
// clip((BaseCoord > SourceRect + SourceTexelDims) ? -1 : 1);
|
||||||
|
|
||||||
float4 BaseColor = tex2D(DiffuseSampler, BaseCoord);
|
float4 BaseColor = tex2D(DiffuseSampler, BaseCoord);
|
||||||
BaseColor.a = 1.0f;
|
BaseColor.a = 1.0f;
|
||||||
@ -313,10 +311,10 @@ float4 ps_main(PS_INPUT Input) : COLOR
|
|||||||
// Mask Simulation (may not affect bloom)
|
// Mask Simulation (may not affect bloom)
|
||||||
if (!PrepareBloom)
|
if (!PrepareBloom)
|
||||||
{
|
{
|
||||||
float2 ShadowTexelDims = 1.0f / ShadowDims;
|
float2 shadowDims = ShadowDims;
|
||||||
ShadowTexelDims = xor(OrientationSwapXY, RotationSwapXY)
|
shadowDims = xor(OrientationSwapXY, RotationSwapXY)
|
||||||
? ShadowTexelDims.yx
|
? shadowDims.yx
|
||||||
: ShadowTexelDims.xy;
|
: shadowDims.xy;
|
||||||
|
|
||||||
float2 shadowUV = ShadowUV;
|
float2 shadowUV = ShadowUV;
|
||||||
// shadowUV = xor(OrientationSwapXY, RotationSwapXY)
|
// shadowUV = xor(OrientationSwapXY, RotationSwapXY)
|
||||||
@ -340,7 +338,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
|
|||||||
|
|
||||||
float2 ShadowFrac = frac(screenCoord / shadowTile);
|
float2 ShadowFrac = frac(screenCoord / shadowTile);
|
||||||
float2 ShadowCoord = (ShadowFrac * shadowUV);
|
float2 ShadowCoord = (ShadowFrac * shadowUV);
|
||||||
ShadowCoord += ShadowTexelDims * 0.5f; // half texel offset
|
ShadowCoord += 0.5f / shadowDims; // half texel offset
|
||||||
// ShadowCoord = xor(OrientationSwapXY, RotationSwapXY)
|
// ShadowCoord = xor(OrientationSwapXY, RotationSwapXY)
|
||||||
// ? ShadowCoord.yx
|
// ? ShadowCoord.yx
|
||||||
// : ShadowCoord.xy;
|
// : ShadowCoord.xy;
|
||||||
|
Loading…
Reference in New Issue
Block a user