A renderer that shade each object as it is drawn in the scene directly.
More...
#include <ForwardRenderer.hpp>
|
| 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 |
|
Texture & | sceneDepth () |
|
| 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 |
|
Renderer & | operator= (const Renderer &)=delete |
|
| Renderer (Renderer &&)=delete |
|
Renderer & | operator= (Renderer &&)=delete |
|
Layout | outputColorFormat () const |
|
Layout | outputDepthFormat () const |
|
|
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.
|
|
|
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.
|
|
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.
◆ ForwardRenderer()
ForwardRenderer::ForwardRenderer |
( |
const glm::vec2 & |
resolution, |
|
|
bool |
ssao, |
|
|
const std::string & |
name |
|
) |
| |
|
explicit |
Constructor.
- Parameters
-
resolution | the initial rendering resolution |
ssao | should screen space ambient occlusion be computed |
name | the debug name |
◆ draw()
void ForwardRenderer::draw |
( |
const Camera & |
camera, |
|
|
Texture * |
dstColor, |
|
|
Texture * |
dstDepth, |
|
|
uint |
layer = 0 |
|
) |
| |
|
overridevirtual |
Draw from a given viewpoint.
- Parameters
-
camera | the rendering viewpoint |
dstColor | the destination color texture (optional, see outputColorFormat) |
dstDepth | the destination depth texture (optional, see outputDepthFormat) |
layer | the 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
-
view | the camera view matrix |
proj | the camera projection matrix |
pos | the 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
-
visibles | list of indices of visible objects |
view | the camera view matrix |
proj | the 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
-
visibles | list of indices of visible objects |
view | the camera view matrix |
proj | the 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
-
visibles | list of indices of visible objects |
view | the camera view matrix |
proj | the camera projection matrix |
◆ resize()
void ForwardRenderer::resize |
( |
uint |
width, |
|
|
uint |
height |
|
) |
| |
|
overridevirtual |
Handle a window resize event.
- Parameters
-
width | the new width |
height | the 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
-
The documentation for this class was generated from the following files: