Browse Source

Increase the default quality of shadows on desktop

Panagiotis Christopoulos Charitos 3 years ago
parent
commit
353f87ac93

+ 3 - 2
AnKi/Renderer/ConfigVars.defs.h

@@ -37,7 +37,8 @@ ANKI_CONFIG_VAR_U32(RIndirectDiffuseDenoiseSampleCount, 4, 1, 128, "Indirect dif
 ANKI_CONFIG_VAR_F32(RIndirectDiffuseSsaoStrength, 2.5f, 0.1f, 10.0f, "SSAO strength")
 ANKI_CONFIG_VAR_F32(RIndirectDiffuseSsaoBias, -0.1f, -10.0f, 10.0f, "SSAO bias")
 
-ANKI_CONFIG_VAR_U32(RShadowMappingTileResolution, 128, 16, 2048, "Shadowmapping tile resolution")
+ANKI_CONFIG_VAR_U32(RShadowMappingTileResolution, (ANKI_PLATFORM_MOBILE) ? 128 : 512, 16, 2048,
+					"Shadowmapping tile resolution")
 ANKI_CONFIG_VAR_U32(RShadowMappingTileCountPerRowOrColumn, 16, 1, 256,
 					"Shadowmapping atlas will have this number squared number of tiles")
 ANKI_CONFIG_VAR_U32(RShadowMappingScratchTileCountX, 4 * (MAX_SHADOW_CASCADES2 + 2), 1, 256,
@@ -64,7 +65,7 @@ ANKI_CONFIG_VAR_BOOL(RDbgEnabled, false, "Enable or not debugging")
 ANKI_CONFIG_VAR_F32(RBloomThreshold, 2.5f, 0.0f, 256.0f, "Bloom threshold")
 ANKI_CONFIG_VAR_F32(RBloomScale, 2.5f, 0.0f, 256.0f, "Bloom scale")
 
-ANKI_CONFIG_VAR_F32(RSmResolveFactor, 0.5f, 0.25f, 1.0f, "Shadowmapping resolve quality")
+ANKI_CONFIG_VAR_BOOL(RSmResolveQuarterRez, ANKI_PLATFORM_MOBILE, "Shadowmapping resolve quality")
 
 ANKI_CONFIG_VAR_BOOL(RRtShadowsSvgf, false, "Enable or not RT shadows SVGF")
 ANKI_CONFIG_VAR_U8(RRtShadowsSvgfAtrousPassCount, 3, 1, 20, "Number of atrous passes of SVGF")

+ 20 - 7
AnKi/Renderer/ShadowmapsResolve.cpp

@@ -7,6 +7,7 @@
 #include <AnKi/Renderer/Renderer.h>
 #include <AnKi/Renderer/GBuffer.h>
 #include <AnKi/Renderer/ShadowMapping.h>
+#include <AnKi/Renderer/DepthDownscale.h>
 #include <AnKi/Core/ConfigSet.h>
 
 namespace anki {
@@ -28,10 +29,9 @@ Error ShadowmapsResolve::init()
 
 Error ShadowmapsResolve::initInternal()
 {
-	U32 width = U32(getConfig().getRSmResolveFactor() * F32(m_r->getInternalResolution().x()));
-	width = min(m_r->getInternalResolution().x(), getAlignedRoundUp(4, width));
-	U32 height = U32(getConfig().getRSmResolveFactor() * F32(m_r->getInternalResolution().y()));
-	height = min(m_r->getInternalResolution().y(), getAlignedRoundUp(4, height));
+	m_quarterRez = getConfig().getRSmResolveQuarterRez();
+	const U32 width = m_r->getInternalResolution().x() / (m_quarterRez + 1);
+	const U32 height = m_r->getInternalResolution().y() / (m_quarterRez + 1);
 
 	ANKI_R_LOGV("Initializing shadowmaps resolve. Resolution %ux%u", width, height);
 
@@ -76,7 +76,9 @@ void ShadowmapsResolve::populateRenderGraph(RenderingContext& ctx)
 		});
 
 		rpass.newDependency(RenderPassDependency(m_runCtx.m_rt, TextureUsageBit::IMAGE_COMPUTE_WRITE));
-		rpass.newDependency(RenderPassDependency(m_r->getGBuffer().getDepthRt(), TextureUsageBit::SAMPLED_COMPUTE));
+		rpass.newDependency(
+			RenderPassDependency((m_quarterRez) ? m_r->getDepthDownscale().getHiZRt() : m_r->getGBuffer().getDepthRt(),
+								 TextureUsageBit::SAMPLED_COMPUTE, TextureSurfaceInfo(0, 0, 0, 0)));
 		rpass.newDependency(
 			RenderPassDependency(m_r->getShadowMapping().getShadowmapRt(), TextureUsageBit::SAMPLED_COMPUTE));
 
@@ -93,7 +95,9 @@ void ShadowmapsResolve::populateRenderGraph(RenderingContext& ctx)
 		});
 
 		rpass.newDependency(RenderPassDependency(m_runCtx.m_rt, TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE));
-		rpass.newDependency(RenderPassDependency(m_r->getGBuffer().getDepthRt(), TextureUsageBit::SAMPLED_FRAGMENT));
+		rpass.newDependency(
+			RenderPassDependency((m_quarterRez) ? m_r->getDepthDownscale().getHiZRt() : m_r->getGBuffer().getDepthRt(),
+								 TextureUsageBit::SAMPLED_FRAGMENT, TextureSurfaceInfo(0, 0, 0, 0)));
 		rpass.newDependency(
 			RenderPassDependency(m_r->getShadowMapping().getShadowmapRt(), TextureUsageBit::SAMPLED_FRAGMENT));
 
@@ -116,7 +120,16 @@ void ShadowmapsResolve::run(const RenderingContext& ctx, RenderPassWorkContext&
 	bindStorage(cmdb, 0, 4, rsrc.m_clustersToken);
 
 	cmdb->bindSampler(0, 5, m_r->getSamplers().m_trilinearClamp);
-	rgraphCtx.bindTexture(0, 6, m_r->getGBuffer().getDepthRt(), TextureSubresourceInfo(DepthStencilAspectBit::DEPTH));
+	if(m_quarterRez)
+	{
+		rgraphCtx.bindTexture(0, 6, m_r->getDepthDownscale().getHiZRt(),
+							  TextureSubresourceInfo(TextureSurfaceInfo(0, 0, 0, 0)));
+	}
+	else
+	{
+		rgraphCtx.bindTexture(0, 6, m_r->getGBuffer().getDepthRt(),
+							  TextureSubresourceInfo(DepthStencilAspectBit::DEPTH));
+	}
 
 	if(getConfig().getRPreferCompute())
 	{

+ 1 - 0
AnKi/Renderer/ShadowmapsResolve.h

@@ -47,6 +47,7 @@ public:
 	ShaderProgramPtr m_grProg;
 	RenderTargetDescription m_rtDescr;
 	FramebufferDescription m_fbDescr;
+	Bool m_quarterRez = false;
 
 	class
 	{