瀏覽代碼

Increased the quality of Bloom

Panagiotis Christopoulos Charitos 9 年之前
父節點
當前提交
623352932b

+ 22 - 28
include/anki/renderer/Bloom.h

@@ -35,52 +35,46 @@ anki_internal:
 	ANKI_USE_RESULT Error init(const ConfigSet& initializer);
 	void run(RenderingContext& ctx);
 
-	TexturePtr& getRt()
+	TexturePtr& getMaxExposureRt()
 	{
-		return m_vblurRt;
+		return m_extractExposure.m_rt;
 	}
 
-	TexturePtr& getRt1()
+	TexturePtr& getFinalRt()
 	{
-		return m_hblurRt;
+		return m_upscale.m_rt;
 	}
 
-	U32 getWidth() const
+	U getMaxExposureRtWidth() const
 	{
-		return m_width;
+		return m_extractExposure.m_width;
 	}
 
-	U32 getHeight() const
+	U getMaxExposureRtHeight() const
 	{
-		return m_height;
+		return m_extractExposure.m_height;
 	}
 
 private:
-	U32 m_width, m_height;
-	F32 m_threshold = 10.0; ///< How bright it is
-	F32 m_scale = 1.0;
-	F32 m_blurringDist = 1.0; ///< Distance in blurring
-
-	FramebufferPtr m_hblurFb;
-	FramebufferPtr m_vblurFb;
+	class SubPass
+	{
+	public:
+		U32 m_width, m_height;
 
-	ShaderResourcePtr m_quadVert;
-	ShaderResourcePtr m_toneFrag;
-	ShaderResourcePtr m_hblurFrag;
-	ShaderResourcePtr m_vblurFrag;
+		TexturePtr m_rt;
+		FramebufferPtr m_fb;
 
-	PipelinePtr m_tonePpline;
-	PipelinePtr m_hblurPpline;
-	PipelinePtr m_vblurPpline;
+		ShaderResourcePtr m_frag;
+		PipelinePtr m_ppline;
+		ResourceGroupPtr m_rsrc;
+	};
 
-	TexturePtr m_hblurRt; ///< pass0Fai with the horizontal blur FAI
-	TexturePtr m_vblurRt; ///< The final FAI
+	F32 m_threshold = 10.0; ///< How bright it is
+	F32 m_scale = 1.0;
 
-	ResourceGroupPtr m_firstDescrGroup;
-	ResourceGroupPtr m_hDescrGroup;
-	ResourceGroupPtr m_vDescrGroup;
+	SubPass m_extractExposure;
+	SubPass m_upscale;
 
-	ANKI_USE_RESULT Error initFb(FramebufferPtr& fb, TexturePtr& rt);
 	ANKI_USE_RESULT Error initInternal(const ConfigSet& initializer);
 };
 

+ 2 - 21
include/anki/renderer/Common.h

@@ -48,22 +48,6 @@ const U SSAO_FRACTION = 4;
 /// Bloom size is rendererSize/BLOOM_FRACTION.
 const U BLOOM_FRACTION = 4;
 
-/// IS mimap count is: log2(BLOOM_FRACTION)+2 extra mips for bloom+1
-const U IS_MIPMAP_COUNT = __builtin_popcount(BLOOM_FRACTION - 1) + 1 + 2;
-
-/// Get the number of mips for IS's render target.
-inline U getIsMipmapCount(U width, U height)
-{
-	U count = computeMaxMipmapCount2d(width, height, 512);
-	ANKI_ASSERT(count > 1);
-	return count;
-}
-
-inline U getMsDepthRtMipmapCount()
-{
-	return log2(SSAO_FRACTION) + 1;
-}
-
 /// Computes the 'a' and 'b' numbers for linearizeDepthOptimal
 inline void computeLinearizeDepthOptimal(F32 near, F32 far, F32& a, F32& b)
 {
@@ -73,11 +57,8 @@ inline void computeLinearizeDepthOptimal(F32 near, F32 far, F32& a, F32& b)
 
 const U MS_COLOR_ATTACHMENT_COUNT = 3;
 
-const Array<PixelFormat, MS_COLOR_ATTACHMENT_COUNT>
-	MS_COLOR_ATTACHMENT_PIXEL_FORMATS = {
-		{PixelFormat(ComponentFormat::R8G8B8A8, TransformFormat::UNORM),
-			PixelFormat(ComponentFormat::R8G8B8A8, TransformFormat::UNORM),
-			PixelFormat(ComponentFormat::R8G8B8A8, TransformFormat::UNORM)}};
+extern const Array<PixelFormat, MS_COLOR_ATTACHMENT_COUNT>
+	MS_COLOR_ATTACHMENT_PIXEL_FORMATS;
 
 const PixelFormat MS_DEPTH_ATTACHMENT_PIXEL_FORMAT(
 	ComponentFormat::D24, TransformFormat::UNORM);

+ 3 - 1
include/anki/renderer/DownscaleBlur.h

@@ -22,6 +22,8 @@ anki_internal:
 	{
 	}
 
+	~DownscaleBlur();
+
 	ANKI_USE_RESULT Error init(const ConfigSet& initializer);
 
 	void run(RenderingContext& ctx);
@@ -37,7 +39,7 @@ private:
 		FramebufferPtr m_fb;
 	};
 
-	Array<Subpass, IS_MIPMAP_COUNT - 1> m_passes;
+	DynamicArray<Subpass> m_passes;
 
 	Error initSubpass(U idx, const UVec2& inputTexSize);
 };

+ 7 - 0
include/anki/renderer/Is.h

@@ -43,6 +43,12 @@ anki_internal:
 		cmdb->generateMipmaps(m_rt, 0, 0, 0);
 	}
 
+	/// Get the number of mips for IS's render target.
+	U getRtMipmapCount() const
+	{
+		return m_rtMipCount;
+	}
+
 private:
 	static const U COMMON_VARS_LOCATION = 0;
 	static const U P_LIGHTS_LOCATION = 1;
@@ -53,6 +59,7 @@ private:
 
 	/// The IS render target
 	TexturePtr m_rt;
+	U8 m_rtMipCount = 0;
 
 	/// The IS FBO
 	FramebufferPtr m_fb;

+ 5 - 0
include/anki/renderer/Ms.h

@@ -69,6 +69,11 @@ anki_internal:
 		return m_fb;
 	}
 
+	static U getDepthRtMipmapCount()
+	{
+		return log2(SSAO_FRACTION) + 1;
+	}
+
 private:
 	FramebufferPtr m_fb;
 

+ 15 - 24
shaders/Bloom.frag.glsl

@@ -6,10 +6,6 @@
 #include "shaders/Common.glsl"
 #include "shaders/Tonemapping.glsl"
 
-#if MIPMAP - 2 < 0
-#error See file
-#endif
-
 // Vars
 layout(ANKI_TEX_BINDING(0, 0)) uniform lowp sampler2D u_tex; ///< Its the IS RT
 
@@ -26,29 +22,24 @@ layout(ANKI_SS_BINDING(0, 0), std140) readonly buffer ss0_
 layout(location = 0) in vec2 in_texCoord;
 layout(location = 0) out vec3 out_color;
 
