Browse Source

Integrate SSGI to LightShading

Panagiotis Christopoulos Charitos 5 years ago
parent
commit
20e5089ba8
3 changed files with 8 additions and 2 deletions
  1. 3 1
      shaders/LightShading.ankiprog
  2. 2 1
      shaders/Ssgi.ankiprog
  3. 3 0
      src/anki/renderer/LightShading.cpp

+ 3 - 1
shaders/LightShading.ankiprog

@@ -51,6 +51,7 @@ layout(set = 0, binding = 15) uniform texture2D u_msRt2;
 layout(set = 0, binding = 16) uniform texture2D u_msDepthRt;
 layout(set = 0, binding = 17) uniform texture2D u_ssrRt;
 layout(set = 0, binding = 18) uniform texture2D u_ssaoRt;
+layout(set = 0, binding = 19) uniform texture2D u_ssgiRt;
 
 layout(location = 0) in Vec2 in_uv;
 layout(location = 1) in Vec2 in_clusterIJ;
@@ -280,7 +281,8 @@ void main()
 			diffIndirect /= totalBlendWeight;
 		}
 
-		out_color += diffIndirect * gbuffer.m_diffuse;
+		const Vec4 ssgi = textureLod(u_ssgiRt, u_trilinearClampSampler, in_uv, 0.0);
+		out_color += (ssgi.rgb + diffIndirect) * gbuffer.m_diffuse;
 	}
 }
 #pragma anki end

+ 2 - 1
shaders/Ssgi.ankiprog

@@ -126,6 +126,7 @@ void main()
 		// Modulate
 		const F32 NoL = max(0.0, dot(randomHemisphere, newViewNormal));
 		outColor.xyz *= NoL;
+		outColor.xyz *= PI / 2.0;
 	}
 	else
 	{
@@ -136,7 +137,7 @@ void main()
 	const Vec4 v4 = u_unis.m_prevViewProjMatMulInvViewProjMat * Vec4(ndc, depth, 1.0);
 	const Vec2 historyUv = NDC_TO_UV(v4.xy / v4.w);
 	const Vec4 history = textureLod(u_historyTex, u_trilinearClampSampler, historyUv, 0.0);
-	outColor = mix(history, outColor, 0.25);
+	outColor = mix(history, outColor, 0.15);
 
 	// Store
 	imageStore(out_img, fixedGlobalInvocationId, outColor);

+ 3 - 0
src/anki/renderer/LightShading.cpp

@@ -14,6 +14,7 @@
 #include <anki/renderer/DepthDownscale.h>
 #include <anki/renderer/Ssao.h>
 #include <anki/renderer/Ssr.h>
+#include <anki/renderer/Ssgi.h>
 #include <anki/renderer/GlobalIllumination.h>
 #include <anki/core/ConfigSet.h>
 #include <anki/util/HighRezTimer.h>
@@ -135,6 +136,7 @@ void LightShading::run(RenderPassWorkContext& rgraphCtx)
 			0, 16, m_r->getGBuffer().getDepthRt(), TextureSubresourceInfo(DepthStencilAspectBit::DEPTH));
 		rgraphCtx.bindColorTexture(0, 17, m_r->getSsr().getRt());
 		rgraphCtx.bindColorTexture(0, 18, m_r->getSsao().getRt());
+		rgraphCtx.bindColorTexture(0, 19, m_r->getSsgi().getRt());
 
 		// Draw
 		drawQuad(cmdb);
@@ -203,6 +205,7 @@ void LightShading::populateRenderGraph(RenderingContext& ctx)
 		TextureSubresourceInfo(DepthStencilAspectBit::DEPTH)});
 	pass.newDependency({m_r->getShadowMapping().getShadowmapRt(), TextureUsageBit::SAMPLED_FRAGMENT});
 	pass.newDependency({m_r->getSsao().getRt(), TextureUsageBit::SAMPLED_FRAGMENT});
+	pass.newDependency({m_r->getSsgi().getRt(), TextureUsageBit::SAMPLED_FRAGMENT});
 
 	// Refl & indirect
 	pass.newDependency({m_r->getSsr().getRt(), TextureUsageBit::SAMPLED_FRAGMENT});