summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl/deconverge.fx
diff options
context:
space:
mode:
author ImJezze <jezze@gmx.net>2016-02-20 21:58:56 +0100
committer ImJezze <jezze@gmx.net>2016-02-20 21:58:56 +0100
commite57c90084c5d1dd9f6cdb0bbbf8782dc4f369cda (patch)
tree650be9617f5dd57cce30eb78e283e15c149a0472 /hlsl/deconverge.fx
parentd15d53c728b4848e3ed74d66b9ab446811e1acee (diff)
Quality and Performance improvements
- HLSL now uses NPOT sized target surfaces (breaks compatibility with graphics cards based on R300/R400/NV30 and older) - HLSL target surfaces now have the size of the screen canvas - removed HLSL pre-scale factor - HLSL now uses a sharp bilinear interpolation to pre-scale textures to screen canvas size, based on [Themaister's] implementation - improved overall performance (based on the previously required pre-scale factor, you might notice a 5-50% speed-up depending on your graphics card, more if you used a higher pre-scale factor) - improved shadow mask quality (pixel-perfect) in screen-mode - fixed half source texel offset of bloom level alignment - removed ./hlsl/artwork_support folder - all shaders after pre-scale are now based on screen coordinate (workaground, till both raster and vector pass can work on texture coordinates) - disabled distortion shader for more than one screen and for artworks in full mode, does not affect artworks in copped mode (workaground, till both raster and vector pass can work on texture coordinates) - moved compute_texture_size() from texture_info to texture_manager (nw)
Diffstat (limited to 'hlsl/deconverge.fx')
-rw-r--r--hlsl/deconverge.fx43
1 files changed, 21 insertions, 22 deletions
diff --git a/hlsl/deconverge.fx b/hlsl/deconverge.fx
index 3c1cbeeeb1f..df5bc2e6b49 100644
--- a/hlsl/deconverge.fx
+++ b/hlsl/deconverge.fx
@@ -68,48 +68,47 @@ VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
- float2 HalfSourceRect = SourceRect * 0.5f;
-
- float2 QuadRatio =
- 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 FixedTexelDims = (1.0f / 1024.0) * SourceRect * QuadRatio;
-
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; // toom
- float2 TexCoord = Input.TexCoord;
+ float2 TexCoord = Input.Position.xy / ScreenDims;
TexCoord += 0.5f / TargetDims; // half texel offset correction (DX9)
-
- Output.Color = Input.Color;
+
+ // we have to handle the swap of the coordinates ourself, because we are using screen not texture coordinates
+ float3 convergeX = SwapXY ? ConvergeY : ConvergeX;
+ float3 convergeY = SwapXY ? ConvergeX : ConvergeY;
+ float3 radialConvergeX = SwapXY ? RadialConvergeY : RadialConvergeX;
+ float3 radialConvergeY = SwapXY ? RadialConvergeX : RadialConvergeY;
+
+ // imaginary texel dimensions independed from screen dimension, but ratio
+ float2 TexelDims = (1.0f / 1024) * (QuadDims / ScreenDims);
Output.TexCoordX = TexCoord.xxx;
Output.TexCoordY = TexCoord.yyy;
// center coordinates
- Output.TexCoordX -= HalfSourceRect.xxx;
- Output.TexCoordY -= HalfSourceRect.yyy;
+ Output.TexCoordX -= 0.5f * SourceRect.xxx;
+ Output.TexCoordY -= 0.5f * SourceRect.yyy;
// radial converge offset to "translate" the most outer pixel as thay would be translated by the linar converge with the same amount
float2 radialConvergeOffset = 2.0f / SourceRect;
// radial converge
- Output.TexCoordX *= 1.0f + RadialConvergeX * FixedTexelDims.xxx * radialConvergeOffset.xxx;
- Output.TexCoordY *= 1.0f + RadialConvergeY * FixedTexelDims.yyy * radialConvergeOffset.yyy;
-
+ Output.TexCoordX *= 1.0f + radialConvergeX * TexelDims.xxx * radialConvergeOffset.xxx;
+ Output.TexCoordY *= 1.0f + radialConvergeY * TexelDims.yyy * radialConvergeOffset.yyy;
+
// un-center coordinates
- Output.TexCoordX += HalfSourceRect.xxx;
- Output.TexCoordY += HalfSourceRect.yyy;
+ Output.TexCoordX += 0.5f * SourceRect.xxx;
+ Output.TexCoordY += 0.5f * SourceRect.yyy;
// linear converge
- Output.TexCoordX += ConvergeX * FixedTexelDims.xxx;
- Output.TexCoordY += ConvergeY * FixedTexelDims.yyy;
+ Output.TexCoordX += convergeX * TexelDims.xxx;
+ Output.TexCoordY += convergeY * TexelDims.yyy;
+
+ Output.Color = Input.Color;
return Output;
}