Skip to content

Commit dac32c6

Browse files
Updated documentation for post-effects
1 parent 9ec3dbb commit dac32c6

File tree

9 files changed

+241
-77
lines changed

9 files changed

+241
-77
lines changed

PostProcess/Bloom/interface/Bloom.hpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Diligent Graphics LLC
2+
* Copyright 2024-2025 Diligent Graphics LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,9 @@
2525
*/
2626
#pragma once
2727

28+
/// \file
29+
/// Defines Diligent::Bloom class implementing bloom post-process effect.
30+
2831
#include <unordered_map>
2932
#include <vector>
3033
#include <memory>
@@ -47,6 +50,10 @@ namespace HLSL
4750
struct BloomAttribs;
4851
}
4952

53+
54+
/// Implements [bloom post-process effect](https://github.com/DiligentGraphics/DiligentFX/tree/master/PostProcess/Bloom).
55+
56+
/// \include{doc} DiligentFX/PostProcess/Bloom/README.md
5057
class Bloom
5158
{
5259
public:
@@ -55,6 +62,7 @@ class Bloom
5562
FEATURE_FLAG_NONE = 0u
5663
};
5764

65+
/// Render attributes.
5866
struct RenderAttributes
5967
{
6068
/// Render device that may be used to create new objects needed for this frame, if any.
@@ -76,22 +84,33 @@ class Bloom
7684
const HLSL::BloomAttribs* pBloomAttribs = nullptr;
7785
};
7886

87+
/// Create info.
7988
struct CreateInfo
8089
{
90+
/// Whether to enable asynchronous shader and pipeline state creation.
91+
92+
/// If enabled, the shaders and pipeline state objects will be created using
93+
/// the engine's asynchronous creation mechanism. While shaders are being
94+
/// compiled, the effect will do nothing and return a black texture.
8195
bool EnableAsyncCreation = false;
8296
};
8397

8498
public:
99+
/// Creates a new instance of the Bloom class.
85100
Bloom(IRenderDevice* pDevice, const CreateInfo& CI);
86101

87102
~Bloom();
88103

104+
/// Prepares the bloom effect for rendering.
89105
void PrepareResources(IRenderDevice* pDevice, IDeviceContext* pDeviceContext, PostFXContext* pPostFXContext, FEATURE_FLAGS FeatureFlags);
90106

107+
/// Executes the bloom effect.
91108
void Execute(const RenderAttributes& RenderAttribs);
92109

110+
/// Adds the ImGui controls to the UI.
93111
static bool UpdateUI(HLSL::BloomAttribs& Attribs, FEATURE_FLAGS& FeatureFlags);
94112

113+
/// Returns the shader resource view of the bloom texture.
95114
ITextureView* GetBloomTextureSRV() const;
96115

97116
private:

PostProcess/DepthOfField/interface/DepthOfField.hpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Diligent Graphics LLC
2+
* Copyright 2024-2025 Diligent Graphics LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,9 @@
2525
*/
2626
#pragma once
2727

28+
/// \file
29+
/// Defines Diligent::DepthOfField class implementing depth-of-field post-process effect.
30+
2831
#include <unordered_map>
2932
#include <memory>
3033

@@ -46,16 +49,25 @@ namespace HLSL
4649
struct DepthOfFieldAttribs;
4750
}
4851