-vec3 readTexture(in uint mipmap)
-{
-	uint w = ANKI_RENDERER_WIDTH / (2 << (mipmap - 1));
-	uint h = ANKI_RENDERER_HEIGHT / (2 << (mipmap - 1));
-
-	vec2 textureSize = vec2(w, h);
-	vec2 scale = (textureSize - 1.0) / textureSize;
-	vec2 offset = 1.0 / (2.0 * textureSize);
-
-	vec2 texc = in_texCoord * scale + offset;
-
-	return textureLod(u_tex, texc, float(mipmap)).rgb;
-}
-
 void main()
 {
-	out_color = readTexture(MIPMAP);
-#if 0
-	out_color += readTexture(MIPMAP - 1);
-	out_color += readTexture(MIPMAP - 2);
+	const vec2 TEXEL_SIZE = 1.0 / vec2(WIDTH, HEIGHT);
+
+	out_color = textureLod(u_tex, in_texCoord, MIPMAP).rgb;
+	out_color += textureLod(u_tex, in_texCoord + TEXEL_SIZE, MIPMAP).rgb;
+	out_color += textureLod(u_tex, in_texCoord - TEXEL_SIZE, MIPMAP).rgb;
+	out_color +=
+		textureLod(
+			u_tex, in_texCoord + vec2(TEXEL_SIZE.x, -TEXEL_SIZE.y), MIPMAP)
+			.rgb;
+	out_color +=
+		textureLod(
+			u_tex, in_texCoord + vec2(-TEXEL_SIZE.x, TEXEL_SIZE.y), MIPMAP)
+			.rgb;
+
+	out_color /= 5.0;
 
-	out_color /= 3.0;
-#endif
 	out_color =
 		tonemap(out_color, u_averageLuminancePad3.x, u_thresholdScalePad2.x)
 		* u_thresholdScalePad2.y;

+ 31 - 0
shaders/BloomUpscale.frag.glsl

@@ -0,0 +1,31 @@
+// Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos and contributors.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#include "shaders/Common.glsl"
+
+layout(ANKI_TEX_BINDING(0, 0)) uniform mediump sampler2D u_tex;
+
+layout(location = 0) in vec2 in_texCoord;
+layout(location = 0) out vec3 out_color;
+
+void main()
+{
+	const vec2 TEXEL_SIZE = 1.0 / vec2(WIDTH, HEIGHT);
+	const float MIPMAP = 0.0;
+
+	out_color = textureLod(u_tex, in_texCoord, MIPMAP).rgb;
+	out_color += textureLod(u_tex, in_texCoord + TEXEL_SIZE, MIPMAP).rgb;
+	out_color += textureLod(u_tex, in_texCoord - TEXEL_SIZE, MIPMAP).rgb;
+	out_color +=
+		textureLod(
+			u_tex, in_texCoord + vec2(TEXEL_SIZE.x, -TEXEL_SIZE.y), MIPMAP)
+			.rgb;
+	out_color +=
+		textureLod(
+			u_tex, in_texCoord + vec2(-TEXEL_SIZE.x, TEXEL_SIZE.y), MIPMAP)
+			.rgb;
+
+	out_color /= 5.0;
+}

+ 24 - 0
shaders/DownscaleBlur.frag.glsl

@@ -13,6 +13,7 @@ layout(location = 0) out vec3 out_color;
 void main()
 {
 	const vec2 TEXEL_SIZE = 1.0 / TEXTURE_SIZE;
+	const vec2 TEXEL_SIZE2 = 2.0 * TEXEL_SIZE;
 
 	out_color = textureLod(u_tex, in_uv, TEXTURE_MIPMAP).rgb;
 	out_color += textureLod(u_tex, in_uv + TEXEL_SIZE, TEXTURE_MIPMAP).rgb;
@@ -26,5 +27,28 @@ void main()
 			u_tex, in_uv + vec2(-TEXEL_SIZE.x, TEXEL_SIZE.y), TEXTURE_MIPMAP)
 			.rgb;
 
+#if 0
+	out_color +=
+		textureLod(
+			u_tex, in_uv + TEXEL_SIZE2, TEXTURE_MIPMAP)
+			.rgb;
+
+	out_color +=
+		textureLod(
+			u_tex, in_uv - TEXEL_SIZE2, TEXTURE_MIPMAP)
+			.rgb;
+
+	out_color +=
+		textureLod(
+			u_tex, in_uv + vec2(-TEXEL_SIZE2.x, TEXEL_SIZE2.y), TEXTURE_MIPMAP)
+			.rgb;
+
+	out_color +=
+		textureLod(
+			u_tex, in_uv + vec2(TEXEL_SIZE2.x, -TEXEL_SIZE2.y), TEXTURE_MIPMAP)
+			.rgb;
+
+	out_color /= 9.0;
+#endif
 	out_color /= 5.0;
 }

+ 83 - 107
src/renderer/Bloom.cpp

@@ -23,94 +23,85 @@ Bloom::~Bloom()
 }
 
 //==============================================================================
