Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DeferredRenderer Class Referencefinal

Performs deferred rendering of a scene. More...

#include <DeferredRenderer.hpp>

Public Member Functions

 DeferredRenderer (const glm::vec2 &resolution, bool ssao, const std::string &name)
 
void setScene (const std::shared_ptr< Scene > &scene)
 
void draw (const Camera &camera, Texture *dstColor, Texture *dstDepth, uint layer=0) override
 
void resize (uint width, uint height) override
 
void interface () override
 
TexturesceneDepth ()
 
- Public Member Functions inherited from Renderer
 Renderer (const std::string &name)
 
virtual void draw (const Camera &camera, Texture *dstColor, Texture *dstDepth, uint layer=0)
 
virtual void resize (uint width, uint height)
 
virtual void interface ()
 
virtual ~Renderer ()=default
 
 Renderer (const Renderer &)=delete
 
Rendereroperator= (const Renderer &)=delete
 
 Renderer (Renderer &&)=delete
 
Rendereroperator= (Renderer &&)=delete
 
Layout outputColorFormat () const
 
Layout outputDepthFormat () const
 

Private Member Functions

void renderOpaque (const Culler::List &visibles, const glm::mat4 &view, const glm::mat4 &proj)
 
void renderTransparent (const Culler::List &visibles, const glm::mat4 &view, const glm::mat4 &proj)
 
void renderBackground (const glm::mat4 &view, const glm::mat4 &proj, const glm::vec3 &pos)
 

Private Attributes

Texture _sceneAlbedo
 Scene albedo.
 
Texture _sceneNormal
 Scene normals.
 
Texture _sceneEffects
 Scene material parameters.
 
Texture _sceneDepth
 Scene depth.
 
Texture _lighting
 Lighting accumulation.
 
Texture _indirectLighting
 Indirect lighting accumulation.
 
Texture _depthCopy
 Lighting detph copy.
 
std::unique_ptr< SSAO_ssaoPass
 SSAO processing.
 
std::unique_ptr< DeferredLight_lightRenderer
 The lights renderer.
 
std::unique_ptr< DeferredProbe_probeRenderer
 The probes renderer.
 
std::unique_ptr< ForwardLight_fwdLightsGPU
 The lights forward renderer for transparent objects.
 
std::unique_ptr< ForwardProbe_fwdProbesGPU
 The probes forward renderer for transparent objects.
 
Program_objectProgram
 Basic PBR program.
 
Program_parallaxProgram
 Parallax mapping PBR program.
 
Program_clearCoatProgram
 Basic PBR program with an additional clear coat specular layer.
 
Program_anisotropicProgram
 Basic PBR with anisotropic roughness.
 
Program_sheenProgram
 PBR with sheen BRDF.
 
Program_iridescentProgram
 PBR with iridescent Fresnel.
 
Program_subsurfaceProgram
 PBR with subsurface scattering.
 
Program_emissiveProgram
 Emissive program.
 
Program_transparentProgram
 Transparent PBR program.
 
Program_transpIridProgram
 Transparent PBR with iridescent Fresnel program.
 
Program_probeNormalization
 Indirect lighting normalization program.
 
Program_skyboxProgram
 Skybox program.
 
Program_bgProgram
 Planar background program.
 
Program_atmoProgram
 Atmospheric scattering program.
 
const Texture_textureBrdf
 The BRDF lookup table.
 
std::shared_ptr< Scene_scene
 The scene to render.
 
std::unique_ptr< Culler_culler
 Objects culler.
 
bool _applySSAO = true
 Screen space ambient occlusion.
 

Additional Inherited Members

- Protected Attributes inherited from Renderer
std::string _name
 Debug name.
 
Layout _colorFormat = Layout::NONE
 The preferred output format for a given renderer.
 
Layout _depthFormat = Layout::NONE
 The preferred output format for a given renderer.
 

Detailed Description

Performs deferred rendering of a scene.

See also
DeferredLight, DeferredProbe, Material, GPUShaders::Common::Common_pbr

Objects material information is renderer in a G-buffer, packing the various parameters as efficiently as possible in a fixed number of texture channels. As many components as possible are reused between materials, and the precision of some parameters is lowered. See the Material class documentation for all parameter details.

Shared section:

_______Red‏‏‎_______ ______Green______ _______Blue______ ______Alpha______
0: RGBA8 Albedo/reflectance/emissive color Material ID
1: RGB10A2 Normal octahedral XY
2: RGBA8

Standard (& Parallax):

_______Red‏‏‎_______ ______Green______ _______Blue______ ______Alpha______
1: RGB10A2
2: RGBA8 Roughness Metalness(5) Ambient occlusion
See also
GPUShaders::Frag::Object_gbuffer, GPUShaders::Frag::Object_parallax_gbuffer

Clearcoat:

_______Red‏‏‎_______ ______Green______ _______Blue______ ______Alpha______
1: RGB10A2
2: RGBA8 Roughness Metal(5) Coating(3) Ambient occlusion Coat roughness
See also
GPUShaders::Frag::Object_clearcoat_gbuffer

Anisotropic:

_______Red‏‏‎_______ ______Green______ _______Blue______ ______Alpha______
1: RGB10A2 Anisotropy angle Anisotropy signs
2: RGBA8 Roughness Metalness(5) Ambient occlusion Anisotropy
See also
GPUShaders::Frag::Object_anisotropic_gbuffer

Sheen:

_______Red‏‏‎_______ ______Green______ _______Blue______ ______Alpha______
1: RGB10A2 Sheen color (3*4)
2: RGBA8 Roughness Sheeness(5) Ambient occlusion Sheen roughness
See also
GPUShaders::Frag::Object_sheen_gbuffer

Iridescent:

_______Red‏‏‎_______ ______Green______ _______Blue______ ______Alpha______
1: RGB10A2 Index of refraction
2: RGBA8 Roughness Metalness(5) Ambient occlusion Thickness
See also
GPUShaders::Frag::Object_iridescent_gbuffer

Subsurface:

_______Red‏‏‎_______ ______Green______ _______Blue______ ______Alpha______
1: RGB10A2 Subsurface color (3*4)
2: RGBA8 Roughness Subsurf rough(5) Ambient occlusion Thickness
See also
GPUShaders::Frag::Object_subsurface_gbuffer

Emissive:

_______Red‏‏‎_______ ______Green______ _______Blue______ ______Alpha______
1: RGB10A2 Roughness
2: RGBA8 Emissive intensity
See also
GPUShaders::Frag::Object_emissive_gbuffer

The G-buffer is then read by each light, rendered as a geometric proxy onto the scene depth buffer and writing its lighting contribution to a lighting buffer. Ambient probes are processed similarly. Direct and ambient lighting are finally merged to generate the final image.

Transparent objects are rendered in a forward pass.

See also
GPUShaders::Frag::Object_transparent_forward, GPUShaders::Frag::Object_transparent_irid_forward

Inherits Renderer.

Constructor & Destructor Documentation

◆ DeferredRenderer()

DeferredRenderer::DeferredRenderer ( const glm::vec2 &  resolution,
bool  ssao,
const std::string &  name 
)
explicit

Constructor.

Parameters
resolutionthe initial rendering resolution
ssaoshould screen space ambient occlusion be computed
namethe debug name

Member Function Documentation

◆ draw()

void DeferredRenderer::draw ( const Camera camera,
Texture dstColor,
Texture dstDepth,
uint  layer = 0 
)
overridevirtual

Draw from a given viewpoint.

Parameters
camerathe rendering viewpoint
dstColorthe destination color texture (optional, see outputColorFormat)
dstDepththe destination depth texture (optional, see outputDepthFormat)
layerthe layer to write to in the target

Reimplemented from Renderer.

◆ interface()

void DeferredRenderer::interface ( )
overridevirtual

Display GUI exposing renderer options.

Note
The renderer can assume that a GUI window is currently open.

Reimplemented from Renderer.

◆ renderBackground()

void DeferredRenderer::renderBackground ( const glm::mat4 &  view,
const glm::mat4 &  proj,
const glm::vec3 &  pos 
)
private

Render the scene background to the G-buffer.

Parameters
viewthe camera view matrix
projthe camera projection matrix
posthe camera position

◆ renderOpaque()

void DeferredRenderer::renderOpaque ( const Culler::List visibles,
const glm::mat4 &  view,
const glm::mat4 &  proj 
)
private

Render the scene opaque objects.

Parameters
visibleslist of indices of visible objects
viewthe camera view matrix
projthe camera projection matrix

◆ renderTransparent()

void DeferredRenderer::renderTransparent ( const Culler::List visibles,
const glm::mat4 &  view,
const glm::mat4 &  proj 
)
private

Render the scene transparent objects.

Parameters
visibleslist of indices of visible objects
viewthe camera view matrix
projthe camera projection matrix

◆ resize()

void DeferredRenderer::resize ( uint  width,
uint  height 
)
overridevirtual

Handle a window resize event.

Parameters
widththe new width
heightthe new height

Reimplemented from Renderer.

◆ sceneDepth()

Texture & DeferredRenderer::sceneDepth ( )
Returns
the texture containing the scene depth information

◆ setScene()

void DeferredRenderer::setScene ( const std::shared_ptr< Scene > &  scene)

Set the scene to render.

Parameters
scenethe new scene

The documentation for this class was generated from the following files: