Browse Source

Improve SSR a bit

Panagiotis Christopoulos Charitos 7 years ago
parent
commit
479cbf2a71

+ 6 - 2
programs/Reflections.ankiprog

@@ -264,7 +264,7 @@ void main()
 		vec4 sslr = doSslr(reflVec, viewNormal, viewPos, uv, depth, gbuffer.roughness);
 		vec4 sslr = doSslr(reflVec, viewNormal, viewPos, uv, depth, gbuffer.roughness);
 		sslrFactor = sslr.w;
 		sslrFactor = sslr.w;
 		sslrCol = sslr.xyz;
 		sslrCol = sslr.xyz;
-		sslrCol = clamp(sslrCol, 0.0, FLT_MAX); // XXX
+		sslrCol = clamp(sslrCol, 0.0, FLT_MAX); // Fix the value just in case
 	}
 	}
 
 
 	// Read probes
 	// Read probes
@@ -304,7 +304,11 @@ void main()
 	
 	
 	// Done!
 	// Done!
 	imageStore(out_reflAndIndirect, ivec2(realInvocationId), vec4(outColor, 0.0));
 	imageStore(out_reflAndIndirect, ivec2(realInvocationId), vec4(outColor, 0.0));
-	imageStore(out_reflAndIndirect, ivec2(realInvocationId.x + 1, realInvocationId.y), vec4(outColor, 0.0));
+
+	// Store the same color in the next pixel as well
+	bool xIsOdd = (realInvocationId.x & 1u) == 0u;
+	realInvocationId.x = (xIsOdd) ? (realInvocationId.x + 1u) : (realInvocationId.x - 1u);
+	imageStore(out_reflAndIndirect, ivec2(realInvocationId), vec4(outColor, 0.0));
 }
 }
 			]]></source>
 			]]></source>
 		</shader>
 		</shader>

+ 4 - 7
src/anki/renderer/Reflections.cpp

@@ -37,15 +37,12 @@ Error Reflections::initInternal(const ConfigSet& cfg)
 	ANKI_R_LOGI("Initializing reflection pass (%ux%u)", width, height);
 	ANKI_R_LOGI("Initializing reflection pass (%ux%u)", width, height);
 
 
 	// Create RTs
 	// Create RTs
-	TextureInitInfo texinit = m_r->create2DRenderTargetInitInfo(width,
+	m_rtDescr = m_r->create2DRenderTargetDescription(width,
 		height,
 		height,
 		LIGHT_SHADING_COLOR_ATTACHMENT_PIXEL_FORMAT,
 		LIGHT_SHADING_COLOR_ATTACHMENT_PIXEL_FORMAT,
-		TextureUsageBit::SAMPLED_FRAGMENT | TextureUsageBit::IMAGE_COMPUTE_WRITE
-			| TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE,
+		TextureUsageBit::SAMPLED_FRAGMENT | TextureUsageBit::IMAGE_COMPUTE_WRITE,
 		"IndirectRes");
 		"IndirectRes");
-	texinit.m_initialUsage = TextureUsageBit::SAMPLED_FRAGMENT;
-
-	m_indirectTex = m_r->createAndClearRenderTarget(texinit);
+	m_rtDescr.bake();
 
 
 	// Create shader
 	// Create shader
 	ANKI_CHECK(getResourceManager().loadResource("programs/Reflections.ankiprog", m_prog));
 	ANKI_CHECK(getResourceManager().loadResource("programs/Reflections.ankiprog", m_prog));
@@ -81,7 +78,7 @@ void Reflections::populateRenderGraph(RenderingContext& ctx)
 	m_runCtx.m_ctx = &ctx;
 	m_runCtx.m_ctx = &ctx;
 
 
 	// Create RTs
 	// Create RTs
-	m_runCtx.m_indirectRt = rgraph.importRenderTarget("IndirectRes", m_indirectTex, TextureUsageBit::SAMPLED_FRAGMENT);
+	m_runCtx.m_indirectRt = rgraph.newRenderTarget(m_rtDescr);
 
 
 	// Create pass
 	// Create pass
 	ComputeRenderPassDescription& rpass = rgraph.newComputeRenderPass("IndirectRes");
 	ComputeRenderPassDescription& rpass = rgraph.newComputeRenderPass("IndirectRes");

+ 1 - 1
src/anki/renderer/Reflections.h

@@ -38,7 +38,7 @@ private:
 	ShaderProgramResourcePtr m_prog;
 	ShaderProgramResourcePtr m_prog;
 	Array<ShaderProgramPtr, 2> m_grProg;
 	Array<ShaderProgramPtr, 2> m_grProg;
 
 
-	TexturePtr m_indirectTex;
+	RenderTargetDescription m_rtDescr;
 
 
 	Array<U8, 2> m_workgroupSize = {{16, 16}};
 	Array<U8, 2> m_workgroupSize = {{16, 16}};
 
 

+ 0 - 1
src/anki/renderer/Renderer.cpp

@@ -343,7 +343,6 @@ TextureInitInfo Renderer::create2DRenderTargetInitInfo(
 RenderTargetDescription Renderer::create2DRenderTargetDescription(
 RenderTargetDescription Renderer::create2DRenderTargetDescription(
 	U32 w, U32 h, const PixelFormat& format, TextureUsageBit usage, CString name)
 	U32 w, U32 h, const PixelFormat& format, TextureUsageBit usage, CString name)
 {
 {
-	ANKI_ASSERT(!!(usage & TextureUsageBit::FRAMEBUFFER_ATTACHMENT_WRITE));
 	RenderTargetDescription init(name);
 	RenderTargetDescription init(name);
 
 
 	init.m_width = w;
 	init.m_width = w;