Kuesa Runtime

ForwardRenderer Class

class Kuesa::ForwardRenderer

Implements a simple forward rendering FrameGraph. More...

Header: #include <ForwardRenderer>
Since: Kuesa 1.0
Instantiated By: ForwardRenderer
Inherits: Kuesa::View

This class was introduced in Kuesa 1.0.

Properties

Public Functions

Qt3DRender::QClearBuffers::BufferType clearBuffers() const
QObject *renderSurface() const
bool showDebugOverlay() const

Public Slots

void dump()
void setClearBuffers(Qt3DRender::QClearBuffers::BufferType clearBuffers)
void setRenderSurface(QObject *renderSurface)
void setShowDebugOverlay(bool showDebugOverlay)

Signals

void clearBuffersChanged(Qt3DRender::QClearBuffers::BufferType clearBuffers)
void renderSurfaceChanged(QObject *renderSurface)
void showDebugOverlayChanged(bool showDebugOverlay)

Detailed Description

This FrameGraph will select all Qt3D Entities that reference a Material with Techniques having a FilterKey with the name "renderingStyle" set to the string value "forward".

The rendering will be made on a main viewport whose dimensions can be set with normalized coordinates by calling ForwardRender::setViewportRect.

The screen will be cleared with the color set by calling ForwardRender::setClearColor. By default the clear color is black.

Unless a call to ForwardRender::setClearBuffers has been made, only the color and depth buffers will be cleared before the rest of the scene is rendered.

The scene will be rendered from the camera set with ForwardRender::setCamera on the window or offscreen surface set by calling ForwardRender::setRenderSurface. Additionally ForwardRender::setExternalRenderTargetSize can be called to specify the size of the rendering surface, when different from the size reported by the surface, this can be the case with high DPI screens.

Frustum culling of Entities will be performed by default to only render entities that are visible within the camera's frustum. This can be disabled by calling ForwardRender::setFrustumCulling. Please note frustum culling is not performed on skinned meshes.

By default the rendering is performed so that:

Opaque object are rendered first: Entities having a Material with a compatible RenderPass that has a FilterKey KuesaDrawStage with a value set to Opaque will be rendered.

Transparent objects are rendered second: select all Entities having a Material with a compatible RenderPass that has a FilterKey KuesaDrawStage with a value set to Transparent will be rendered.

Scenes containing materials with transparency need to be drawn from back-to-front in relation to the Camera for the blending to work correctly. This sorting can be expensive and is disabled by default. It can be enabled by calling ForwardRender::setBackToFrontSorting.

In some case, an optimization technique known as an early z-filling pass can provide a significant performance gain. This is especially true for large scenes using complex rendering materials. The idea consist in filling the depth buffer with a low complexity shader so that subsequent passes incorporating more detailed rendering techniques only render fragments for the depth previously recorded. The optional z-fill pass can be enabled by calling ForwardRender::setZFilling. All Entities having a Material with a compatible RenderPass that has a FilterKey KuesaDrawStage with a value set to ZFill will be rendered. This will take place before the Opaque and Transparent pass. Only Opaque objects should be used to fill the depth buffer.

The pipeline steps, from materials to post processing effects are working in linear color space. This ForwardRenderer adds a final gamma correction to perform the final conversion to sRGB, through the use of the GammaCorrectionEffect, as the last step of this pipeline.

 #include <Qt3DExtras/Qt3DWindow>
 #include <Qt3DRender/QCamera>
 #include <ForwardRenderer>
 #include <SceneEntity>
 #include <BloomEffect>

 Qt3DExtras::Qt3DWindow win;
 Kuesa::SceneEntity *root = new Kuesa::SceneEntity();
 Kuesa::ForwardRenderer *frameGraph = new Kuesa::ForwardRenderer();
 Kuesa::BloomEffect *bloomEffect = new Kuesa::BloomEffect();
 Qt3DRender::QCamera *camera = new Qt3DRender::QCamera();

 frameGraph->setCamera(camera);
 frameGraph->setFrustumCulling(true);
 frameGraph->setClearColor(QColor(Qt::red));
 frameGraph->addPostProcessingEffect(bloomEffect);

 win->setRootEntity(root);
 win->setActiveFrameGraph(forwardRenderer);

 ...

Property Documentation

clearBuffers : Qt3DRender::QClearBuffers::BufferType

Holds which buffers will be cleared at the start of each frame.

Access functions:

Qt3DRender::QClearBuffers::BufferType clearBuffers() const
void setClearBuffers(Qt3DRender::QClearBuffers::BufferType clearBuffers)

Notifier signal:

void clearBuffersChanged(Qt3DRender::QClearBuffers::BufferType clearBuffers)

renderSurface : QObject*

Holds the surface where rendering will occur.

Access functions:

QObject *renderSurface() const
void setRenderSurface(QObject *renderSurface)

Notifier signal:

void renderSurfaceChanged(QObject *renderSurface)

Member Function Documentation

[slot] void ForwardRenderer::dump()

Dumps the FrameGraph tree to the console. Can be really convenient for debug or troubleshooting purposes.

[slot] void ForwardRenderer::setClearBuffers(Qt3DRender::QClearBuffers::BufferType clearBuffers)

Sets which clearBuffers will be cleared at the start of each frame.

Note: Setter function for property clearBuffers.

See also clearBuffers().

[slot] void ForwardRenderer::setRenderSurface(QObject *renderSurface)

Sets the surface where rendering will occur to renderSurface. This can be an offscreen surface or a window surface.

Note: Setter function for property renderSurface.

See also renderSurface().

Qt3DRender::QClearBuffers::BufferType ForwardRenderer::clearBuffers() const

Returns which buffers are cleared at the start of each frame.

Note: Getter function for property clearBuffers.

See also setClearBuffers().

QObject *ForwardRenderer::renderSurface() const

Returns the surface where rendering will occur.

Note: Getter function for property renderSurface.

See also setRenderSurface().