Browse Source

Minor changes in indirect diffuse denoising

Panagiotis Christopoulos Charitos 3 years ago
parent
commit
c26327784e

+ 1 - 3
AnKi/Renderer/IndirectDiffuse.cpp

@@ -220,7 +220,6 @@ void IndirectDiffuse::populateRenderGraph(RenderingContext& ctx)
 		TextureSubresourceInfo hizSubresource;
 		TextureSubresourceInfo hizSubresource;
 		hizSubresource.m_mipmapCount = 1;
 		hizSubresource.m_mipmapCount = 1;
 		prpass->newDependency(RenderPassDependency(m_r->getDepthDownscale().getHiZRt(), readUsage, hizSubresource));
 		prpass->newDependency(RenderPassDependency(m_r->getDepthDownscale().getHiZRt(), readUsage, hizSubresource));
-		prpass->newDependency(RenderPassDependency(m_r->getGBuffer().getColorRt(2), readUsage));
 		prpass->newDependency(RenderPassDependency(m_runCtx.m_mainRtHandles[!readIdx], writeUsage));
 		prpass->newDependency(RenderPassDependency(m_runCtx.m_mainRtHandles[!readIdx], writeUsage));
 
 
 		prpass->setWork([this, &ctx, dir, readIdx](RenderPassWorkContext& rgraphCtx) {
 		prpass->setWork([this, &ctx, dir, readIdx](RenderPassWorkContext& rgraphCtx) {
@@ -232,11 +231,10 @@ void IndirectDiffuse::populateRenderGraph(RenderingContext& ctx)
 			TextureSubresourceInfo hizSubresource;
 			TextureSubresourceInfo hizSubresource;
 			hizSubresource.m_mipmapCount = 1;
 			hizSubresource.m_mipmapCount = 1;
 			rgraphCtx.bindTexture(0, 2, m_r->getDepthDownscale().getHiZRt(), hizSubresource);
 			rgraphCtx.bindTexture(0, 2, m_r->getDepthDownscale().getHiZRt(), hizSubresource);
-			rgraphCtx.bindColorTexture(0, 3, m_r->getGBuffer().getColorRt(2));
 
 
 			if(getConfig().getRPreferCompute())
 			if(getConfig().getRPreferCompute())
 			{
 			{
-				rgraphCtx.bindImage(0, 4, m_runCtx.m_mainRtHandles[!readIdx]);
+				rgraphCtx.bindImage(0, 3, m_runCtx.m_mainRtHandles[!readIdx]);
 			}
 			}
 
 
 			IndirectDiffuseDenoiseUniforms unis;
 			IndirectDiffuseDenoiseUniforms unis;

+ 3 - 9
AnKi/Shaders/IndirectDiffuseDenoise.glsl

@@ -13,13 +13,12 @@
 layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;
 layout(set = 0, binding = 0) uniform sampler u_linearAnyClampSampler;
 layout(set = 0, binding = 1) uniform ANKI_RP texture2D u_toDenoiseTex;
 layout(set = 0, binding = 1) uniform ANKI_RP texture2D u_toDenoiseTex;
 layout(set = 0, binding = 2) uniform texture2D u_depthTex;
 layout(set = 0, binding = 2) uniform texture2D u_depthTex;
-layout(set = 0, binding = 3) uniform ANKI_RP texture2D u_gbuffer2Tex;
 
 
 #if defined(ANKI_COMPUTE_SHADER)
 #if defined(ANKI_COMPUTE_SHADER)
 const UVec2 WORKGROUP_SIZE = UVec2(8u, 8u);
 const UVec2 WORKGROUP_SIZE = UVec2(8u, 8u);
 layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y) in;
 layout(local_size_x = WORKGROUP_SIZE.x, local_size_y = WORKGROUP_SIZE.y) in;
 
 
-layout(set = 0, binding = 4) writeonly uniform ANKI_RP image2D u_outImg;
+layout(set = 0, binding = 3) writeonly uniform ANKI_RP image2D u_outImg;
 #else
 #else
 layout(location = 0) in Vec2 in_uv;
 layout(location = 0) in Vec2 in_uv;
 layout(location = 0) out Vec3 out_color;
 layout(location = 0) out Vec3 out_color;
@@ -63,8 +62,6 @@ void main()
 	}
 	}
 
 
 	const Vec3 positionCenter = unproject(UV_TO_NDC(uv), depthCenter);
 	const Vec3 positionCenter = unproject(UV_TO_NDC(uv), depthCenter);
-	const ANKI_RP Vec3 normalCenter =
-		unpackNormalFromGBuffer(textureLod(u_gbuffer2Tex, u_linearAnyClampSampler, uv, 0.0));
 
 
 	// Sample
 	// Sample
 	ANKI_RP F32 weight = EPSILON_RP;
 	ANKI_RP F32 weight = EPSILON_RP;
@@ -80,12 +77,9 @@ void main()
 #endif
 #endif
 
 
 		const F32 depthTap = textureLod(u_depthTex, u_linearAnyClampSampler, sampleUv, 0.0).r;
 		const F32 depthTap = textureLod(u_depthTex, u_linearAnyClampSampler, sampleUv, 0.0).r;
-		const Vec3 positionTap = unproject(UV_TO_NDC(sampleUv), depthTap);
-		const Vec3 normalTap =
-			unpackNormalFromGBuffer(textureLod(u_gbuffer2Tex, u_linearAnyClampSampler, sampleUv, 0.0));
 
 
-		ANKI_RP F32 w = calculateBilateralWeightPlane(positionCenter, normalCenter, positionTap, normalTap, 1.0);
-		// w *= gaussianWeight(0.4, abs(F32(i)) / (sampleCount + 1.0));
+		ANKI_RP F32 w = calculateBilateralWeightDepth(depthCenter, depthTap, 1.0);
+		// w *= gaussianWeight(0.4, abs(F32(i)) / (u_unis.m_sampleCountDiv2 * 2.0 + 1.0));
 		weight += w;
 		weight += w;
 
 
 		color += textureLod(u_toDenoiseTex, u_linearAnyClampSampler, sampleUv, 0.0).xyz * w;
 		color += textureLod(u_toDenoiseTex, u_linearAnyClampSampler, sampleUv, 0.0).xyz * w;

+ 1 - 1
Samples/Common/SampleApp.cpp

@@ -67,7 +67,7 @@ Error SampleApp::userMainLoop(Bool& quit, Second elapsedTime)
 	if(in.getKey(KeyCode::Y) == 1)
 	if(in.getKey(KeyCode::Y) == 1)
 	{
 	{
 		renderer.setCurrentDebugRenderTarget(
 		renderer.setCurrentDebugRenderTarget(
-			(renderer.getCurrentDebugRenderTarget() == "GBuffer_albedo") ? "" : "GBuffer_albedo");
+			(renderer.getCurrentDebugRenderTarget() == "GBuffer_normals") ? "" : "GBuffer_normals");
 	}
 	}
 
 
 	if(in.getKey(KeyCode::U) == 1)
 	if(in.getKey(KeyCode::U) == 1)