summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl
diff options
context:
space:
mode:
Diffstat (limited to 'hlsl')
-rw-r--r--hlsl/artwork_support/post.fx33
-rw-r--r--hlsl/distortion.fx7
-rw-r--r--hlsl/focus.fx18
-rw-r--r--hlsl/post.fx30
-rw-r--r--hlsl/prescale.fx10
5 files changed, 33 insertions, 65 deletions
diff --git a/hlsl/artwork_support/post.fx b/hlsl/artwork_support/post.fx
index 48530272c9d..8da6dabf1ab 100644
--- a/hlsl/artwork_support/post.fx
+++ b/hlsl/artwork_support/post.fx
@@ -74,11 +74,6 @@ static const float GelfondSchneider = 2.6651442f; // 2^sqrt(2) (Gelfond-Schneide
// Functions
//-----------------------------------------------------------------------------
-bool xor(bool a, bool b)
-{
- return (a || b) && !(a && b);
-}
-
// www.stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader/
float random(float2 seed)
{
@@ -114,8 +109,8 @@ uniform float2 QuadDims; // size of the screen quad
uniform float2 ShadowDims = float2(32.0f, 32.0f); // size of the shadow texture (extended to power-of-two size)
uniform float2 ShadowUVOffset = float2(0.0f, 0.0f);
-uniform bool OrientationSwapXY = false; // false landscape, true portrait for default screen orientation
-uniform bool RotationSwapXY = false; // swapped default screen orientation due to screen rotation
+uniform bool SwapXY = false;
+
uniform int RotationType = 0; // 0 = 0°, 1 = 90°, 2 = 180°, 3 = 270°
uniform bool PrepareBloom = false; // disables some effects for rendering bloom textures
@@ -126,7 +121,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
VS_OUTPUT Output = (VS_OUTPUT)0;
float2 shadowUVOffset = ShadowUVOffset;
- shadowUVOffset = xor(OrientationSwapXY, RotationSwapXY)
+ shadowUVOffset = SwapXY
? shadowUVOffset.yx
: shadowUVOffset.xy;
@@ -227,7 +222,7 @@ float GetSpotAddend(float2 coord, float amount)
// normalized screen canvas ratio
float2 CanvasRatio = PrepareVector
? float2(1.0f, QuadDims.y / QuadDims.x)
- : float2(1.0f, xor(OrientationSwapXY, RotationSwapXY)
+ : float2(1.0f, SwapXY
? QuadDims.x / QuadDims.y
: QuadDims.y / QuadDims.x);
@@ -240,7 +235,7 @@ float GetSpotAddend(float2 coord, float amount)
: RotationType == 3 // 270°
? float2(0.25f, 0.25f)
: float2(-0.25f, 0.25f)
- : OrientationSwapXY
+ : SwapXY
? float2(0.25f, 0.25f)
: float2(-0.25f, 0.25f);
@@ -272,7 +267,7 @@ float GetRoundCornerFactor(float2 coord, float radiusAmount, float smoothAmount)
float2 CanvasDims = PrepareVector
? ScreenDims
- : xor(OrientationSwapXY, RotationSwapXY)
+ : SwapXY
? QuadDims.yx / SourceRect
: QuadDims.xy / SourceRect;
@@ -375,9 +370,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
float2 ScreenTexelDims = 1.0f / ScreenDims;
float2 SourceTexelDims = 1.0f / SourceDims;
- float2 HalfSourceRect = PrepareVector
- ? float2(0.5f, 0.5f)
- : SourceRect * 0.5f;
+ float2 HalfSourceRect = SourceRect * 0.5f;
float2 ScreenCoord = Input.ScreenCoord / ScreenDims;
ScreenCoord = GetCoords(ScreenCoord, float2(0.5f, 0.5f), CurvatureAmount * 0.25f); // reduced amount
@@ -406,34 +399,34 @@ float4 ps_main(PS_INPUT Input) : COLOR
if (!PrepareBloom)
{
float2 shadowDims = ShadowDims;
- shadowDims = xor(OrientationSwapXY, RotationSwapXY)
+ shadowDims = SwapXY
? shadowDims.yx
: shadowDims.xy;
float2 shadowUV = ShadowUV;
- // shadowUV = xor(OrientationSwapXY, RotationSwapXY)
+ // shadowUV = SwapXY
// ? shadowUV.yx
// : shadowUV.xy;
float2 screenCoord = ShadowTileMode == 0 ? ScreenCoord : BaseCoord;
- screenCoord = xor(OrientationSwapXY, RotationSwapXY)
+ screenCoord = SwapXY
? screenCoord.yx
: screenCoord.xy;
float2 shadowCount = ShadowCount;
- shadowCount = xor(OrientationSwapXY, RotationSwapXY)
+ shadowCount = SwapXY
? shadowCount.yx
: shadowCount.xy;
float2 shadowTile = ((ShadowTileMode == 0 ? ScreenTexelDims : SourceTexelDims) * shadowCount);
- shadowTile = xor(OrientationSwapXY, RotationSwapXY)
+ shadowTile = SwapXY
? shadowTile.yx
: shadowTile.xy;
float2 ShadowFrac = frac(screenCoord / shadowTile);
float2 ShadowCoord = (ShadowFrac * shadowUV);
ShadowCoord += 0.5f / shadowDims; // half texel offset
- // ShadowCoord = xor(OrientationSwapXY, RotationSwapXY)
+ // ShadowCoord = SwapXY
// ? ShadowCoord.yx
// : ShadowCoord.xy;
diff --git a/hlsl/distortion.fx b/hlsl/distortion.fx
index f9dd51b697b..63d35789393 100644
--- a/hlsl/distortion.fx
+++ b/hlsl/distortion.fx
@@ -59,11 +59,6 @@ static const float GelfondSchneider = 2.6651442f; // 2^sqrt(2) (Gelfond-Schneide
// Functions
//-----------------------------------------------------------------------------
-bool xor(bool a, bool b)
-{
- return (a || b) && !(a && b);
-}
-
// www.stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader/
float random(float2 seed)
{
@@ -122,8 +117,6 @@ uniform float SmoothBorderAmount = 0.0f;
uniform float VignettingAmount = 0.0f;
uniform float ReflectionAmount = 0.0f;
-uniform bool OrientationSwapXY = false; // false landscape, true portrait for default screen orientation
-uniform bool RotationSwapXY = false; // swapped default screen orientation due to screen rotation
uniform int RotationType = 0; // 0 = 0°, 1 = 90°, 2 = 180°, 3 = 270°
float2 GetRatioCorrection()
diff --git a/hlsl/focus.fx b/hlsl/focus.fx
index 6da8ab928a2..c5e5262fedd 100644
--- a/hlsl/focus.fx
+++ b/hlsl/focus.fx
@@ -46,15 +46,6 @@ struct PS_INPUT
};
//-----------------------------------------------------------------------------
-// Functions
-//-----------------------------------------------------------------------------
-
-bool xor(bool a, bool b)
-{
- return (a || b) && !(a && b);
-}
-
-//-----------------------------------------------------------------------------
// Defocus Vertex Shader
//-----------------------------------------------------------------------------
@@ -98,18 +89,19 @@ float2 Coord8Offset = float2( 1.00f, -0.25f);
uniform float2 Defocus = float2(0.0f, 0.0f);
-uniform bool OrientationSwapXY = false; // false landscape, true portrait for default screen orientation
-uniform bool RotationSwapXY = false; // swapped default screen orientation due to screen rotation
+uniform bool SwapXY = false;
float4 ps_main(PS_INPUT Input) : COLOR
{
float2 QuadRatio =
- float2(1.0f, xor(OrientationSwapXY, RotationSwapXY)
+ float2(1.0f, SwapXY
? QuadDims.y / QuadDims.x
: QuadDims.x / QuadDims.y);
// imaginary texel dimensions independed from quad dimensions, but dependend on quad ratio
- float2 DefocusTexelDims = (1.0f / 1024.0) * SourceRect * QuadRatio * Defocus;
+ float2 TexelDims = (1.0f / 1024.0) * SourceRect * QuadRatio;
+
+ float2 DefocusTexelDims = Defocus * TexelDims;
float4 d = tex2D(DiffuseSampler, Input.TexCoord);
float3 d1 = tex2D(DiffuseSampler, Input.TexCoord + Coord1Offset * DefocusTexelDims).rgb;
diff --git a/hlsl/post.fx b/hlsl/post.fx
index 2b175dedf90..4415298a2f8 100644
--- a/hlsl/post.fx
+++ b/hlsl/post.fx
@@ -67,15 +67,6 @@ struct PS_INPUT
static const float PI = 3.1415927f;
//-----------------------------------------------------------------------------
-// Functions
-//-----------------------------------------------------------------------------
-
-bool xor(bool a, bool b)
-{
- return (a || b) && !(a && b);
-}
-
-//-----------------------------------------------------------------------------
// Scanline & Shadowmask Vertex Shader
//-----------------------------------------------------------------------------
@@ -87,8 +78,7 @@ uniform float2 TargetDims; // size of the target surface
uniform float2 ShadowDims = float2(32.0f, 32.0f); // size of the shadow texture (extended to power-of-two size)
uniform float2 ShadowUVOffset = float2(0.0f, 0.0f);
-uniform bool OrientationSwapXY = false; // false landscape, true portrait for default screen orientation
-uniform bool RotationSwapXY = false; // swapped default screen orientation due to screen rotation
+uniform bool SwapXY = false;
uniform bool PrepareBloom = false; // disables some effects for rendering bloom textures
uniform bool PrepareVector = false;
@@ -98,7 +88,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
VS_OUTPUT Output = (VS_OUTPUT)0;
float2 shadowUVOffset = ShadowUVOffset;
- shadowUVOffset = xor(OrientationSwapXY, RotationSwapXY)
+ shadowUVOffset = SwapXY
? shadowUVOffset.yx
: shadowUVOffset.xy;
@@ -170,9 +160,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
float2 ScreenTexelDims = 1.0f / ScreenDims;
float2 SourceTexelDims = 1.0f / SourceDims;
- float2 HalfSourceRect = PrepareVector
- ? float2(0.5f, 0.5f)
- : SourceRect * 0.5f;
+ float2 HalfSourceRect = SourceRect * 0.5f;
float2 ScreenCoord = Input.ScreenCoord / ScreenDims;
float2 BaseCoord = GetAdjustedCoords(Input.TexCoord, HalfSourceRect);
@@ -190,34 +178,34 @@ float4 ps_main(PS_INPUT Input) : COLOR
if (!PrepareBloom)
{
float2 shadowDims = ShadowDims;
- shadowDims = xor(OrientationSwapXY, RotationSwapXY)
+ shadowDims = SwapXY
? shadowDims.yx
: shadowDims.xy;
float2 shadowUV = ShadowUV;
- // shadowUV = xor(OrientationSwapXY, RotationSwapXY)
+ // shadowUV = SwapXY
// ? shadowUV.yx
// : shadowUV.xy;
float2 screenCoord = ShadowTileMode == 0 ? ScreenCoord : BaseCoord;
- screenCoord = xor(OrientationSwapXY, RotationSwapXY)
+ screenCoord = SwapXY
? screenCoord.yx
: screenCoord.xy;
float2 shadowCount = ShadowCount;
- shadowCount = xor(OrientationSwapXY, RotationSwapXY)
+ shadowCount = SwapXY
? shadowCount.yx
: shadowCount.xy;
float2 shadowTile = ((ShadowTileMode == 0 ? ScreenTexelDims : SourceTexelDims) * shadowCount);
- shadowTile = xor(OrientationSwapXY, RotationSwapXY)
+ shadowTile = SwapXY
? shadowTile.yx
: shadowTile.xy;
float2 ShadowFrac = frac(screenCoord / shadowTile);
float2 ShadowCoord = (ShadowFrac * shadowUV);
ShadowCoord += 0.5f / shadowDims; // half texel offset
- // ShadowCoord = xor(OrientationSwapXY, RotationSwapXY)
+ // ShadowCoord = SwapXY
// ? ShadowCoord.yx
// : ShadowCoord.xy;
diff --git a/hlsl/prescale.fx b/hlsl/prescale.fx
index 33b2a4efb06..846c02577ce 100644
--- a/hlsl/prescale.fx
+++ b/hlsl/prescale.fx
@@ -49,6 +49,7 @@ struct PS_INPUT
//-----------------------------------------------------------------------------
uniform float2 ScreenDims;
+uniform float2 TargetDims;
VS_OUTPUT vs_main(VS_INPUT Input)
{
@@ -56,11 +57,12 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.xy /= ScreenDims;
- Output.Position.y = 1.0f - Output.Position.y;
- Output.Position.xy -= 0.5f;
- Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
+ Output.Position.y = 1.0f - Output.Position.y; // flip y
+ Output.Position.xy -= 0.5f; // center
+ Output.Position.xy *= 2.0f; // zoom
- Output.TexCoord = Input.TexCoord + 0.5f / ScreenDims;
+ Output.TexCoord = Input.TexCoord;
+ Output.TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
return Output;
}