-Error Bloom::initFb(FramebufferPtr& fb, TexturePtr& rt)
+Error Bloom::initInternal(const ConfigSet& config)
 {
-	// Set to bilinear because the blurring techniques take advantage of that
-	m_r->createRenderTarget(
-		m_width, m_height, RT_PIXEL_FORMAT, 1, SamplingFilter::LINEAR, 1, rt);
+	GrManager& gr = getGrManager();
 
-	// Create FB
-	FramebufferInitInfo fbInit;
-	fbInit.m_colorAttachmentCount = 1;
-	fbInit.m_colorAttachments[0].m_texture = rt;
-	fbInit.m_colorAttachments[0].m_loadOperation =
-		AttachmentLoadOperation::DONT_CARE;
-	fb = getGrManager().newInstance<Framebuffer>(fbInit);
+	m_upscale.m_width = m_r->getWidth() / BLOOM_FRACTION;
+	m_upscale.m_height = m_r->getHeight() / BLOOM_FRACTION;
 
-	return ErrorCode::NONE;
-}
-
-//==============================================================================
-Error Bloom::initInternal(const ConfigSet& config)
-{
-	m_width = m_r->getWidth() / BLOOM_FRACTION;
-	m_height = m_r->getHeight() / BLOOM_FRACTION;
+	m_extractExposure.m_width =
+		m_r->getWidth() >> (m_r->getIs().getRtMipmapCount() - 2);
+	m_extractExposure.m_height =
+		m_r->getHeight() >> (m_r->getIs().getRtMipmapCount() - 2);
 
 	m_threshold = config.getNumber("bloom.threshold");
 	m_scale = config.getNumber("bloom.scale");
-	m_blurringDist = config.getNumber("bloom.blurringDist");
-
-	ANKI_CHECK(initFb(m_hblurFb, m_hblurRt));
-	ANKI_CHECK(initFb(m_vblurFb, m_vblurRt));
 
-	// init shaders & pplines
-	GrManager& gr = getGrManager();
+	// Create RTs
+	m_r->createRenderTarget(m_extractExposure.m_width,
+		m_extractExposure.m_height,
+		RT_PIXEL_FORMAT,
+		1,
+		SamplingFilter::LINEAR,
+		1,
+		m_extractExposure.m_rt);
+
+	m_r->createRenderTarget(m_upscale.m_width,
+		m_upscale.m_height,
+		RT_PIXEL_FORMAT,
+		1,
+		SamplingFilter::LINEAR,
+		1,
+		m_upscale.m_rt);
+
+	// Create FBs
+	FramebufferInitInfo fbInit;
+	fbInit.m_colorAttachmentCount = 1;
+	fbInit.m_colorAttachments[0].m_texture = m_extractExposure.m_rt;
+	fbInit.m_colorAttachments[0].m_loadOperation =
+		AttachmentLoadOperation::DONT_CARE;
+	m_extractExposure.m_fb = gr.newInstance<Framebuffer>(fbInit);
 
-	PipelineInitInfo ppinit;
-	ppinit.m_color.m_attachmentCount = 1;
-	ppinit.m_color.m_attachments[0].m_format = RT_PIXEL_FORMAT;
-	ppinit.m_depthStencil.m_depthWriteEnabled = false;
-	ppinit.m_depthStencil.m_depthCompareFunction = CompareOperation::ALWAYS;
+	fbInit.m_colorAttachments[0].m_texture = m_upscale.m_rt;
+	m_upscale.m_fb = gr.newInstance<Framebuffer>(fbInit);
 
+	// init shaders
 	StringAuto pps(getAllocator());
-	pps.sprintf("#define ANKI_RENDERER_WIDTH %u\n"
-				"#define ANKI_RENDERER_HEIGHT %u\n"
-				"#define MIPMAP %u\n",
-		m_r->getWidth(),
-		m_r->getHeight(),
-		IS_MIPMAP_COUNT - 1);
-
-	ANKI_CHECK(getResourceManager().loadResourceToCache(
-		m_quadVert, "shaders/Quad.vert.glsl", pps.toCString(), "r_"));
-
-	ppinit.m_shaders[ShaderType::VERTEX] = m_quadVert->getGrShader();
-
-	ANKI_CHECK(getResourceManager().loadResourceToCache(
-		m_toneFrag, "shaders/Bloom.frag.glsl", pps.toCString(), "r_"));
-
-	ppinit.m_shaders[ShaderType::FRAGMENT] = m_toneFrag->getGrShader();
-
-	m_tonePpline = gr.newInstance<Pipeline>(ppinit);
-
-	const char* SHADER_FILENAME = "shaders/GaussianBlurGeneric.frag.glsl";
+	pps.sprintf("#define WIDTH %u\n"
+				"#define HEIGHT %u\n"
+				"#define MIPMAP %u.0\n",
+		m_r->getWidth() >> (m_r->getIs().getRtMipmapCount() - 1),
+		m_r->getHeight() >> (m_r->getIs().getRtMipmapCount() - 1),
+		m_r->getIs().getRtMipmapCount() - 1);
+
+	ANKI_CHECK(
+		getResourceManager().loadResourceToCache(m_extractExposure.m_frag,
+			"shaders/Bloom.frag.glsl",
+			pps.toCString(),
+			"r_"));
 
 	pps.destroy();
-	pps.sprintf("#define HPASS\n"
-				"#define COL_RGB\n"
-				"#define TEXTURE_SIZE vec2(%f, %f)\n"
-				"#define KERNEL_SIZE 19\n",
-		F32(m_width),
-		F32(m_height));
-
-	ANKI_CHECK(getResourceManager().loadResourceToCache(
-		m_hblurFrag, SHADER_FILENAME, pps.toCString(), "r_"));
-
-	ppinit.m_shaders[ShaderType::FRAGMENT] = m_hblurFrag->getGrShader();
-	m_hblurPpline = gr.newInstance<Pipeline>(ppinit);
-
-	pps.destroy();
-	pps.sprintf("#define VPASS\n"
-				"#define COL_RGB\n"
-				"#define TEXTURE_SIZE vec2(%f, %f)\n"
-				"#define KERNEL_SIZE 15\n",
-		F32(m_width),
-		F32(m_height));
-
-	ANKI_CHECK(getResourceManager().loadResourceToCache(
-		m_vblurFrag, SHADER_FILENAME, pps.toCString(), "r_"));
-
-	ppinit.m_shaders[ShaderType::FRAGMENT] = m_vblurFrag->getGrShader();
-	m_vblurPpline = gr.newInstance<Pipeline>(ppinit);
+	pps.sprintf("#define WIDTH %u\n"
+				"#define HEIGHT %u\n",
+		m_extractExposure.m_width,
+		m_extractExposure.m_height);
+
+	ANKI_CHECK(getResourceManager().loadResourceToCache(m_upscale.m_frag,
+		"shaders/BloomUpscale.frag.glsl",
+		pps.toCString(),
+		"r_"));
+
+	// Init pplines
+	ColorStateInfo colorInf;
+	colorInf.m_attachmentCount = 1;
+	colorInf.m_attachments[0].m_format = RT_PIXEL_FORMAT;
+
+	m_r->createDrawQuadPipeline(m_extractExposure.m_frag->getGrShader(),
+		colorInf,
+		m_extractExposure.m_ppline);
+	m_r->createDrawQuadPipeline(
+		m_upscale.m_frag->getGrShader(), colorInf, m_upscale.m_ppline);
 
 	// Set descriptors
 	{
@@ -121,22 +112,15 @@ Error Bloom::initInternal(const ConfigSet& config)
 		descInit.m_storageBuffers[0].m_buffer =
 			m_r->getTm().getAverageLuminanceBuffer();
 
-		m_firstDescrGroup = gr.newInstance<ResourceGroup>(descInit);
-	}
-
-	{
-		ResourceGroupInitInfo descInit;
-		descInit.m_textures[0].m_texture = m_vblurRt;
-		m_hDescrGroup = gr.newInstance<ResourceGroup>(descInit);
+		m_extractExposure.m_rsrc = gr.newInstance<ResourceGroup>(descInit);
 	}
 
 	{
 		ResourceGroupInitInfo descInit;
-		descInit.m_textures[0].m_texture = m_hblurRt;
-		m_vDescrGroup = gr.newInstance<ResourceGroup>(descInit);
+		descInit.m_textures[0].m_texture = m_extractExposure.m_rt;
+		m_upscale.m_rsrc = gr.newInstance<ResourceGroup>(descInit);
 	}
 
-	getGrManager().finish();
 	return ErrorCode::NONE;
 }
 
