Implements bloom post-process effect. More...
#include <Bloom.hpp>
Classes | |
struct | CreateInfo |
Create info. More... | |
struct | RenderAttributes |
Render attributes. More... | |
Public Member Functions | |
Bloom (IRenderDevice *pDevice, const CreateInfo &CI) | |
Creates a new instance of the Bloom class. | |
void | PrepareResources (IRenderDevice *pDevice, IDeviceContext *pDeviceContext, PostFXContext *pPostFXContext, FEATURE_FLAGS FeatureFlags) |
Prepares the bloom effect for rendering. | |
void | Execute (const RenderAttributes &RenderAttribs) |
Executes the bloom effect. | |
ITextureView * | GetBloomTextureSRV () const |
Returns the shader resource view of the bloom texture. | |
Static Public Member Functions | |
static bool | UpdateUI (HLSL::BloomAttribs &Attribs, FEATURE_FLAGS &FeatureFlags) |
Adds the ImGui controls to the UI. | |
Implements bloom post-process effect.
Displays have a low dynamic range (LDR), limiting brightness levels to a scale from black to full brightness (RGB 0 to 1), unlike the unlimited brightness in real life. High dynamic range (HDR) technology allows for brightness levels above 1, though actual displays still limit these to their maximum LDR brightness. HDR scenes are adapted for LDR displays through tonemapping and auto-exposure, which adjust the image's brightness and contrast.
Bloom is an effect that simulates intense brightness by causing bright pixels to bleed into adjacent ones.
The following table enumerates all external inputs required by Bloom effect.
Name | Format | Notes |
---|---|---|
Color buffer | APPLICATION SPECIFIED (3x FLOAT) | The HDR render target of the current frame containing the scene radiance |
The effect uses a number of parameters that control the quality and performance and are organized into the HLSL::ScreenSpaceAmbientOcclusionAttribs
structure. The following table lists the parameters and their descriptions.
Name | Notes |
---|---|
Intensity | Intensity of the bloom effect. |
Threshold | The minimum brightness required for a pixel to contribute to the bloom effect. |
SoftTreshold | The softness of the threshold. A higher value will result in a softer threshold. |
Radius | The size of the bloom effect. A larger radius will result in a larger area of the image being affected by the bloom effect. |
To integrate Bloom into your project, include the following header files:
Now, create the necessary objects:
Next, call the methods to prepare resources for the PostFXContext
and Bloom
objects. This needs to be done every frame before starting the rendering process.
Next, call the PostFXContext::Execute
method prepare intermediate resources required by all post-processing objects dependent on PostFXContext
. This method can take a constant buffer containing the current and previous-frame cameras (refer to these code examples: [0] and [1]). Alternatively, you can pass the corresponding pointers const HLSL::CameraAttribs* pCurrCamera
and const HLSL::CameraAttribs* pPrevCamera
for the current and previous cameras, respectively. You also need to pass the depth of the current and previous frames, and a buffer with motion vectors in NDC space, via the corresponding ITextureView* pCurrDepthBufferSRV
, ITextureView* pPrevDepthBufferSRV
, and ITextureView* pMotionVectorsSRV
pointers.
To calculate bloom effect, call the Bloom::Execute
method. Before this, fill the BloomAttribs
and Bloom::RenderAttributes
structures with the necessary data. Refer to the Input resources section for parameter description.
To obtain an ITextureView
of the texture containing the bloom result, use the Bloom::GetBloomTextureSRV
method.
Our implementation is based on the technique described in [Léna Piquet, 2021]. We modified it by adding a threshold and using the Additive Bloom as described in [Alexander Christensen, 2022]. Additionally, we changed the weighting to eliminate fireflies from this article (section Bonus material 2: Karis average) as follows: