Fixed aspect ratio of rounded corners (nw)

This commit is contained in:
Jezze 2016-09-29 15:19:44 +02:00
parent 2e362cfd6b
commit 68036515ba
7 changed files with 24 additions and 22 deletions

View file

@ -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);

View file

@ -157,20 +157,13 @@ vec2 GetTextureCoords(vec2 coord, float distortionAmount, float cubicDistortionA
return coord;
}
vec2 GetQuadCoords(vec2 coord, float distortionAmount, float cubicDistortionAmount)
vec2 GetQuadCoords(vec2 coord, vec2 scale, float distortionAmount, float cubicDistortionAmount)
{
// center coordinates
coord -= 0.5;
// keep coords inside of the quad bounds of a single screen
if (u_screen_count.x > 0.0 && u_screen_count.x < 2.0)
{
// base-target dimensions (without oversampling)
vec2 BaseTargetDims = u_target_dims.xy / u_target_scale.xy;
// apply base-target/quad difference
coord *= BaseTargetDims / ((u_swap_xy.x > 0.0) ? u_quad_dims.yx : u_quad_dims.xy);
}
// apply scale
coord *= scale;
// distort coordinates
coord = GetDistortedCoords(coord, distortionAmount, cubicDistortionAmount);
@ -197,12 +190,20 @@ void main()
// base-target dimensions (without oversampling)
vec2 BaseTargetDims = u_target_dims.xy / u_target_scale.xy;
BaseTargetDims = (u_swap_xy.x > 0.0)
? BaseTargetDims.yx
: BaseTargetDims.xy;
// base-target/quad difference scale
vec2 BaseTargetQuadScale = (u_screen_count.x > 0.0 && u_screen_count.x < 2.0)
? BaseTargetDims / u_quad_dims.xy // keeps the coords inside of the quad bounds of a single screen
: vec2(1.0, 1.0);
// Screen Texture Curvature
vec2 BaseCoord = GetTextureCoords(v_texcoord0, distortionAmount, cubicDistortionAmount);
// Screen Quad Curvature
vec2 QuadCoord = GetQuadCoords(v_texcoord0, distortCornerAmount, 0.0);
vec2 QuadCoord = GetQuadCoords(v_texcoord0, BaseTargetQuadScale, distortCornerAmount, 0.0);
// Color
vec4 BaseColor = texture2D(s_tex, BaseCoord);