@@ -158,9 +142,10 @@ void Bloom::run(RenderingContext& ctx)
 	CommandBufferPtr& cmdb = ctx.m_commandBuffer;
 
 	// pass 0
-	cmdb->beginRenderPass(m_vblurFb);
-	cmdb->setViewport(0, 0, m_width, m_height);
-	cmdb->bindPipeline(m_tonePpline);
+	cmdb->beginRenderPass(m_extractExposure.m_fb);
+	cmdb->setViewport(
+		0, 0, m_extractExposure.m_width, m_extractExposure.m_height);
+	cmdb->bindPipeline(m_extractExposure.m_ppline);
 
 	TransientMemoryInfo dyn;
 	Vec4* uniforms = static_cast<Vec4*>(
@@ -169,30 +154,21 @@ void Bloom::run(RenderingContext& ctx)
 			dyn.m_uniformBuffers[0]));
 	*uniforms = Vec4(m_threshold, m_scale, 0.0, 0.0);
 
-	cmdb->bindResourceGroup(m_firstDescrGroup, 0, &dyn);
+	cmdb->bindResourceGroup(m_extractExposure.m_rsrc, 0, &dyn);
 
 	m_r->drawQuad(cmdb);
 	cmdb->endRenderPass();
 
-	// Blurring passes
+	// pass 1
+	cmdb->setViewport(0, 0, m_upscale.m_width, m_upscale.m_height);
+	cmdb->beginRenderPass(m_upscale.m_fb);
+	cmdb->bindPipeline(m_upscale.m_ppline);
+	cmdb->bindResourceGroup(m_upscale.m_rsrc, 0, nullptr);
+	m_r->drawQuad(cmdb);
+
+	if(!m_r->getSslfEnabled())
 	{
-		// hpass
-		cmdb->beginRenderPass(m_hblurFb);
-		cmdb->bindResourceGroup(m_hDescrGroup, 0, nullptr);
-		cmdb->bindPipeline(m_hblurPpline);
-		m_r->drawQuad(cmdb);
 		cmdb->endRenderPass();
-
-		// vpass
-		cmdb->beginRenderPass(m_vblurFb);
-		cmdb->bindResourceGroup(m_vDescrGroup, 0, nullptr);
-		cmdb->bindPipeline(m_vblurPpline);
-		m_r->drawQuad(cmdb);
-
-		if(!m_r->getSslfEnabled())
-		{
-			cmdb->endRenderPass();
-		}
 	}
 }
 

+ 18 - 0
src/renderer/Common.cpp

@@ -0,0 +1,18 @@
+// Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos and contributors.
+// All rights reserved.
+// Code licensed under the BSD License.
+// http://www.anki3d.org/LICENSE
+
+#include <anki/renderer/Common.h>
+
+namespace anki
+{
+
+//==============================================================================
+const Array<PixelFormat, MS_COLOR_ATTACHMENT_COUNT>
+	MS_COLOR_ATTACHMENT_PIXEL_FORMATS = {
+		{PixelFormat(ComponentFormat::R8G8B8A8, TransformFormat::UNORM),
+			PixelFormat(ComponentFormat::R8G8B8A8, TransformFormat::UNORM),
+			PixelFormat(ComponentFormat::R8G8B8A8, TransformFormat::UNORM)}};
+
+} // end namespace anki

+ 8 - 0
src/renderer/DownscaleBlur.cpp

@@ -10,6 +10,12 @@
 namespace anki
 {
 
+//==============================================================================
+DownscaleBlur::~DownscaleBlur()
+{
+	m_passes.destroy(getAllocator());
+}
+
 //==============================================================================
 Error DownscaleBlur::initSubpass(U idx, const UVec2& inputTexSize)
 {
@@ -65,6 +71,8 @@ Error DownscaleBlur::initSubpass(U idx, const UVec2& inputTexSize)
 //==============================================================================
 Error DownscaleBlur::init(const ConfigSet& initializer)
 {
+	m_passes.create(getAllocator(), m_r->getIs().getRtMipmapCount() - 1);
+
 	UVec2 size(m_r->getWidth(), m_r->getHeight());
 	for(U i = 0; i < m_passes.getSize(); ++i)
 	{

+ 5 - 1
src/renderer/Is.cpp

@@ -74,6 +74,10 @@ Error Is::initInternal(const ConfigSet& config)
 		return ErrorCode::USER_DATA;
 	}
 
+	m_rtMipCount =
+		computeMaxMipmapCount2d(m_r->getWidth(), m_r->getHeight(), 32);
+	ANKI_ASSERT(m_rtMipCount);
+
 	U clusterCount = m_r->getTileCountXY().x() * m_r->getTileCountXY().y()
 		* config.getNumber("clusterSizeZ");
 	m_maxLightIds *= clusterCount;
@@ -136,7 +140,7 @@ Error Is::initInternal(const ConfigSet& config)
 		IS_COLOR_ATTACHMENT_PIXEL_FORMAT,
 		1,
 		SamplingFilter::LINEAR,
-		IS_MIPMAP_COUNT,
+		m_rtMipCount,
 		m_rt);
 
 	FramebufferInitInfo fbInit;

+ 2 - 2
src/renderer/Ms.cpp

@@ -38,7 +38,7 @@ Error Ms::createRt(U32 samples)
 		DEPTH_RT_PIXEL_FORMAT,
 		samples,
 		SamplingFilter::NEAREST,
-		getMsDepthRtMipmapCount(),
+		getDepthRtMipmapCount(),
 		m_depthRt);
 
 	m_r->createRenderTarget(m_r->getWidth(),
@@ -62,7 +62,7 @@ Error Ms::createRt(U32 samples)
 		RT_PIXEL_FORMATS[2],
 		samples,
 		SamplingFilter::NEAREST,
-		getMsDepthRtMipmapCount(),
+		getDepthRtMipmapCount(),
 		m_rt2);
 
 	AttachmentLoadOperation loadop = AttachmentLoadOperation::DONT_CARE;

+ 1 - 1
src/renderer/Pps.cpp

@@ -86,7 +86,7 @@ Error Pps::initInternal(const ConfigSet& config)
 
 	if(m_r->getBloomEnabled())
 	{
-		rcInit.m_textures[1].m_texture = m_r->getBloom().getRt();
+		rcInit.m_textures[1].m_texture = m_r->getBloom().getFinalRt();
 	}
 
 	rcInit.m_textures[2].m_texture = m_lut->getGrTexture();

+ 1 - 1
src/renderer/Renderer.cpp

@@ -296,7 +296,7 @@ Error Renderer::render(RenderingContext& ctx)
 	cmdb->generateMipmaps(m_ms->getDepthRt(), 0, 0, 0);
 	cmdb->generateMipmaps(m_ms->getRt2(), 0, 0, 0);
 
-	for(U i = 0; i < getMsDepthRtMipmapCount(); ++i)
+	for(U i = 0; i < m_ms->getDepthRtMipmapCount(); ++i)
 	{
 		cmdb->setTextureBarrier(m_ms->getDepthRt(),
 			TextureUsageBit::GENERATE_MIPMAPS,

+ 3 - 3
src/renderer/Sslf.cpp

@@ -30,8 +30,8 @@ Error Sslf::initInternal(const ConfigSet& config)
 	StringAuto pps(getAllocator());
 
 	pps.sprintf("#define TEX_DIMENSIONS vec2(%u.0, %u.0)\n",
-		m_r->getBloom().getWidth(),
-		m_r->getBloom().getHeight());
+		m_r->getBloom().getMaxExposureRtWidth(),
+		m_r->getBloom().getMaxExposureRtHeight());
 
 	ANKI_CHECK(getResourceManager().loadResourceToCache(
 		m_frag, "shaders/Sslf.frag.glsl", pps.toCString(), "r_"));
@@ -49,7 +49,7 @@ Error Sslf::initInternal(const ConfigSet& config)
 
 	// Create the resource group
 	ResourceGroupInitInfo rcInit;
-	rcInit.m_textures[0].m_texture = m_r->getBloom().getRt1();
+	rcInit.m_textures[0].m_texture = m_r->getBloom().getMaxExposureRt();
 	rcInit.m_textures[1].m_texture = m_lensDirtTex->getGrTexture();
 
 	m_rcGroup = getGrManager().newInstance<ResourceGroup>(rcInit);

+ 2 - 2
src/renderer/Tm.cpp

@@ -16,11 +16,11 @@ Error Tm::create(const ConfigSet& initializer)
 	// Create shader
 	StringAuto pps(getAllocator());
 
-	ANKI_ASSERT(IS_MIPMAP_COUNT > 1);
+	ANKI_ASSERT(m_r->getIs().getRtMipmapCount() > 1);
 	pps.sprintf("#define IS_RT_MIPMAP %u\n"
 				"#define ANKI_RENDERER_WIDTH %u\n"
 				"#define ANKI_RENDERER_HEIGHT %u\n",
-		IS_MIPMAP_COUNT - 1,
+		m_r->getIs().getRtMipmapCount() - 1,
 		m_r->getWidth(),
 		m_r->getHeight());