52+
/// Implements [depth-of-field post-process effect](https://github.com/DiligentGraphics/DiligentFX/tree/master/PostProcess/DepthOfField).
53+
54+
/// \include{doc} DiligentFX/PostProcess/DepthOfField/README.md
4955
class DepthOfField
5056
{
5157
public:
58+
/// Feature flags that control the behavior of the effect.
5259
enum FEATURE_FLAGS : Uint32
5360
{
54-
FEATURE_FLAG_NONE = 0u,
61+
/// No feature flags are set.
62+
FEATURE_FLAG_NONE = 0u,
63+
64+
/// Enable temporal smoothing.
5565
FEATURE_FLAG_ENABLE_TEMPORAL_SMOOTHING = 1u << 0u,
56-
FEATURE_FLAG_ENABLE_KARIS_INVERSE = 1u << 1u
66+
67+
FEATURE_FLAG_ENABLE_KARIS_INVERSE = 1u << 1u
5768
};
5869

70+
/// Render attributes.
5971
struct RenderAttributes
6072
{
6173
/// Render device that may be used to create new objects needed for this frame, if any.
@@ -80,22 +92,33 @@ class DepthOfField
8092
const HLSL::DepthOfFieldAttribs* pDOFAttribs = nullptr;
8193
};
8294

95+
/// Create info.
8396
struct CreateInfo
8497
{
98+
/// Whether to enable asynchronous shader and pipeline state creation.
99+
100+
/// If enabled, the shaders and pipeline state objects will be created using
101+
/// the engine's asynchronous creation mechanism. While shaders are being
102+
/// compiled, the effect will do nothing and return the input color.
85103
bool EnableAsyncCreation = false;
86104
};
87105

88106
public:
107+
/// Creates a new instance of the DepthOfField class.
89108
DepthOfField(IRenderDevice* pDevice, const CreateInfo& CI);
90109

91110
~DepthOfField();
92111

112+
/// Prepares resources for the effect.
93113
void PrepareResources(IRenderDevice* pDevice, IDeviceContext* pDeviceContext, PostFXContext* pPostFXContext, FEATURE_FLAGS FeatureFlags);
94114

115+
/// Executes the effect.
95116
void Execute(const RenderAttributes& RenderAttribs);
96117

118+
/// Adds the ImGui controls to the UI.
97119
static bool UpdateUI(HLSL::DepthOfFieldAttribs& Attribs, FEATURE_FLAGS& FeatureFlags);
98120

121+
/// Returns the shader resource view of the depth-of-field texture.
99122
ITextureView* GetDepthOfFieldTextureSRV() const;
100123

101124
private:

PostProcess/EpipolarLightScattering/README.md

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,63 +14,63 @@ that start at the light source and interpolating the radiance between these samp
1414
`EpipolarLightScatteringAttribs` structure
1515
The following parameters control the effect
1616

17-
* uiNumEpipolarSlices - the total number of epipolar slices (lines). For high quality effect,
18-
set this value to (Screen Width + Screen Height)/2
19-
* uiMaxSamplesInSlice - Maximum number of samples on a single epipolar line.
20-
When epipolar light is short, the actual number of samples
21-
may be lower. For high quality effect, set this value to max(Screen Width, Screen Height)/2.
22-
* uiInitialSampleStepInSlice - Initial ray marching sample spacing on an epipolar line.
23-
Additional samples are added at discontinuities.
24-
* uiEpipoleSamplingDensityFactor - Sample density scale near the epipole where inscattering changes rapidly.
25-
Note that sampling near the epipole is very cheap since only a few steps
26-
required to perform ray marching.
27-
* fRefinementThreshold - Sampling refinement threshold that controls detection of discontinuities. Smaller values
28-
produce more samples and higher quality, but at a higher performance cost.
29-
* bShowSampling - Whether to show epipolar sampling.
30-
* bCorrectScatteringAtDepthBreaks - Whether to correct inscattering at depth discontinuities. Improves quality
31-
for additional cost. It may be preferable to increase the number of slices
32-
and or maximum number of samples on an epipolar line instead.
33-
* bShowDepthBreaks - Whether to display pixels which are classified as depth discontinuities and which
34-
will be corrected. Only has effect when bCorrectScatteringAtDepthBreaks is TRUE.
35-
* bShowLightingOnly - Whether to show lighting only
36-
* bOptimizeSampleLocations - Optimize sample locations to avoid oversampling. This should generally be TRUE.
37-
* bEnableLightShafts - Whether to enable light shafts or render unshadowed inscattering.
38-
Setting this to FALSE increases performance, but reduces visual quality.
39-
* uiInstrIntegralSteps - Number of inscattering integral steps taken when computing unshadowed inscattering
40-
Default value is OK and should not be changed.
41-
* f2ShadowMapTexelSize - Size of the shadowmap texel (1/width, 1/height)
42-
* uiMaxSamplesOnTheRay - Maximum number of ray marching samples on a single ray. Typically this value should match the maximum
43-
shadow map cascade resolution. Using lower value will improve performance but may result
44-
in moire patterns. Note that in most cases significantly less samples are actually taken.
45-
* uiMinMaxShadowMapResolution - Defines the number of samples at the lowest level of min-max binary tree
46-
and should match the maximum cascade shadow map resolution.
47-
* iNumCascades - Number of shadow map cascades
48-
* iFirstCascadeToRayMarch - First cascade to use for ray marching. Usually first few cascades are small, and ray
49-
marching them is inefficient.
50-
* fMaxShadowMapStep - Cap on the maximum shadow map step in texels.
51-
* bUse1DMinMaxTree - Whether to use 1D min/max binary tree optimization. This improves
52-
performance for higher shadow map resolution. Test it.
53-
* bIs32BitMinMaxMipMap - Whether to use 32-bit float or 16-bit UNORM min-max binary tree. Usually 16-bit UNORM is OK.
54-
* uiLightSctrTechnique - Light scattering evaluation technique. The following two methods are available: epipolar and brute-force.
55-
Brute force light scattering performs expensive ray marching for every screen pixel. This method
56-
can be used as the quality reference.
57-
* uiCascadeProcessingMode - Shadow map cascades processing mode.
58-
* uiRefinementCriterion - Epipolar sampling refinement criterion. The two options are depth difference and scattering difference.
59-
Scattering difference is generally preferable way.
60-
* uiSingleScatteringMode - Single scattering evaluation mode. The following three methods are available:
17+
* `uiNumEpipolarSlices` - the total number of epipolar slices (lines). For high quality effect,
18+
set this value to (Screen Width + Screen Height)/2
19+
* `uiMaxSamplesInSlice` - Maximum number of samples on a single epipolar line.
20+
When epipolar light is short, the actual number of samples
21+
may be lower. For high quality effect, set this value to max(Screen Width, Screen Height)/2.
22+
* `uiInitialSampleStepInSlice` - Initial ray marching sample spacing on an epipolar line.
23+
Additional samples are added at discontinuities.
24+
* `uiEpipoleSamplingDensityFactor` - Sample density scale near the epipole where inscattering changes rapidly.
25+
Note that sampling near the epipole is very cheap since only a few steps
26+
required to perform ray marching.
27+
* `fRefinementThreshold` - Sampling refinement threshold that controls detection of discontinuities. Smaller values
28+
produce more samples and higher quality, but at a higher performance cost.
29+
* `bShowSampling` - Whether to show epipolar sampling.
30+
* `bCorrectScatteringAtDepthBreaks` - Whether to correct inscattering at depth discontinuities. Improves quality
31+
for additional cost. It may be preferable to increase the number of slices
32+
and or maximum number of samples on an epipolar line instead.
33+
* `bShowDepthBreaks` - Whether to display pixels which are classified as depth discontinuities and which
34+
will be corrected. Only has effect when bCorrectScatteringAtDepthBreaks is TRUE.
35+
* `bShowLightingOnly` - Whether to show lighting only
36+
* `bOptimizeSampleLocations` - Optimize sample locations to avoid oversampling. This should generally be TRUE.
37+
* `bEnableLightShafts` - Whether to enable light shafts or render unshadowed inscattering.
38+
Setting this to FALSE increases performance, but reduces visual quality.
39+
* `uiInstrIntegralSteps` - Number of inscattering integral steps taken when computing unshadowed inscattering
40+
Default value is OK and should not be changed.
41+
* `f2ShadowMapTexelSize` - Size of the shadowmap texel (1/width, 1/height)
42+
* `uiMaxSamplesOnTheRay` - Maximum number of ray marching samples on a single ray. Typically this value should match the maximum
43+
shadow map cascade resolution. Using lower value will improve performance but may result
44+
in moire patterns. Note that in most cases significantly less samples are actually taken.
45+
* `uiMinMaxShadowMapResolution` - Defines the number of samples at the lowest level of min-max binary tree
46+
and should match the maximum cascade shadow map resolution.
47+
* `iNumCascades` - Number of shadow map cascades
48+
* `iFirstCascadeToRayMarch` - First cascade to use for ray marching. Usually first few cascades are small, and ray
49+
marching them is inefficient.
50+
* `fMaxShadowMapStep` - Cap on the maximum shadow map step in texels.
51+
* `bUse1DMinMaxTree` - Whether to use 1D min/max binary tree optimization. This improves
52+
performance for higher shadow map resolution. Test it.
53+
* `bIs32BitMinMaxMipMap` - Whether to use 32-bit float or 16-bit UNORM min-max binary tree. Usually 16-bit UNORM is OK.
54+
* `uiLightSctrTechnique` - Light scattering evaluation technique. The following two methods are available: epipolar and brute-force.
55+
Brute force light scattering performs expensive ray marching for every screen pixel. This method
56+
can be used as the quality reference.
57+
* `uiCascadeProcessingMode` - Shadow map cascades processing mode.
58+
* `uiRefinementCriterion` - Epipolar sampling refinement criterion. The two options are depth difference and scattering difference.
59+
Scattering difference is generally preferable way.
60+
* `uiSingleScatteringMode` - Single scattering evaluation mode. The following three methods are available:
6161
* None - no single scattering.
6262
* Integration (default) - evaluate single scattering with numerical integration.
6363
* Look-up table - use precomputed single-scattering look-up table.
64-
* uiMultipleScatteringMode - Higher-order scattering evaluation mode. The following three options are available:
64+
* `uiMultipleScatteringMode` - Higher-order scattering evaluation mode. The following three options are available:
6565
* None - no multiple scattering.
6666
* Unoccluded (default) - evaluate multiple scattering without shadowing.
6767
* Occluded - evaluate multiple scattering taking shadowing into account similar to single scattering.
68-
* uiExtinctionEvalMode - Atmospheric extinction evaluation mode.
69-
* bUseCustomSctrCoeffs - Whether to use custom scattering coefficients.
70-
* fAerosolDensityScale - Aerosol density scale to use for scattering coefficient computation.
71-
* fAerosolAbsorbtionScale - Aerosol absorption scale to use for scattering coefficient computation.
72-
* f4CustomRlghBeta - Custom Rayleigh coefficients.
73-
* f4CustomMieBeta - Custom Mie coefficients.
68+
* `uiExtinctionEvalMode` - Atmospheric extinction evaluation mode.
69+
* `bUseCustomSctrCoeffs` - Whether to use custom scattering coefficients.
70+
* `fAerosolDensityScale` - Aerosol density scale to use for scattering coefficient computation.
71+
* `fAerosolAbsorbtionScale` - Aerosol absorption scale to use for scattering coefficient computation.
72+
* `f4CustomRlghBeta` - Custom Rayleigh coefficients.
73+
* `f4CustomMieBeta` - Custom Mie coefficients.
7474

7575
## Integration
7676

PostProcess/EpipolarLightScattering/interface/EpipolarLightScattering.hpp

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2024 Diligent Graphics LLC
2+
* Copyright 2019-2025 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,6 +26,9 @@
2626
*/
2727
#pragma once
2828

29+
/// \file
30+
/// Defines Diligent::EpipolarLightScattering class implementing epipolar light scattering post-process effect.
31+
2932
#include "../../../../DiligentCore/Graphics/GraphicsEngine/interface/RenderDevice.h"
3033
#include "../../../../DiligentCore/Graphics/GraphicsEngine/interface/DeviceContext.h"
3134
#include "../../../../DiligentCore/Graphics/GraphicsEngine/interface/Buffer.h"
@@ -45,10 +48,13 @@ using uint = uint32_t;
4548
#include "Shaders/PostProcess/ToneMapping/public/ToneMappingStructures.fxh"
4649
#include "Shaders/PostProcess/EpipolarLightScattering/public/EpipolarLightScatteringStructures.fxh"
4750

51+
/// Implements the [epipolar light scattering post-process effect](https://github.com/DiligentGraphics/DiligentFX/tree/master/PostProcess/EpipolarLightScattering).
4852

53+
/// \include{doc} DiligentFX/PostProcess/EpipolarLightScattering/README.md
4954
class EpipolarLightScattering
5055
{
5156
public:
57+
/// Frame attributes that are passed to the effect at the beginning of each frame.
5258
struct FrameAttribs
5359
{
5460
/// Render device that may be used to create new objects needed for this frame, if any.
@@ -60,13 +66,19 @@ class EpipolarLightScattering
6066
/// Device context that will record the rendering commands.
6167
IDeviceContext* pDeviceContext = nullptr;
6268

69+
/// The time elapsed since the last frame.
6370
double dElapsedTime = 0;
6471

65-
const LightAttribs* pLightAttribs = nullptr;
72+
/// A pointer to the light attributes CPU data.
73+
const LightAttribs* pLightAttribs = nullptr;
74+
75+
/// A pointer to the camera attributes CPU data.
6676
const CameraAttribs* pCameraAttribs = nullptr;
67-
// If this parameter is null, the effect will use its own buffer.
77+
78+
/// If this parameter is null, the effect will use its own buffer.
6879
IBuffer* pcbLightAttribs = nullptr;
69-
// If this parameter is null, the effect will use its own buffer.
80+
81+
/// If this parameter is null, the effect will use its own buffer.
7082
IBuffer* pcbCameraAttribs = nullptr;
7183

7284
/// Shader resource view of the source color buffer.
@@ -85,19 +97,37 @@ class EpipolarLightScattering
8597
ITextureView* ptex2DShadowMapSRV = nullptr;
8698
};
8799

100+
/// Create info.
88101
struct CreateInfo
89102
{
90-
IRenderDevice* pDevice = nullptr;
91-
IRenderStateCache* pStateCache = nullptr;
92-
IDeviceContext* pContext = nullptr;
93-
TEXTURE_FORMAT BackBufferFmt = TEX_FORMAT_RGBA8_UNORM_SRGB;
94-
TEXTURE_FORMAT DepthBufferFmt = TEX_FORMAT_D32_FLOAT;
95-
TEXTURE_FORMAT OffscreenBackBuffer = TEX_FORMAT_R11G11B10_FLOAT;
96-
bool PackMatrixRowMajor = false;
97-
AirScatteringAttribs ScatteringAttibs = {};
103+
/// A pointer to the render device that will be used to create the effect.
104+
IRenderDevice* pDevice = nullptr;
105+
106+
/// An optional render state cache to optimize state loading.
107+
IRenderStateCache* pStateCache = nullptr;
108+
109+
/// The render device context that will be used to record the rendering commands.
110+
IDeviceContext* pContext = nullptr;
111+
112+
/// Back buffer format.
113+
TEXTURE_FORMAT BackBufferFmt = TEX_FORMAT_RGBA8_UNORM_SRGB;
114+
115+
/// Depth buffer format.
116+
TEXTURE_FORMAT DepthBufferFmt = TEX_FORMAT_D32_FLOAT;
117+
118+
/// Offscreen back buffer format.
119+
TEXTURE_FORMAT OffscreenBackBuffer = TEX_FORMAT_R11G11B10_FLOAT;
120+
121+
/// Whether to use row-major packing for the matrix data.
122+
bool PackMatrixRowMajor = false;
123+
124+
/// Air scattering attributes.
125+
AirScatteringAttribs ScatteringAttibs = {};
98126
};
99127

128+
/// Creates a new instance of the EpipolarLightScattering class.
100129
EpipolarLightScattering(const CreateInfo& CI);
130+
101131
~EpipolarLightScattering();
102132

103133

@@ -109,20 +139,28 @@ class EpipolarLightScattering
109139
void PrepareForNewFrame(FrameAttribs& FrameAttribs,
110140
EpipolarLightScatteringAttribs& PPAttribs);
111141

142+
/// Computes the sun color and ambient light color based on the given direction on the sun and extraterrestrial sun color.
112143
void ComputeSunColor(const float3& vDirectionOnSun,
113144
const float4& f4ExtraterrestrialSunColor,
114145
float4& f4SunColorAtGround,
115146
float4& f4AmbientLight);
116147

148+
/// Renders the sun.
117149
void RenderSun(TEXTURE_FORMAT RTVFormat,
118150
TEXTURE_FORMAT DSVFormat,
119151
Uint8 SampleCount);
120152

153+
/// Runs the post-processing effect.
121154
void PerformPostProcessing();
122155

123156

124-
IBuffer* GetMediaAttribsCB() { return m_pcbMediaAttribs; }
157+
/// Returns the media attributes buffer.
158+
IBuffer* GetMediaAttribsCB() { return m_pcbMediaAttribs; }
159+
160+
/// Returns the precomputed net density look-up texture.
125161
ITextureView* GetPrecomputedNetDensitySRV() { return m_ptex2DOccludedNetDensityToAtmTopSRV; }
162+
163+
/// Returns the ambient sky light texture.
126164
ITextureView* GetAmbientSkyLightSRV(IRenderDevice* pDevice, IRenderStateCache* pStateCache, IDeviceContext* pContext);
127165

128166
private:

0 commit comments

Comments
 (0)