Lysa  0.0
Lysa 3D Engine
DeferredRenderer Class Reference

Detailed Description

Deferred rendering path.

Renders geometry into a G-Buffer (position, normal, albedo, emissive), then performs lighting as a full-screen pass, followed by transparency and post-processing passes.

+ Inheritance diagram for DeferredRenderer:

Public Member Functions

 DeferredRenderer (const RendererConfiguration &config, vireo::ImageFormat outputFormat)
 
void update (uint32 frameIndex) override
 
void updatePipelines (const std::unordered_map< pipeline_id, std::vector< unique_id >> &pipelineIds) override
 
void resize (const vireo::Extent &extent, const std::shared_ptr< vireo::CommandList > &commandList) override
 
std::shared_ptr< vireo::Image > getBrightnessAttachment (const uint32 frameIndex) const override
 
std::shared_ptr< vireo::RenderTarget > getColorRenderTarget (const uint32 frameIndex) const override
 
GBufferPassgetGBufferPass ()
 
FullScreenComputegetAOPass () const
 
TAAPassgetTAAPass () const
 
FullScreenComputegetSSAOBlurPass () const
 
- Public Member Functions inherited from Renderer
auto getColorAttachment (const uint32 frameIndex) const
 
auto getDepthAttachment (const uint32 frameIndex) const
 
std::shared_ptr< vireo::Image > getCurrentColorAttachment (uint32 frameIndex) const
 
void updatePipelines (const SceneFrameData &scene)
 
void prepare (const std::shared_ptr< vireo::CommandList > &commandList, const SceneFrameData &scene, const vireo::Viewport &viewport, const vireo::Rect &scissors, uint32 frameIndex)
 
void render (const std::shared_ptr< vireo::CommandList > &commandList, const SceneFrameData &scene, const vireo::Viewport &viewport, const vireo::Rect &scissors, bool clearAttachment, uint32 frameIndex)
 
std::shared_ptr< vireo::Image > postprocessBloom (const std::shared_ptr< vireo::CommandList > &commandList, uint32 frameIndex) const
 
std::shared_ptr< vireo::Image > postprocess (const std::shared_ptr< vireo::CommandList > &commandList, const std::shared_ptr< vireo::Image > &colorAttachment, uint32 frameIndex)
 
std::shared_ptr< vireo::Image > postprocessAA (const std::shared_ptr< vireo::CommandList > &commandList, const std::shared_ptr< vireo::Image > &colorAttachment, uint32 frameIndex) const
 
void renderCustomRenderPasses (const std::shared_ptr< vireo::CommandList > &commandList, const SceneFrameData &scene, RenderingPhase stage, uint32 frameIndex)
 
void addPostprocessing (FullScreenCompute &postProcessingPass)
 
void removePostprocessing (const std::string &fragShaderName)
 
void removePostprocessing (const FullScreenCompute &postProcessingPass)
 
void addRenderPass (RenderingPhase phase, CustomRenderpass &pass)
 
void removeRenderPass (RenderingPhase phase, const CustomRenderpass &pass)
 
TransparencyPassgetTransparencyPass ()
 
FXAAPassgetFXAAPass () const
 
SMAAPassgetSMAAPass () const
 
BloomPassgetBloomPass () const
 
GammaCorrectionPassgetGammaCorrectionPass () const
 
vireo::ImageFormat getOutputFormat () const
 
const auto & getExtent () const
 
virtual ~Renderer () = default
 
 Renderer (Renderer &) = delete
 
Renderer & operator= (Renderer &) = delete
 

Protected Member Functions

void colorPass (const std::shared_ptr< vireo::CommandList > &commandList, const SceneFrameData &scene, const vireo::Viewport &viewport, const vireo::Rect &scissors, bool clearAttachment, uint32 frameIndex) override
 
- Protected Member Functions inherited from Renderer
 Renderer (const RendererConfiguration &config, vireo::ImageFormat outputFormat)
 

Additional Inherited Members

- Static Public Member Functions inherited from Renderer
static std::unique_ptr< Renderer > create (const RendererConfiguration &config, vireo::ImageFormat outputFormat)
 
- Protected Attributes inherited from Renderer
const bool withStencil
 True if stencil testing must be enabled. More...
 
const RendererConfiguration config
 Global rendering configuration. More...
 
vireo::ImageFormat outputFormat
 Final output format after the gamma/tonemapping pass. More...
 
std::vector< FrameDataframesData
 Per-frame attachment data, one entry per frame in flight. More...
 
DepthPrepass depthPrePass
 Depth-only pre-pass shared by forward and deferred renderers. More...
 

Constructor & Destructor Documentation

DeferredRenderer ( const RendererConfiguration config,
vireo::ImageFormat  outputFormat 
)

Constructs a deferred renderer instance.

Parameters
configRendering configuration (attachments, frames in flight).
outputFormatOutput attachment color format

Member Function Documentation

void colorPass ( const std::shared_ptr< vireo::CommandList > &  commandList,
const SceneFrameData scene,
const vireo::Viewport &  viewport,
const vireo::Rect &  scissors,
bool  clearAttachment,
uint32  frameIndex 
)
overrideprotectedvirtual

Records the pipeline-specific color pass for the concrete renderer. Implementations dispatch scene draws into colorAttachment and depthAttachment.

Parameters
commandListCommand list to record into.
scenePer-frame scene data.
viewportViewport rectangle for this frame.
scissorsScissor rectangle for this frame.
clearAttachmentIf true, the color attachment is cleared before rendering.
frameIndexIndex of the frame in flight.

Implements lysa::Renderer::colorPass()

FullScreenCompute& getAOPass ( ) const
inline
std::shared_ptr<vireo::Image> getBrightnessAttachment ( const uint32  frameIndex) const
inlineoverridevirtual

Returns the brightness buffer used as input for the bloom extraction pass.

Parameters
frameIndexIndex of the frame in flight.
Returns
Shared pointer to the brightness image.

Implements lysa::Renderer::getBrightnessAttachment()

std::shared_ptr<vireo::RenderTarget> getColorRenderTarget ( const uint32  frameIndex) const
inlineoverridevirtual

Returns the color render target for a given frame. Overridden by subclasses that apply a TAA or sharpening pass as the final step.

Parameters
frameIndexIndex of the frame in flight.
Returns
Shared pointer to the color render target.

Reimplemented from lysa::Renderer::getColorRenderTarget()

GBufferPass& getGBufferPass ( )
inline
FullScreenCompute& getSSAOBlurPass ( ) const
inline
TAAPass& getTAAPass ( ) const
inline
void resize ( const vireo::Extent &  extent,
const std::shared_ptr< vireo::CommandList > &  commandList 
)
overridevirtual

Recreates attachments and pipelines after a render target resize.

Parameters
extentNew swap chain extent.
commandListCommand list used for any required layout transitions or copies.

Reimplemented from lysa::Renderer::resize()

void update ( uint32  frameIndex)
overridevirtual

Performs per-frame housekeeping such as pass-local data uploads.

Parameters
frameIndexIndex of the frame in flight.

Reimplemented from lysa::Renderer::update()

void updatePipelines ( const std::unordered_map< pipeline_id, std::vector< unique_id >> &  pipelineIds)
overridevirtual

Updates graphics pipelines according to the provided materials mapping.

Parameters
pipelineIdsMap of pipeline family id to the list of material unique ids.

Reimplemented from lysa::Renderer::updatePipelines()