summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl/post.fx
diff options
context:
space:
mode:
author ImJezze <jezze@gmx.net>2015-11-17 19:37:56 +0100
committer ImJezze <jezze@gmx.net>2015-11-17 19:37:56 +0100
commit8be53c28f0266af433076a6f5c1f1fa0abc70867 (patch)
tree5167ec845cdb853dddcbbafd84749308d3888095 /hlsl/post.fx
parent5200f15ace282ad246bd38af900472db353ba241 (diff)
Changed screen adjustment for HLSL
- screen adjustment (scale, offset) can now be handled by the respective render API itself (default behavior is as before) - D3D (if HLSL) is activated handles screen adjustment by itself within the shader, which fixes the odd behavior of some effects (e.g. round corners) when screen scale and offset is used
Diffstat (limited to 'hlsl/post.fx')
-rw-r--r--hlsl/post.fx32
1 files changed, 31 insertions, 1 deletions
diff --git a/hlsl/post.fx b/hlsl/post.fx
index b457b9687e2..7ab09b45ddb 100644
--- a/hlsl/post.fx
+++ b/hlsl/post.fx
@@ -77,6 +77,7 @@ bool xor(bool a, bool b)
uniform float2 ScreenDims; // size of the window or fullscreen
uniform float2 SourceDims; // size of the texture in power-of-two size
+uniform float2 SourceRect; // size of the uv rectangle
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)
@@ -124,6 +125,9 @@ VS_OUTPUT vs_main(VS_INPUT Input)
// Post-Processing Pixel Shader
//-----------------------------------------------------------------------------
+uniform float2 ScreenScale = float2(1.0f, 1.0f);
+uniform float2 ScreenOffset = float2(0.0f, 0.0f);
+
uniform float ScanlineAlpha = 1.0f;
uniform float ScanlineScale = 1.0f;
uniform float ScanlineBrightScale = 1.0f;
@@ -138,17 +142,43 @@ uniform float2 ShadowUV = float2(0.25f, 0.25f);
uniform float3 Power = float3(1.0f, 1.0f, 1.0f);
uniform float3 Floor = float3(0.0f, 0.0f, 0.0f);
+float2 GetAdjustedCoords(float2 coord, float2 centerOffset)
+{
+ // center coordinates
+ coord -= centerOffset;
+
+ // apply screen scale
+ coord /= ScreenScale;
+
+ // un-center coordinates
+ coord += centerOffset;
+
+ // apply screen offset
+ coord += (centerOffset * 2.0) * ScreenOffset;
+
+ return coord;
+}
+
float4 ps_main(PS_INPUT Input) : COLOR
{
float2 ScreenTexelDims = 1.0f / ScreenDims;
+ float2 HalfSourceRect = PrepareVector
+ ? float2(0.5f, 0.5f)
+ : SourceRect * 0.5f;
+
float2 ScreenCoord = Input.ScreenCoord / ScreenDims;
- float2 BaseCoord = Input.TexCoord;
+ float2 BaseCoord = GetAdjustedCoords(Input.TexCoord, HalfSourceRect);
// Color
float4 BaseColor = tex2D(DiffuseSampler, BaseCoord);
BaseColor.a = 1.0f;
+ if (BaseCoord.x < 0.0f || BaseCoord.y < 0.0f)
+ {
+ BaseColor.rgb = 0.0f;
+ }
+
// Mask Simulation (may not affect bloom)
if (!PrepareBloom)
{