vkBasalt icon indicating copy to clipboard operation
vkBasalt copied to clipboard

Compatibility with RTGI

Open artivision opened this issue 3 years ago • 7 comments

IS vkBasalt compatible with the Reshade based RTGI of Pascal Gilcher?

artivision avatar Mar 17 '21 01:03 artivision

Last time I tried, it didn't work.

DadSchoorse avatar Mar 17 '21 07:03 DadSchoorse

And in general, there are a lot of issues with depth capture, so I wouldn't expect it to work.

DadSchoorse avatar Mar 17 '21 07:03 DadSchoorse

I needed to make a patch to both vkBasalt and the RTGI stuff to even get it to load.

Here's the vkBasalt patch:

From 9426d1bd4cd0e98c682c04a6a623c885f99207ea Mon Sep 17 00:00:00 2001
Date: Sat, 8 Jul 2023 21:24:21 -0400
Subject: [PATCH] Fix for RTGI

---
 src/reshade_uniforms.cpp | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/reshade_uniforms.cpp b/src/reshade_uniforms.cpp
index b66670d..6d640a3 100644
--- a/src/reshade_uniforms.cpp
+++ b/src/reshade_uniforms.cpp
@@ -15,9 +15,15 @@ namespace vkBasalt
     {
         for (auto& uniform : module.uniforms)
         {
-            auto source = std::find_if(uniform.annotations.begin(), uniform.annotations.end(), [](const auto& a) {
+            auto ann = std::find_if(uniform.annotations.begin(), uniform.annotations.end(), [](const auto& a) {
                               return a.name == "source";
-                          })->value.string_data;
+                          });
+            if (ann == uniform.annotations.end())
+            {
+                continue;
+            }
+
+            auto source = ann->value.string_data;
             Logger::debug(source);
             Logger::debug("size: " + std::to_string(uniform.size));
             Logger::debug("offset: " + std::to_string(uniform.offset));
@@ -29,9 +35,15 @@ namespace vkBasalt
         std::vector<std::shared_ptr<ReshadeUniform>> uniforms;
         for (auto& uniform : module.uniforms)
         {
-            auto source = std::find_if(uniform.annotations.begin(), uniform.annotations.end(), [](const auto& a) {
+            auto ann = std::find_if(uniform.annotations.begin(), uniform.annotations.end(), [](const auto& a) {
                               return a.name == "source";
-                          })->value.string_data;
+                          });
+            if (ann == uniform.annotations.end())
+            {
+                continue;
+            }
+
+            auto source = ann->value.string_data;
             if (source == "frametime")
             {
                 uniforms.push_back(std::shared_ptr<ReshadeUniform>(new FrameTimeUniform(uniform)));
-- 
2.41.0

Here's the RTGI patch:

From 08dfa8e0fc58249d14030de950569e217f393415 Mon Sep 17 00:00:00 2001
Date: Sat, 8 Jul 2023 21:24:46 -0400
Subject: [PATCH] Fix for vkbasalt

---
 Shaders/qUINT_rtgi.fx | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/Shaders/qUINT_rtgi.fx b/Shaders/qUINT_rtgi.fx
index 98cd774..2cf6984 100644
--- a/Shaders/qUINT_rtgi.fx
+++ b/Shaders/qUINT_rtgi.fx
@@ -308,7 +308,7 @@ uniform float4 tempF5 <
 =============================================================================*/
 
 #if __RENDERER__ >= 0xb000
- #define CS_YAY
+ /*#define CS_YAY*/
 #endif
 
 uniform uint  FRAMECOUNT  < source = "framecount"; >;
@@ -388,13 +388,13 @@ struct VSOUT
     float2 uv   : TEXCOORD0;
 };
 
-#include "qUINT\Global.fxh"
-#include "qUINT\Depth.fxh"
-#include "qUINT\Projection.fxh"
-#include "qUINT\Normal.fxh"
-#include "qUINT\Random.fxh"
-#include "qUINT\RayTracing.fxh"
-#include "qUINT\Denoise.fxh"
+#include "qUINT/Global.fxh"
+#include "qUINT/Depth.fxh"
+#include "qUINT/Projection.fxh"
+#include "qUINT/Normal.fxh"
+#include "qUINT/Random.fxh"
+#include "qUINT/RayTracing.fxh"
+#include "qUINT/Denoise.fxh"
 
 /*=============================================================================
 	Functions
@@ -550,7 +550,7 @@ float3 get_jitter(uint2 texelpos, uint framecount)
     tile.y = frame / 8u;
 
     uint2 texturepos = tile * 128u + texel_in_tile;
-    float3 jitter = tex2Dfetch(sJitterTexHi, texturepos).xyz;
+    float3 jitter = tex2Dfetch(sJitterTexHi, int4(texturepos.x, texturepos.y, 0, 0)).xyz;
     return jitter;
 }
 
@@ -883,7 +883,7 @@ void PS_RTGI_reinterleave(in VSOUT i, out float4 o : SV_Target0)
         case 2: if((block_id.x % 2 + (block_id.y % 2) * 2) != (FRAMECOUNT % 4)) discard; break; 
     }
 
-    o = tex2Dfetch(sGITexFilter1, write_pos);
+    o = tex2Dfetch(sGITexFilter1, int4(write_pos.x, write_pos.y, 0, 0));
 }
 #endif
 
-- 
2.41.0

Not sure if those last two edited lines are correct since I don't know much about shaders.

However, there are some visual artifacts, so it doesn't seem to work.

That's with depthCapture = on: 2023-07-08_21:26:47

This is with depthCapture = off: 2023-07-08_21:50:21

Is this expected to give this result?

antoyo avatar Jul 09 '23 02:07 antoyo

I needed to make a patch to both vkBasalt and the RTGI stuff to even get it to load.

Here's the vkBasalt patch:

From 9426d1bd4cd0e98c682c04a6a623c885f99207ea Mon Sep 17 00:00:00 2001
Date: Sat, 8 Jul 2023 21:24:21 -0400
Subject: [PATCH] Fix for RTGI

---
 src/reshade_uniforms.cpp | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/reshade_uniforms.cpp b/src/reshade_uniforms.cpp
index b66670d..6d640a3 100644
--- a/src/reshade_uniforms.cpp
+++ b/src/reshade_uniforms.cpp
@@ -15,9 +15,15 @@ namespace vkBasalt
     {
         for (auto& uniform : module.uniforms)
         {
-            auto source = std::find_if(uniform.annotations.begin(), uniform.annotations.end(), [](const auto& a) {
+            auto ann = std::find_if(uniform.annotations.begin(), uniform.annotations.end(), [](const auto& a) {
                               return a.name == "source";
-                          })->value.string_data;
+                          });
+            if (ann == uniform.annotations.end())
+            {
+                continue;
+            }
+
+            auto source = ann->value.string_data;
             Logger::debug(source);
             Logger::debug("size: " + std::to_string(uniform.size));
             Logger::debug("offset: " + std::to_string(uniform.offset));
@@ -29,9 +35,15 @@ namespace vkBasalt
         std::vector<std::shared_ptr<ReshadeUniform>> uniforms;
         for (auto& uniform : module.uniforms)
         {
-            auto source = std::find_if(uniform.annotations.begin(), uniform.annotations.end(), [](const auto& a) {
+            auto ann = std::find_if(uniform.annotations.begin(), uniform.annotations.end(), [](const auto& a) {
                               return a.name == "source";
-                          })->value.string_data;
+                          });
+            if (ann == uniform.annotations.end())
+            {
+                continue;
+            }
+
+            auto source = ann->value.string_data;
             if (source == "frametime")
             {
                 uniforms.push_back(std::shared_ptr<ReshadeUniform>(new FrameTimeUniform(uniform)));
-- 
2.41.0

Here's the RTGI patch:

From 08dfa8e0fc58249d14030de950569e217f393415 Mon Sep 17 00:00:00 2001
Date: Sat, 8 Jul 2023 21:24:46 -0400
Subject: [PATCH] Fix for vkbasalt

---
 Shaders/qUINT_rtgi.fx | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/Shaders/qUINT_rtgi.fx b/Shaders/qUINT_rtgi.fx
index 98cd774..2cf6984 100644
--- a/Shaders/qUINT_rtgi.fx
+++ b/Shaders/qUINT_rtgi.fx
@@ -308,7 +308,7 @@ uniform float4 tempF5 <
 =============================================================================*/
 
 #if __RENDERER__ >= 0xb000
- #define CS_YAY
+ /*#define CS_YAY*/
 #endif
 
 uniform uint  FRAMECOUNT  < source = "framecount"; >;
@@ -388,13 +388,13 @@ struct VSOUT
     float2 uv   : TEXCOORD0;
 };
 
-#include "qUINT\Global.fxh"
-#include "qUINT\Depth.fxh"
-#include "qUINT\Projection.fxh"
-#include "qUINT\Normal.fxh"
-#include "qUINT\Random.fxh"
-#include "qUINT\RayTracing.fxh"
-#include "qUINT\Denoise.fxh"
+#include "qUINT/Global.fxh"
+#include "qUINT/Depth.fxh"
+#include "qUINT/Projection.fxh"
+#include "qUINT/Normal.fxh"
+#include "qUINT/Random.fxh"
+#include "qUINT/RayTracing.fxh"
+#include "qUINT/Denoise.fxh"
 
 /*=============================================================================
 	Functions
@@ -550,7 +550,7 @@ float3 get_jitter(uint2 texelpos, uint framecount)
     tile.y = frame / 8u;
 
     uint2 texturepos = tile * 128u + texel_in_tile;
-    float3 jitter = tex2Dfetch(sJitterTexHi, texturepos).xyz;
+    float3 jitter = tex2Dfetch(sJitterTexHi, int4(texturepos.x, texturepos.y, 0, 0)).xyz;
     return jitter;
 }
 
@@ -883,7 +883,7 @@ void PS_RTGI_reinterleave(in VSOUT i, out float4 o : SV_Target0)
         case 2: if((block_id.x % 2 + (block_id.y % 2) * 2) != (FRAMECOUNT % 4)) discard; break; 
     }
 
-    o = tex2Dfetch(sGITexFilter1, write_pos);
+    o = tex2Dfetch(sGITexFilter1, int4(write_pos.x, write_pos.y, 0, 0));
 }
 #endif
 
-- 
2.41.0

Not sure if those last two edited lines are correct since I don't know much about shaders.

However, there are some visual artifacts, so it doesn't seem to work.

That's with depthCapture = on: 2023-07-08_21:26:47

This is with depthCapture = off: 2023-07-08_21:50:21

Is this expected to give this result?

how did u patch it?

Beatboundsoul avatar Dec 19 '23 22:12 Beatboundsoul

I cloned this repo and applied the patch "Fix for RTGI" using git am and applied the second patch for the RTGI shader code the same way.

antoyo avatar Dec 19 '23 23:12 antoyo

@antoyo Do you have access to the latest RTGI? When running via the command-line, I get the following errors after applying your patch to vkBasalt and fixing the #includes in the RTGI shader (the rest of the patch was too different):

vkBasalt err:   /home/smol/reshade/reshade-shaders/Shaders/./MartysMods/mmx_sampling.fxh(68, 9): error X3004: undeclared identifier or no matching intrinsic overload for 'tex2Dfetch'
vkBasalt err:   /home/smol/reshade/reshade-shaders/Shaders/./MartysMods/mmx_sampling.fxh(74, 1): error X3000: syntax error: unexpected 'float4', expected '}'
vkBasalt err:   /home/smol/reshade/reshade-shaders/Shaders/./MartysMods/mmx_sampling.fxh(76, 8): error X3004: undeclared identifier or no matching intrinsic overload for 'sample_volume_trilinear'
vkBasalt err:   /home/smol/reshade/reshade-shaders/Shaders/./MartysMods/mmx_sampling.fxh(170, 1): error X3000: syntax error: unexpected '}'
vkBasalt err:   /home/smol/reshade/reshade-shaders/Shaders/MartysMods_RTGI.fx(257, 1): error X3000: syntax error: unexpected 'identifier'
vkBasalt err:   /home/smol/reshade/reshade-shaders/Shaders/MartysMods_RTGI.fx(257, 9): error X3000: syntax error: unexpected 'identifier'
vkBasalt err:   /home/smol/reshade/reshade-shaders/Shaders/MartysMods_RTGI.fx(257, 21): error X3000: syntax error: unexpected '{'
vkBasalt err:   /home/smol/reshade/reshade-shaders/Shaders/MartysMods_RTGI.fx(257, 23): error X3000: syntax error: unexpected 'identifier'

KyunLFA avatar May 28 '24 23:05 KyunLFA

I do not know: I haven't touched this in a while and gave up.

antoyo avatar May 28 '24 23:05 antoyo