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

A renderer that shade each object as it is drawn in the scene directly. More...

#include <ForwardRenderer.hpp>

Public Member Functions

 ForwardRenderer (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 renderDepth (const Culler::List &visibles, const glm::mat4 &view, const glm::mat4 &proj)
 
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 _sceneColor
 Scene color texture.
 
Texture _sceneDepth
 Scene depth texture.
 
std::unique_ptr< SSAO_ssaoPass
 SSAO processing.
 
std::unique_ptr< ForwardLight_lightsGPU
 The lights renderer.
 
std::unique_ptr< ForwardProbe_probesGPU
 The probes renderer.
 
Program_objectProgram
 Basic PBR program.
 
Program_parallaxProgram
 Parallax mapping PBR program.
 
Program_emissiveProgram
 Parallax mapping PBR program.
 
Program_transparentProgram
 Transparent PBR program.
 
Program_transpIridProgram
 Transparent PBR with iridescent Fresnel.
 
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_depthPrepass
 Depth prepass 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

A renderer that shade each object as it is drawn in the scene directly.

See also
ForwardLight

Lights and probes information is stored in large data buffers that each object shader iterates over, summing their lighting contribution and outputing the final result.

See also
GPUShaders::Frag::Object_forward, GPUShaders::Frag::Object_parallax_forward, GPUShaders::Frag::Object_clearcoat_forward, GPUShaders::Frag::Object_anisotropic_forward, GPUShaders::Frag::Object_sheen_forward, GPUShaders::Frag::Object_iridescent_forward, GPUShaders::Frag::Object_subsurface_forward, GPUShaders::Frag::Object_emissive_forward, GPUShaders::Frag::Object_transparent_forward, GPUShaders::Frag::Object_transparent_irid_forward

A depth prepass is used to avoid wasting lighting computations on surfaces that are occluded by other objects drawn later in the frame.

See also
GPUShaders::Frag::Object_prepass_forward

Inherits Renderer.

Constructor & Destructor Documentation

◆ ForwardRenderer()

ForwardRenderer::ForwardRenderer ( 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 ForwardRenderer::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

This is because after a change of scene shadow maps and probes are reset, but the conditional setup of textures on the program means that descriptors can still reference the deleted textures.

Todo:
Currently there is no mechanism to "unregister" a texture for each shader using it, when deleting the texture. The texture could keep a record of all programs it has been used in. Or we could look at all programs when deleting. Or in PBRDemo we reset the textures when setting a scene.

Reimplemented from Renderer.

◆ interface()

void ForwardRenderer::interface ( )
overridevirtual

Display GUI exposing renderer options.

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

Reimplemented from Renderer.

◆ renderBackground()

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

Render the scene background.

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

◆ renderDepth()

void ForwardRenderer::renderDepth ( const Culler::List visibles,
const glm::mat4 &  view,
const glm::mat4 &  proj 
)
private

Render the scene object depth (prepass).

Parameters
visibleslist of indices of visible objects
viewthe camera view matrix
projthe camera projection matrix
Note
Transparent and parallax objects will be skipped.

◆ renderOpaque()

void ForwardRenderer::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 ForwardRenderer::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 ForwardRenderer::resize ( uint  width,
uint  height 
)
overridevirtual

Handle a window resize event.

Parameters
widththe new width
heightthe new height

Reimplemented from Renderer.

◆ sceneDepth()

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

◆ setScene()

void ForwardRenderer::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: