summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl/primary.fx
diff options
context:
space:
mode:
Diffstat (limited to 'hlsl/primary.fx')
-rw-r--r--hlsl/primary.fx17
1 files changed, 14 insertions, 3 deletions
diff --git a/hlsl/primary.fx b/hlsl/primary.fx
index da9abf028be..130c1cd4706 100644
--- a/hlsl/primary.fx
+++ b/hlsl/primary.fx
@@ -45,24 +45,33 @@ struct PS_INPUT
// Simple Vertex Shader
//-----------------------------------------------------------------------------
+static const float Epsilon = 1.0e-7f;
+
uniform float2 ScreenDims;
+uniform float2 TargetDims;
uniform bool PostPass;
+
uniform float Brighten;
VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
-
+
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.xy /= ScreenDims;
Output.Position.y = 1.0f - Output.Position.y; // flip y
Output.Position.xy -= 0.5f; // center
Output.Position.xy *= 2.0f; // zoom
- Output.TexCoord = PostPass
+ float2 targetDims = TargetDims + Epsilon; // bug: with exact target dimensions the font disappears
+
+ Output.TexCoord = PostPass
? Input.Position.xy / ScreenDims
: Input.TexCoord;
+ Output.TexCoord += PostPass
+ ? 0.5f / targetDims // half texel offset correction (DX9)
+ : 0.0f;
Output.Color = Input.Color;
@@ -76,7 +85,9 @@ VS_OUTPUT vs_main(VS_INPUT Input)
float4 ps_main(PS_INPUT Input) : COLOR
{
float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
- return BaseTexel * (Input.Color + float4(Brighten, Brighten, Brighten, 0.0f));
+ BaseTexel *= Input.Color + float4(Brighten, Brighten, Brighten, 0.0f);
+
+ return BaseTexel;
}
//-----------------------------------------------------------------------------