summaryrefslogtreecommitdiff
path: root/Shaders/fxaa_max_quality.hlsl
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2026-03-17 14:51:15 -0400
committerAndrew Opalach <andrew@akon.city> 2026-03-17 14:51:15 -0400
commitb07893ab935c25d07d81f15521a25cca769a28c1 (patch)
tree1a50706f01c84fd70695ea8d74f89eeaf4da3bde /Shaders/fxaa_max_quality.hlsl
parenta6fcd3f4c75651e08c4392dea8a77b7fed1c2fe5 (diff)
downloadWorldTuningTool-b07893ab935c25d07d81f15521a25cca769a28c1.tar.gz
WorldTuningTool-b07893ab935c25d07d81f15521a25cca769a28c1.tar.bz2
WorldTuningTool-b07893ab935c25d07d81f15521a25cca769a28c1.zip
Cleanup notes
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'Shaders/fxaa_max_quality.hlsl')
-rw-r--r--Shaders/fxaa_max_quality.hlsl87
1 files changed, 87 insertions, 0 deletions
diff --git a/Shaders/fxaa_max_quality.hlsl b/Shaders/fxaa_max_quality.hlsl
index e122754..d7bb253 100644
--- a/Shaders/fxaa_max_quality.hlsl
+++ b/Shaders/fxaa_max_quality.hlsl
@@ -1,3 +1,8 @@
+// https://web.archive.org/web/20120121124756/https://docs.google.com/leaf?id=0B2manFVVrzQAOWUwODM1YmQtNmEwOC00ZDBlLThlYzMtYzE4ZDM1ZjRlMzMx&hl=en_US
+// https://gist.githubusercontent.com/kosua20/0c506b81b3812ac900048059d2383126/raw/9c1f4b97ea5a2ac4bf632fff509f64d7dff0e96a/gistfile1.txt
+// Both sources identical and contain this final patch.
+// https://web.archive.org/web/20120121124756/http://timothylottes.blogspot.com/2011/08/fxaa-311-bug-fixes-for-360.html
+
#define FXAA_PC 1
#define FXAA_HLSL_5 1
#define FXAA_QUALITY__PRESET 39
@@ -2050,6 +2055,87 @@ half4 FxaaPixelShader(
/*==========================================================================*/
#endif
+// https://github.com/Mortalitas/GShade/blob/345b45dda62ccb2070c096b9982fdfbc90280fc6/Shaders/NFAA.fx
+// Edited for readability. Just a test, worse than FXAA.
+
+#define AA_Adjust 16
+#define View_Mode 0
+#define Mask_Adjust 1.0
+
+float4 NFAAGetBB(SamplerState smpl, Texture2D tex, float2 texcoord : TEXCOORD)
+{
+ return tex.SampleLevel(smpl, texcoord, 0.0);
+}
+
+float4 NFAAOut(float4 position : SV_Position, float2 texcoord : TEXCOORD, SamplerState smpl, Texture2D tex, float2 pix) : SV_Target
+{
+ float4 NFAA; // The Edge Seeking code can be adjusted to look for longer edges.
+ float2 UV = texcoord.xy; // But, I don't think it's really needed.
+ float2 SW = pix;
+ float2 n;
+ float t, l, r, d;
+ // Find Edges.
+ t = NFAAGetBB( smpl, tex, float2( UV.x, UV.y - SW.y ) ).a;
+ d = NFAAGetBB( smpl, tex, float2( UV.x, UV.y + SW.y ) ).a;
+ l = NFAAGetBB( smpl, tex, float2( UV.x - SW.x, UV.y ) ).a;
+ r = NFAAGetBB( smpl, tex, float2( UV.x + SW.x, UV.y ) ).a;
+ n = float2(t - d, -(r - l));
+ // I should have made rep adjustable. But, I didn't see the need.
+ // Since my goal was to make this AA fast cheap and simple.
+ float nl = length(n), Rep = rcp(AA_Adjust);
+
+ if (View_Mode == 3)
+ {
+ Rep = rcp(128);
+ }
+ // Seek aliasing and apply AA. Think of this as basicly blur control.
+ if (nl < Rep)
+ {
+ NFAA = NFAAGetBB( smpl, tex,UV);
+ }
+ else
+ {
+ n *= pix / (nl * 0.5);
+
+ const float4 o = NFAAGetBB( smpl, tex, UV ),
+ t0 = NFAAGetBB( smpl, tex, UV + float2(n.x, -n.y) * 0.5) * 0.9,
+ t1 = NFAAGetBB( smpl, tex, UV - float2(n.x, -n.y) * 0.5) * 0.9,
+ t2 = NFAAGetBB( smpl, tex, UV + n * 0.9) * 0.75,
+ t3 = NFAAGetBB( smpl, tex, UV - n * 0.9) * 0.75;
+
+ NFAA = (o + t0 + t1 + t2 + t3) / 4.3;
+ }
+ // Lets make that mask for a sharper image.
+ float Mask = nl*(2.5 * Mask_Adjust);
+
+ if (Mask > 0.025)
+ {
+ Mask = 1-Mask;
+ }
+ else
+ {
+ Mask = 1;
+ }
+ // Super Evil Magic Number.
+ Mask = saturate(lerp(Mask, 1, -1));
+
+ // Final color.
+ if (View_Mode == 0)
+ {
+ NFAA = lerp(NFAA, NFAAGetBB( smpl, tex, texcoord.xy ), Mask);
+ }
+ else if (View_Mode == 1)
+ {
+ NFAA = Mask;
+ }
+ else if (View_Mode == 2)
+ {
+ NFAA = float4(-float2(-(r - l), -(t - d)) * 0.5 + 0.5, 1, 1.0);
+ }
+
+ return NFAA;
+}
+
// ---- Created with 3Dmigoto v1.4.9 on Wed Feb 25 15:30:06 2026
cbuffer CBScreen : register(b1)
@@ -2092,6 +2178,7 @@ void main(
float4 v2 : Color0,
out float4 o0 : SV_Target0)
{
+ //o0 = NFAAOut(v0, v1, SSFilter, tBaseMap, fScreenInverseSize);
FxaaTex tex;
tex.smpl = SSFilter;
tex.tex = tBaseMap;