Implements the epipolar light scattering post-process effect. More...
#include <EpipolarLightScattering.hpp>
Classes | |
struct | CreateInfo |
Create info. More... | |
struct | FrameAttribs |
Frame attributes that are passed to the effect at the beginning of each frame. More... | |
Public Member Functions | |
EpipolarLightScattering (const CreateInfo &CI) | |
Creates a new instance of the EpipolarLightScattering class. | |
void | PrepareForNewFrame (FrameAttribs &FrameAttribs, EpipolarLightScatteringAttribs &PPAttribs) |
void | ComputeSunColor (const float3 &vDirectionOnSun, const float4 &f4ExtraterrestrialSunColor, float4 &f4SunColorAtGround, float4 &f4AmbientLight) |
Computes the sun color and ambient light color based on the given direction on the sun and extraterrestrial sun color. | |
void | RenderSun (TEXTURE_FORMAT RTVFormat, TEXTURE_FORMAT DSVFormat, Uint8 SampleCount) |
Renders the sun. | |
void | PerformPostProcessing () |
Runs the post-processing effect. | |
IBuffer * | GetMediaAttribsCB () |
Returns the media attributes buffer. | |
ITextureView * | GetPrecomputedNetDensitySRV () |
Returns the precomputed net density look-up texture. | |
ITextureView * | GetAmbientSkyLightSRV (IRenderDevice *pDevice, IRenderStateCache *pStateCache, IDeviceContext *pContext) |
Returns the ambient sky light texture. | |
Implements the epipolar light scattering post-process effect.
This post-processing effect renders realistic high-quality light scattering effects and is based on this sample from Intel. The effect works by smartly placing expensive ray-marching samples along the epipolar lines that start at the light source and interpolating the radiance between these samples.
EpipolarLightScatteringAttribs
structure The following parameters control the effect
uiNumEpipolarSlices
- the total number of epipolar slices (lines). For high quality effect, set this value to (Screen Width + Screen Height)/2uiMaxSamplesInSlice
- Maximum number of samples on a single epipolar line. When epipolar light is short, the actual number of samples may be lower. For high quality effect, set this value to max(Screen Width, Screen Height)/2.uiInitialSampleStepInSlice
- Initial ray marching sample spacing on an epipolar line. Additional samples are added at discontinuities.uiEpipoleSamplingDensityFactor
- Sample density scale near the epipole where inscattering changes rapidly. Note that sampling near the epipole is very cheap since only a few steps required to perform ray marching.fRefinementThreshold
- Sampling refinement threshold that controls detection of discontinuities. Smaller values produce more samples and higher quality, but at a higher performance cost.bShowSampling
- Whether to show epipolar sampling.bCorrectScatteringAtDepthBreaks
- Whether to correct inscattering at depth discontinuities. Improves quality for additional cost. It may be preferable to increase the number of slices and or maximum number of samples on an epipolar line instead.bShowDepthBreaks
- Whether to display pixels which are classified as depth discontinuities and which will be corrected. Only has effect when bCorrectScatteringAtDepthBreaks is TRUE.bShowLightingOnly
- Whether to show lighting onlybOptimizeSampleLocations
- Optimize sample locations to avoid oversampling. This should generally be TRUE.bEnableLightShafts
- Whether to enable light shafts or render unshadowed inscattering. Setting this to FALSE increases performance, but reduces visual quality.uiInstrIntegralSteps
- Number of inscattering integral steps taken when computing unshadowed inscattering Default value is OK and should not be changed.f2ShadowMapTexelSize
- Size of the shadowmap texel (1/width, 1/height)uiMaxSamplesOnTheRay
- Maximum number of ray marching samples on a single ray. Typically this value should match the maximum shadow map cascade resolution. Using lower value will improve performance but may result in moire patterns. Note that in most cases significantly less samples are actually taken.uiMinMaxShadowMapResolution
- Defines the number of samples at the lowest level of min-max binary tree and should match the maximum cascade shadow map resolution.iNumCascades
- Number of shadow map cascadesiFirstCascadeToRayMarch
- First cascade to use for ray marching. Usually first few cascades are small, and ray marching them is inefficient.fMaxShadowMapStep
- Cap on the maximum shadow map step in texels.bUse1DMinMaxTree
- Whether to use 1D min/max binary tree optimization. This improves performance for higher shadow map resolution. Test it.bIs32BitMinMaxMipMap
- Whether to use 32-bit float or 16-bit UNORM min-max binary tree. Usually 16-bit UNORM is OK.uiLightSctrTechnique
- Light scattering evaluation technique. The following two methods are available: epipolar and brute-force. Brute force light scattering performs expensive ray marching for every screen pixel. This method can be used as the quality reference.uiCascadeProcessingMode
- Shadow map cascades processing mode.uiRefinementCriterion
- Epipolar sampling refinement criterion. The two options are depth difference and scattering difference. Scattering difference is generally preferable way.uiSingleScatteringMode
- Single scattering evaluation mode. The following three methods are available:uiMultipleScatteringMode
- Higher-order scattering evaluation mode. The following three options are available:uiExtinctionEvalMode
- Atmospheric extinction evaluation mode.bUseCustomSctrCoeffs
- Whether to use custom scattering coefficients.fAerosolDensityScale
- Aerosol density scale to use for scattering coefficient computation.fAerosolAbsorbtionScale
- Aerosol absorption scale to use for scattering coefficient computation.f4CustomRlghBeta
- Custom Rayleigh coefficients.f4CustomMieBeta
- Custom Mie coefficients.The effect requires the following data:
The code snippet below shows how to use the epipolar light scattering post-processing effect. For the full source code, see Atmospheric scattering sample.
void Diligent::EpipolarLightScattering::PrepareForNewFrame | ( | FrameAttribs & | FrameAttribs, |
EpipolarLightScatteringAttribs & | PPAttribs ) |
The method prepares internal resources and states for processing the next frame. It must be called at the beginning of every frame before any other rendering method (RenderSun, PerformPostProcessing) can be called.