summaryrefslogtreecommitdiff
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
parenta6fcd3f4c75651e08c4392dea8a77b7fed1c2fe5 (diff)
downloadWorldTuningTool-b07893ab935c25d07d81f15521a25cca769a28c1.tar.gz
WorldTuningTool-b07893ab935c25d07d81f15521a25cca769a28c1.tar.bz2
WorldTuningTool-b07893ab935c25d07d81f15521a25cca769a28c1.zip
Cleanup notes
Signed-off-by: Andrew Opalach <andrew@akon.city>
-rw-r--r--README.txt3
-rw-r--r--Scripts/3dmigoto_unsigned_int_and_hacks.diff76
-rwxr-xr-xScripts/generate_diffs.sh4
-rw-r--r--Shaders/fxaa_max_quality.hlsl87
-rw-r--r--Shaders/notes.txt11
5 files changed, 170 insertions, 11 deletions
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..0c44d17
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,3 @@
+== World Tuning Tool
+
+// vim: set syntax=asciidoc:
diff --git a/Scripts/3dmigoto_unsigned_int_and_hacks.diff b/Scripts/3dmigoto_unsigned_int_and_hacks.diff
new file mode 100644
index 0000000..b45317d
--- /dev/null
+++ b/Scripts/3dmigoto_unsigned_int_and_hacks.diff
@@ -0,0 +1,76 @@
+For more complete decompile of Monster Hunter World shaders.
+diff --git a/BinaryDecompiler/decode.cpp b/BinaryDecompiler/decode.cpp
+index 89ac94f0..9356d27b 100644
+--- a/BinaryDecompiler/decode.cpp
++++ b/BinaryDecompiler/decode.cpp
+@@ -333,7 +333,7 @@ uint32_t DecodeOperand (const uint32_t *pui32Tokens, Operand* psOperand)
+ }
+ default:
+ {
+- ASSERT(0);
++ //ASSERT(0);
+ break;
+ }
+ }
+diff --git a/HLSLDecompiler/DecompileHLSL.cpp b/HLSLDecompiler/DecompileHLSL.cpp
+index 6175e733..24913e88 100644
+--- a/HLSLDecompiler/DecompileHLSL.cpp
++++ b/HLSLDecompiler/DecompileHLSL.cpp
+@@ -1493,7 +1493,7 @@ public:
+ {
+ int in[4] = { 0, 0, 0, 0 };
+
+- numRead = sscanf_s(c + pos, "// = %i %i %i %i", in + 0, in + 1, in + 2, in + 3);
++ numRead = sscanf_s(c + pos, "// = %d %d %d %d", in + 0, in + 1, in + 2, in + 3);
+ NextLine(c, pos, size);
+
+ if (structLevel < 0)
+@@ -1510,10 +1510,37 @@ public:
+
+ for (int i = 0; i < numRead - 1; ++i)
+ {
+- sprintf(buffer, "%i,", in[i]);
++ sprintf(buffer, "%d,", in[i]);
+ mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer));
+ }
+- sprintf(buffer, "%i};\n", in[numRead - 1]);
++ sprintf(buffer, "%d};\n", in[numRead - 1]);
++ mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer));
++ }
++ else if (e.bt == DT_uint || e.bt == DT_uint2 || e.bt == DT_uint3 || e.bt == DT_uint4)
++ {
++ unsigned in[4] = { 0, 0, 0, 0 };
++
++ numRead = sscanf_s(c + pos, "// = %u %u %u %u", in + 0, in + 1, in + 2, in + 3);
++ NextLine(c, pos, size);
++
++ if (structLevel < 0)
++ {
++ if (suboffset == 0)
++ sprintf(buffer, " %s%s %s : packoffset(c%u) = {", modifier.c_str(), type, name, packoffset);
++ else
++ sprintf(buffer, " %s%s %s : packoffset(c%u.%c) = {", modifier.c_str(), type, name, packoffset, INDEX_MASK[suboffset]);
++ }
++ else
++ sprintf(buffer, " %s%s%s %s = {", structSpacing.c_str(), modifier.c_str(), type, name);
++
++ mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer));
++
++ for (int i = 0; i < numRead - 1; ++i)
++ {
++ sprintf(buffer, "%u,", in[i]);
++ mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer));
++ }
++ sprintf(buffer, "%u};\n", in[numRead - 1]);
+ mOutput.insert(mOutput.end(), buffer, buffer + strlen(buffer));
+ }
+ else if (e.bt == DT_float || e.bt == DT_float2 || e.bt == DT_float3 || e.bt == DT_float4)
+@@ -2510,7 +2537,7 @@ public:
+ else if (!strncmp(textype, "TextureCubeArray<", strlen("TextureCubeArray<"))) pos = 5; // float4 .xyzw
+ else logDecompileError(" unknown texture type for truncation: " + string(textype));
+ cpos = strrchr(op, '.');
+- cpos[pos] = 0;
++ if (cpos) cpos[pos] = 0;
+ }
+ }
+
diff --git a/Scripts/generate_diffs.sh b/Scripts/generate_diffs.sh
index b0c5687..d7e0d70 100755
--- a/Scripts/generate_diffs.sh
+++ b/Scripts/generate_diffs.sh
@@ -1,5 +1,9 @@
#! /usr/bin/env sh
+# https://github.com/bo3b/3Dmigoto
+# Disassemble: cmd_Decompiler.exe -d shader.dxbc (saved from RenderDoc).
+# Assemble: cmd_Decompiler.exe -a shader.asm (edited)
+
#wine cmd_Decompiler.exe -d ../Shaders/Original/*.dxbc
#wine cmd_Decompiler.exe -d ../Shaders/*.shdr
#diff -u orig.asm edit.asm
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;
diff --git a/Shaders/notes.txt b/Shaders/notes.txt
deleted file mode 100644
index a2e172b..0000000
--- a/Shaders/notes.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-# FXAA Source
-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
-
-# Links
-https://github.com/bo3b/3Dmigoto
-https://stackoverflow.com/questions/74722423/i-need-a-source-of-information-about-directxs-assembler
-https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/registers---cs-5-0
-https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-to-load