From 68036515bae237abd7edd58497528f1473fab2ac Mon Sep 17 00:00:00 2001 From: Jezze Date: Thu, 29 Sep 2016 15:19:44 +0200 Subject: Fixed aspect ratio of rounded corners (nw) --- hlsl/distortion.fx | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'hlsl') diff --git a/hlsl/distortion.fx b/hlsl/distortion.fx index c7128bccfef..7624d962a58 100644 --- a/hlsl/distortion.fx +++ b/hlsl/distortion.fx @@ -232,20 +232,13 @@ float2 GetTextureCoords(float2 coord, float distortionAmount, float cubicDistort return coord; } -float2 GetQuadCoords(float2 coord, float distortionAmount, float cubicDistortionAmount) +float2 GetQuadCoords(float2 coord, float2 scale, float distortionAmount, float cubicDistortionAmount) { // center coordinates coord -= 0.5f; - // keep coords inside of the quad bounds of a single screen - if (ScreenCount == 1) - { - // base-target dimensions (without oversampling) - float2 BaseTargetDims = TargetDims / TargetScale; - - // apply base-target/quad difference - coord *= BaseTargetDims / (SwapXY ? QuadDims.yx : QuadDims.xy); - } + // apply scale + coord *= scale; // distort coordinates coord = GetDistortedCoords(coord, distortionAmount, cubicDistortionAmount); @@ -271,12 +264,20 @@ float4 ps_main(PS_INPUT Input) : COLOR // base-target dimensions (without oversampling) float2 BaseTargetDims = TargetDims / TargetScale; + BaseTargetDims = SwapXY + ? BaseTargetDims.yx + : BaseTargetDims.xy; + + // base-target/quad difference scale + float2 BaseTargetQuadScale = ScreenCount == 1 + ? BaseTargetDims / QuadDims // keeps the coords inside of the quad bounds of a single screen + : 1.0f; // Screen Texture Curvature float2 BaseCoord = GetTextureCoords(Input.TexCoord, distortionAmount, cubicDistortionAmount); // Screen Quad Curvature - float2 QuadCoord = GetQuadCoords(Input.TexCoord, distortCornerAmount, 0.0f); + float2 QuadCoord = GetQuadCoords(Input.TexCoord, BaseTargetQuadScale, distortCornerAmount, 0.0f); // clip border clip(BaseCoord < 0.0f - TexelDims || BaseCoord > 1.0f + TexelDims ? -1 : 1); -- cgit v1.2.3-70-g09d2