QGIS API Documentation 3.43.0-Master (261ee7da134)
qgsframegraph.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsframegraph.cpp
3 --------------------------------------
4 Date : August 2020
5 Copyright : (C) 2020 by Belgacem Nedjima
6 Email : gb underscore nedjima at esi dot dz
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgsframegraph.h"
17#include "moc_qgsframegraph.cpp"
20#include "qgs3dutils.h"
21#include "qgsframegraphutils.h"
23#include "qgsshadowrenderview.h"
24
25
26#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
27#include <Qt3DRender/QAttribute>
28#include <Qt3DRender/QBuffer>
29#include <Qt3DRender/QGeometry>
30
31typedef Qt3DRender::QAttribute Qt3DQAttribute;
32typedef Qt3DRender::QBuffer Qt3DQBuffer;
33typedef Qt3DRender::QGeometry Qt3DQGeometry;
34#else
35#include <Qt3DCore/QAttribute>
36#include <Qt3DCore/QBuffer>
37#include <Qt3DCore/QGeometry>
38
39typedef Qt3DCore::QAttribute Qt3DQAttribute;
40typedef Qt3DCore::QBuffer Qt3DQBuffer;
41typedef Qt3DCore::QGeometry Qt3DQGeometry;
42#endif
43
44#include <Qt3DRender/QGeometryRenderer>
45#include <Qt3DRender/QTechnique>
46#include <Qt3DRender/QGraphicsApiFilter>
47#include <Qt3DRender/QBlendEquation>
48#include <Qt3DRender/QColorMask>
49#include <Qt3DRender/QSortPolicy>
50#include <Qt3DRender/QNoDepthMask>
51#include <Qt3DRender/QBlendEquationArguments>
52#include <Qt3DRender/QAbstractTexture>
53#include <Qt3DRender/QNoDraw>
54#include "qgsshadowrenderview.h"
56#include "qgsdepthrenderview.h"
57#include "qgsdepthentity.h"
61
62const QString QgsFrameGraph::FORWARD_RENDERVIEW = "forward";
63const QString QgsFrameGraph::SHADOW_RENDERVIEW = "shadow";
64const QString QgsFrameGraph::AXIS3D_RENDERVIEW = "3daxis";
65const QString QgsFrameGraph::DEPTH_RENDERVIEW = "depth";
66const QString QgsFrameGraph::DEBUG_RENDERVIEW = "debug_texture";
67const QString QgsFrameGraph::AMBIENT_OCCLUSION_RENDERVIEW = "ambient_occlusion";
68
69void QgsFrameGraph::constructForwardRenderPass()
70{
71 registerRenderView( std::make_unique<QgsForwardRenderView>( FORWARD_RENDERVIEW, mMainCamera ), FORWARD_RENDERVIEW );
72}
73
74void QgsFrameGraph::constructShadowRenderPass()
75{
76 registerRenderView( std::make_unique<QgsShadowRenderView>( SHADOW_RENDERVIEW ), SHADOW_RENDERVIEW );
77}
78
79void QgsFrameGraph::constructDebugTexturePass( Qt3DRender::QFrameGraphNode *topNode )
80{
81 registerRenderView( std::make_unique<QgsDebugTextureRenderView>( DEBUG_RENDERVIEW ), DEBUG_RENDERVIEW, topNode );
82}
83
84Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructSubPostPassForProcessing()
85{
86 Qt3DRender::QCameraSelector *cameraSelector = new Qt3DRender::QCameraSelector;
87 cameraSelector->setObjectName( "Sub pass Postprocessing" );
88 cameraSelector->setCamera( shadowRenderView().lightCamera() );
89
90 Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter( cameraSelector );
91
92 // could be the first of this branch
93 new Qt3DRender::QClearBuffers( layerFilter );
94
95 Qt3DRender::QLayer *postProcessingLayer = new Qt3DRender::QLayer();
96 mPostprocessingEntity = new QgsPostprocessingEntity( this, postProcessingLayer, mRootEntity );
97 layerFilter->addLayer( postProcessingLayer );
98 mPostprocessingEntity->setObjectName( "PostProcessingPassEntity" );
99
100 return cameraSelector;
101}
102
103Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructSubPostPassForRenderCapture()
104{
105 Qt3DRender::QFrameGraphNode *top = new Qt3DRender::QNoDraw;
106 top->setObjectName( "Sub pass RenderCapture" );
107
108 mRenderCapture = new Qt3DRender::QRenderCapture( top );
109
110 return top;
111}
112
113Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructPostprocessingPass()
114{
115 mRenderCaptureTargetSelector = new Qt3DRender::QRenderTargetSelector;
116 mRenderCaptureTargetSelector->setObjectName( "Postprocessing render pass" );
117 mRenderCaptureTargetSelector->setEnabled( mRenderCaptureEnabled );
118
119 Qt3DRender::QRenderTarget *renderTarget = new Qt3DRender::QRenderTarget( mRenderCaptureTargetSelector );
120
121 // The lifetime of the objects created here is managed
122 // automatically, as they become children of this object.
123
124 // Create a render target output for rendering color.
125 Qt3DRender::QRenderTargetOutput *colorOutput = new Qt3DRender::QRenderTargetOutput( renderTarget );
126 colorOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Color0 );
127
128 // Create a texture to render into.
129 mRenderCaptureColorTexture = new Qt3DRender::QTexture2D( colorOutput );
130 mRenderCaptureColorTexture->setSize( mSize.width(), mSize.height() );
131 mRenderCaptureColorTexture->setFormat( Qt3DRender::QAbstractTexture::RGB8_UNorm );
132 mRenderCaptureColorTexture->setMinificationFilter( Qt3DRender::QAbstractTexture::Linear );
133 mRenderCaptureColorTexture->setMagnificationFilter( Qt3DRender::QAbstractTexture::Linear );
134 mRenderCaptureColorTexture->setObjectName( "PostProcessingPass::ColorTarget" );
135
136 // Hook the texture up to our output, and the output up to this object.
137 colorOutput->setTexture( mRenderCaptureColorTexture );
138 renderTarget->addOutput( colorOutput );
139
140 Qt3DRender::QRenderTargetOutput *depthOutput = new Qt3DRender::QRenderTargetOutput( renderTarget );
141
142 depthOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Depth );
143 mRenderCaptureDepthTexture = new Qt3DRender::QTexture2D( depthOutput );
144 mRenderCaptureDepthTexture->setSize( mSize.width(), mSize.height() );
145 mRenderCaptureDepthTexture->setFormat( Qt3DRender::QAbstractTexture::DepthFormat );
146 mRenderCaptureDepthTexture->setMinificationFilter( Qt3DRender::QAbstractTexture::Linear );
147 mRenderCaptureDepthTexture->setMagnificationFilter( Qt3DRender::QAbstractTexture::Linear );
148 mRenderCaptureDepthTexture->setComparisonFunction( Qt3DRender::QAbstractTexture::CompareLessEqual );
149 mRenderCaptureDepthTexture->setComparisonMode( Qt3DRender::QAbstractTexture::CompareRefToTexture );
150 mRenderCaptureDepthTexture->setObjectName( "PostProcessingPass::DepthTarget" );
151
152 depthOutput->setTexture( mRenderCaptureDepthTexture );
153 renderTarget->addOutput( depthOutput );
154
155 mRenderCaptureTargetSelector->setTarget( renderTarget );
156
157 // sub passes:
158 constructSubPostPassForProcessing()->setParent( mRenderCaptureTargetSelector );
159 constructDebugTexturePass( mRenderCaptureTargetSelector );
160 constructSubPostPassForRenderCapture()->setParent( mRenderCaptureTargetSelector );
161
162 return mRenderCaptureTargetSelector;
163}
164
165void QgsFrameGraph::constructAmbientOcclusionRenderPass()
166{
167 Qt3DRender::QTexture2D *forwardDepthTexture = forwardRenderView().depthTexture();
168
169 QgsAmbientOcclusionRenderView *aorv = new QgsAmbientOcclusionRenderView( AMBIENT_OCCLUSION_RENDERVIEW, mMainCamera, mSize, forwardDepthTexture, mRootEntity );
170 registerRenderView( std::unique_ptr<QgsAmbientOcclusionRenderView>( aorv ), AMBIENT_OCCLUSION_RENDERVIEW );
171}
172
173Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructRubberBandsPass()
174{
175 mRubberBandsCameraSelector = new Qt3DRender::QCameraSelector;
176 mRubberBandsCameraSelector->setObjectName( "RubberBands Pass CameraSelector" );
177 mRubberBandsCameraSelector->setCamera( mMainCamera );
178
179 mRubberBandsLayerFilter = new Qt3DRender::QLayerFilter( mRubberBandsCameraSelector );
180 mRubberBandsLayerFilter->addLayer( mRubberBandsLayer );
181
182 Qt3DRender::QBlendEquationArguments *blendState = new Qt3DRender::QBlendEquationArguments;
183 blendState->setSourceRgb( Qt3DRender::QBlendEquationArguments::SourceAlpha );
184 blendState->setDestinationRgb( Qt3DRender::QBlendEquationArguments::OneMinusSourceAlpha );
185
186 Qt3DRender::QBlendEquation *blendEquation = new Qt3DRender::QBlendEquation;
187 blendEquation->setBlendFunction( Qt3DRender::QBlendEquation::Add );
188
189 mRubberBandsStateSet = new Qt3DRender::QRenderStateSet( mRubberBandsLayerFilter );
190 Qt3DRender::QDepthTest *depthTest = new Qt3DRender::QDepthTest;
191 depthTest->setDepthFunction( Qt3DRender::QDepthTest::Always );
192 mRubberBandsStateSet->addRenderState( depthTest );
193 mRubberBandsStateSet->addRenderState( blendState );
194 mRubberBandsStateSet->addRenderState( blendEquation );
195
196 // Here we attach our drawings to the render target also used by forward pass.
197 // This is kind of okay, but as a result, post-processing effects get applied
198 // to rubber bands too. Ideally we would want them on top of everything.
199 mRubberBandsRenderTargetSelector = new Qt3DRender::QRenderTargetSelector( mRubberBandsStateSet );
200 mRubberBandsRenderTargetSelector->setTarget( forwardRenderView().renderTargetSelector()->target() );
201
202 return mRubberBandsCameraSelector;
203}
204
205
206void QgsFrameGraph::constructDepthRenderPass()
207{
208 // entity used to draw the depth texture and convert it to rgb image
209 Qt3DRender::QTexture2D *forwardDepthTexture = forwardRenderView().depthTexture();
210 QgsDepthRenderView *rv = new QgsDepthRenderView( DEPTH_RENDERVIEW, mSize, forwardDepthTexture, mRootEntity );
211 registerRenderView( std::unique_ptr<QgsDepthRenderView>( rv ), DEPTH_RENDERVIEW );
212}
213
214Qt3DRender::QRenderCapture *QgsFrameGraph::depthRenderCapture()
215{
217}
218
219QgsFrameGraph::QgsFrameGraph( QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root )
220 : Qt3DCore::QEntity( root )
221 , mSize( s )
222{
223 // general overview of how the frame graph looks:
224 //
225 // +------------------------+ using window or
226 // | QRenderSurfaceSelector | offscreen surface
227 // +------------------------+
228 // |
229 // +-----------+
230 // | QViewport | (0,0,1,1)
231 // +-----------+
232 // |
233 // +--------------------------+-------------------+-----------------+
234 // | | | |
235 // +--------------------+ +--------------+ +-----------------+ +-----------------+
236 // | two forward passes | | shadows pass | | depth buffer | | post-processing |
237 // | (solid objects | | | | processing pass | | passes |
238 // | and transparent) | +--------------+ +-----------------+ +-----------------+
239 // +--------------------+
240 //
241 // Notes:
242 // - depth buffer processing pass is used whenever we need depth map information
243 // (for camera navigation) and it converts depth texture to a color texture
244 // so that we can capture it with QRenderCapture - currently it is unable
245 // to capture depth buffer, only colors (see QTBUG-65155)
246 // - there are multiple post-processing passes that take rendered output
247 // of the scene, optionally apply effects (add shadows, ambient occlusion,
248 // eye dome lighting) and finally output to the given surface
249 // - there may be also two more passes when 3D axis is shown - see Qgs3DAxis
250
251 mRootEntity = root;
252 mMainCamera = mainCamera;
253
254 mRubberBandsLayer = new Qt3DRender::QLayer;
255 mRubberBandsLayer->setObjectName( "mRubberBandsLayer" );
256 mRubberBandsLayer->setRecursive( true );
257
258 mRenderSurfaceSelector = new Qt3DRender::QRenderSurfaceSelector;
259
260 QObject *surfaceObj = dynamic_cast<QObject *>( surface );
261 Q_ASSERT( surfaceObj );
262
263 mRenderSurfaceSelector->setSurface( surfaceObj );
264 mRenderSurfaceSelector->setExternalRenderTargetSize( mSize );
265
266 mMainViewPort = new Qt3DRender::QViewport( mRenderSurfaceSelector );
267 mMainViewPort->setNormalizedRect( QRectF( 0.0f, 0.0f, 1.0f, 1.0f ) );
268
269 // Forward render
270 constructForwardRenderPass();
271
272 // rubber bands (they should be always on top)
273 Qt3DRender::QFrameGraphNode *rubberBandsPass = constructRubberBandsPass();
274 rubberBandsPass->setObjectName( "rubberBandsPass" );
275 rubberBandsPass->setParent( mMainViewPort );
276
277 // shadow rendering pass
278 constructShadowRenderPass();
279
280 // depth buffer processing
281 constructDepthRenderPass();
282
283 // Ambient occlusion factor render pass
284 constructAmbientOcclusionRenderPass();
285
286 // post process
287 Qt3DRender::QFrameGraphNode *postprocessingPass = constructPostprocessingPass();
288 postprocessingPass->setParent( mMainViewPort );
289 postprocessingPass->setObjectName( "PostProcessingPass" );
290
291 mRubberBandsRootEntity = new Qt3DCore::QEntity( mRootEntity );
292 mRubberBandsRootEntity->setObjectName( "mRubberBandsRootEntity" );
293 mRubberBandsRootEntity->addComponent( mRubberBandsLayer );
294}
295
296void QgsFrameGraph::unregisterRenderView( const QString &name )
297{
298 if ( mRenderViewMap.find( name ) != mRenderViewMap.end() )
299 {
300 mRenderViewMap[name]->topGraphNode()->setParent( ( QNode * ) nullptr );
301 mRenderViewMap.erase( name );
302 }
303}
304
305bool QgsFrameGraph::registerRenderView( std::unique_ptr<QgsAbstractRenderView> renderView, const QString &name, Qt3DRender::QFrameGraphNode *topNode )
306{
307 bool out;
308 if ( mRenderViewMap.find( name ) == mRenderViewMap.end() )
309 {
310 mRenderViewMap[name] = std::move( renderView );
311 mRenderViewMap[name]->topGraphNode()->setParent( topNode ? topNode : mMainViewPort );
312 mRenderViewMap[name]->updateWindowResize( mSize.width(), mSize.height() );
313 out = true;
314 }
315 else
316 out = false;
317
318 return out;
319}
320
321void QgsFrameGraph::setRenderViewEnabled( const QString &name, bool enable )
322{
323 if ( mRenderViewMap[name] )
324 {
325 mRenderViewMap[name]->setEnabled( enable );
326 }
327}
328
330{
331 if ( mRenderViewMap.find( name ) != mRenderViewMap.end() )
332 {
333 return mRenderViewMap[name].get();
334 }
335 return nullptr;
336}
337
338bool QgsFrameGraph::isRenderViewEnabled( const QString &name )
339{
340 return mRenderViewMap[name] != nullptr && mRenderViewMap[name]->isEnabled();
341}
342
344{
346
347 aoRenderView.setRadius( settings.radius() );
348 aoRenderView.setIntensity( settings.intensity() );
349 aoRenderView.setThreshold( settings.threshold() );
350 aoRenderView.setEnabled( settings.isEnabled() );
351
352 mPostprocessingEntity->setAmbientOcclusionEnabled( settings.isEnabled() );
353}
354
356{
357 mPostprocessingEntity->setEyeDomeLightingEnabled( settings.eyeDomeLightingEnabled() );
358 mPostprocessingEntity->setEyeDomeLightingStrength( settings.eyeDomeLightingStrength() );
359 mPostprocessingEntity->setEyeDomeLightingDistance( settings.eyeDomeLightingDistance() );
360}
361
362void QgsFrameGraph::updateShadowSettings( const QgsShadowSettings &shadowSettings, const QList<QgsLightSource *> &lightSources )
363{
364 if ( shadowSettings.renderShadows() )
365 {
366 int selectedLight = shadowSettings.selectedDirectionalLight();
367 QgsDirectionalLightSettings *light = nullptr;
368 for ( int i = 0, dirLight = 0; !light && i < lightSources.size(); i++ )
369 {
370 if ( lightSources[i]->type() == Qgis::LightSourceType::Directional )
371 {
372 if ( dirLight == selectedLight )
373 light = qgis::down_cast< QgsDirectionalLightSettings * >( lightSources[i] );
374 dirLight++;
375 }
376 }
377
378 if ( light )
379 {
380 shadowRenderView().setMapSize( shadowSettings.shadowMapResolution(), shadowSettings.shadowMapResolution() );
382 mPostprocessingEntity->setShadowRenderingEnabled( true );
383 mPostprocessingEntity->setShadowBias( static_cast<float>( shadowSettings.shadowBias() ) );
384 mPostprocessingEntity->updateShadowSettings( *light, static_cast<float>( shadowSettings.maximumShadowRenderingDistance() ) );
385 }
386 }
387 else
388 {
389 shadowRenderView().setEnabled( false );
390 mPostprocessingEntity->setShadowRenderingEnabled( false );
391 }
392}
393
395{
396 QgsDebugTextureRenderView *debugRenderView = dynamic_cast<QgsDebugTextureRenderView *>( mRenderViewMap[DEBUG_RENDERVIEW].get() );
397 if ( !mShadowTextureDebugging && settings.debugShadowMapEnabled() )
398 {
399 Qt3DRender::QTexture2D *shadowDepthTexture = shadowRenderView().mapTexture();
400 mShadowTextureDebugging = new QgsDebugTextureEntity( shadowDepthTexture, debugRenderView->debugLayer(), this );
401 }
402
403 debugRenderView->setEnabled( settings.debugShadowMapEnabled() || settings.debugDepthMapEnabled() );
404
405 if ( mShadowTextureDebugging )
406 {
407 mShadowTextureDebugging->setEnabled( settings.debugShadowMapEnabled() );
408 if ( settings.debugShadowMapEnabled() )
409 mShadowTextureDebugging->setPosition( settings.debugShadowMapCorner(), settings.debugShadowMapSize() );
410 else
411 {
412 delete mShadowTextureDebugging;
413 mShadowTextureDebugging = nullptr;
414 }
415 }
416}
417
419{
420 QgsDebugTextureRenderView *debugRenderView = dynamic_cast<QgsDebugTextureRenderView *>( mRenderViewMap[DEBUG_RENDERVIEW].get() );
421 if ( !mDepthTextureDebugging && settings.debugDepthMapEnabled() )
422 {
423 Qt3DRender::QTexture2D *forwardDepthTexture = forwardRenderView().depthTexture();
424 mDepthTextureDebugging = new QgsDebugTextureEntity( forwardDepthTexture, debugRenderView->debugLayer(), this );
425 }
426
427 debugRenderView->setEnabled( settings.debugShadowMapEnabled() || settings.debugDepthMapEnabled() );
428
429 if ( mDepthTextureDebugging )
430 {
431 mDepthTextureDebugging->setEnabled( settings.debugDepthMapEnabled() );
432 if ( settings.debugDepthMapEnabled() )
433 mDepthTextureDebugging->setPosition( settings.debugDepthMapCorner(), settings.debugDepthMapSize() );
434 else
435 {
436 delete mDepthTextureDebugging;
437 mDepthTextureDebugging = nullptr;
438 }
439 }
440}
441
443{
444 QObject *top = mRenderSurfaceSelector;
445 while ( top->parent() && dynamic_cast<Qt3DRender::QFrameGraphNode *>( top->parent() ) )
446 top = top->parent();
447
449 context.lowestId = mMainCamera->id().id();
450 QStringList strList = QgsFrameGraphUtils::dumpFrameGraph( dynamic_cast<Qt3DRender::QFrameGraphNode *>( top ), context );
451
452 return strList.join( "\n" ) + QString( "\n" );
453}
454
456{
457 QStringList strList = QgsFrameGraphUtils::dumpSceneGraph( mRootEntity, QgsFrameGraphUtils::FgDumpContext() );
458 return strList.join( "\n" ) + QString( "\n" );
459}
460
461void QgsFrameGraph::setClearColor( const QColor &clearColor )
462{
463 forwardRenderView().setClearColor( clearColor );
464}
465
470
472{
473 mSize = s;
474 for ( auto it = mRenderViewMap.begin(); it != mRenderViewMap.end(); ++it )
475 {
476 QgsAbstractRenderView *rv = it->second.get();
477 rv->updateWindowResize( mSize.width(), mSize.height() );
478 }
479
480 mRenderCaptureColorTexture->setSize( mSize.width(), mSize.height() );
481 mRenderCaptureDepthTexture->setSize( mSize.width(), mSize.height() );
482 mRenderSurfaceSelector->setExternalRenderTargetSize( mSize );
483}
484
485Qt3DRender::QRenderCapture *QgsFrameGraph::renderCapture()
486{
487 return mRenderCapture;
488}
489
491{
492 if ( enabled == mRenderCaptureEnabled )
493 return;
494 mRenderCaptureEnabled = enabled;
495 mRenderCaptureTargetSelector->setEnabled( mRenderCaptureEnabled );
496}
497
502
507
508void QgsFrameGraph::addClipPlanes( int nrClipPlanes )
509{
510 forwardRenderView().addClipPlanes( nrClipPlanes );
511}
512
514{
516 return *( dynamic_cast<QgsForwardRenderView *>( rv ) );
517}
518
520{
522 return *( dynamic_cast<QgsShadowRenderView *>( rv ) );
523}
524
526{
527 QgsAbstractRenderView *rv = mRenderViewMap[QgsFrameGraph::DEPTH_RENDERVIEW].get();
528 return *( dynamic_cast<QgsDepthRenderView *>( rv ) );
529}
530
@ Directional
Directional light source.
Definition of the world.
Qt::Corner debugDepthMapCorner() const
Returns the corner where the shadow map preview is displayed.
bool debugDepthMapEnabled() const
Returns whether the shadow map debugging is enabled.
double eyeDomeLightingStrength() const
Returns the eye dome lighting strength value.
Qt::Corner debugShadowMapCorner() const
Returns the corner where the shadow map preview is displayed.
double debugDepthMapSize() const
Returns the size of the shadow map preview.
int eyeDomeLightingDistance() const
Returns the eye dome lighting distance value (contributes to the contrast of the image)
double debugShadowMapSize() const
Returns the size of the shadow map preview.
bool debugShadowMapEnabled() const
Returns whether the shadow map debugging is enabled.
bool eyeDomeLightingEnabled() const
Returns whether eye dome lighting is used.
Base class for 3D render view.
virtual void setEnabled(bool enable)
Enable or disable via enable the render view sub tree.
virtual void updateWindowResize(int width, int height)
Called when 3D window is resized.
Container class that holds different objects related to ambient occlusion rendering.
void setRadius(float radius)
Delegates to QgsAmbientOcclusionRenderEntity::setRadius.
virtual void setEnabled(bool enable) override
Enable or disable via enable the render view sub tree.
void setIntensity(float intensity)
Delegates to QgsAmbientOcclusionRenderEntity::setIntensity.
void setThreshold(float threshold)
Delegates to QgsAmbientOcclusionRenderEntity::setThreshold.
Contains the configuration of ambient occlusion rendering.
float radius() const
Returns the radius parameter of the ambient occlusion effect.
bool isEnabled() const
Returns whether ambient occlusion effect is enabled.
float intensity() const
Returns the shading factor of the ambient occlusion effect.
float threshold() const
Returns at what amount of occlusion the effect will kick in.
An entity that is responsible for debugging texture.
void setPosition(Qt::Corner corner, double size)
Sets the texture debugging parameters.
Simple renderview to preview/debug textures.
Qt3DRender::QLayer * debugLayer() const
Returns layer in which entities must be added in the in order to be processed by this renderview.
Container class that holds different objects related to depth rendering.
Qt3DRender::QRenderCapture * renderCapture()
Returns the render capture object used to take an image of the depth buffer of the scene.
Definition of a directional light in a 3D map scene.
Container class that holds different objects related to forward rendering.
void setClearColor(const QColor &clearColor)
Sets the clear color of the scene (background color)
void setDebugOverlayEnabled(bool enabled)
Sets whether debug overlay is enabled.
void setFrustumCullingEnabled(bool enabled)
Sets whether frustum culling is enabled.
Qt3DRender::QTexture2D * depthTexture() const
Returns forward depth texture.
void addClipPlanes(int nrClipPlanes)
Setups nrClipPlanes clip planes in the forward pass to enable OpenGL clipping.
void removeClipPlanes()
Disables OpenGL clipping.
static QStringList dumpFrameGraph(const Qt3DCore::QNode *node, FgDumpContext context)
Returns a tree view of the frame graph starting from node. The object ids will be given relatively to...
static QStringList dumpSceneGraph(const Qt3DCore::QNode *node, FgDumpContext context)
Returns a tree view of the scene graph starting from node. The object ids will be given relatively to...
void updateAmbientOcclusionSettings(const QgsAmbientOcclusionSettings &settings)
Updates settings for ambient occlusion.
void updateEyeDomeSettings(const Qgs3DMapSettings &settings)
Updates settings for eye dome lighting.
bool isRenderViewEnabled(const QString &name)
Returns true if the render view named name is found and enabled.
void setRenderViewEnabled(const QString &name, bool enable)
Enables or disables the render view named name according to enable.
void updateShadowSettings(const QgsShadowSettings &shadowSettings, const QList< QgsLightSource * > &lightSources)
Updates shadow bias, light and texture size according to shadowSettings and lightSources.
void addClipPlanes(int nrClipPlanes)
Setups nrClipPlanes clip planes in the forward pass to enable OpenGL clipping.
void unregisterRenderView(const QString &name)
Unregisters the render view named name, if any.
bool registerRenderView(std::unique_ptr< QgsAbstractRenderView > renderView, const QString &name, Qt3DRender::QFrameGraphNode *topNode=nullptr)
Registers a new the render view renderView with name name.
QString dumpFrameGraph() const
Dumps frame graph as string.
void setRenderCaptureEnabled(bool enabled)
Sets whether it will be possible to render to an image.
QgsAmbientOcclusionRenderView & ambientOcclusionRenderView()
Returns ambient occlusion renderview.
Qt3DRender::QRenderCapture * depthRenderCapture()
Returns the render capture object used to take an image of the depth buffer of the scene.
void updateDebugShadowMapSettings(const Qgs3DMapSettings &settings)
Updates settings for shadows debug map.
QgsAbstractRenderView * renderView(const QString &name)
Returns the render view named name, if any.
void removeClipPlanes()
Disables OpenGL clipping.
static const QString AMBIENT_OCCLUSION_RENDERVIEW
Ambient occlusion render view name.
QgsDepthRenderView & depthRenderView()
Returns depth renderview.
void setClearColor(const QColor &clearColor)
Sets the clear color of the scene (background color)
static const QString FORWARD_RENDERVIEW
void setFrustumCullingEnabled(bool enabled)
Sets whether frustum culling is enabled.
static const QString SHADOW_RENDERVIEW
void setDebugOverlayEnabled(bool enabled)
Sets whether debug overlay is enabled.
void updateDebugDepthMapSettings(const Qgs3DMapSettings &settings)
Updates settings for depth debug map.
static const QString AXIS3D_RENDERVIEW
QgsForwardRenderView & forwardRenderView()
Returns forward renderview.
QString dumpSceneGraph() const
Dumps scene graph as string.
QgsShadowRenderView & shadowRenderView()
Returns shadow renderview.
static const QString DEBUG_RENDERVIEW
void setSize(QSize s)
Sets the size of the buffers used for rendering.
static const QString DEPTH_RENDERVIEW
Qt3DRender::QCamera * mainCamera()
Returns the main camera.
QgsFrameGraph(QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root)
Constructor.
Qt3DRender::QRenderCapture * renderCapture()
Returns the render capture object used to take an image of the scene.
An entity that is responsible for applying post processing effects.
void setAmbientOcclusionEnabled(bool enabled)
Sets whether screen space ambient occlusion is enabled.
void setShadowRenderingEnabled(bool enabled)
Sets whether shadow rendering is enabled.
void updateShadowSettings(const QgsDirectionalLightSettings &light, float maximumShadowRenderingDistance)
Sets shadow rendering to use a directional light.
void setEyeDomeLightingDistance(int distance)
Sets the eye dome lighting distance (contributes to the contrast of the image)
void setShadowBias(float shadowBias)
Sets the shadow bias value.
void setEyeDomeLightingStrength(double strength)
Sets the eye dome lighting strength.
void setEyeDomeLightingEnabled(bool enabled)
Sets whether eye dome lighting is enabled.
Container class that holds different objects related to shadow rendering.
void setMapSize(int width, int height)
Update shadow depth texture size.
virtual void setEnabled(bool enable) override
Enable or disable via enable the renderview sub tree.
Qt3DRender::QTexture2D * mapTexture() const
Returns shadow depth texture.
Contains configuration for rendering shadows.
int selectedDirectionalLight() const
Returns the selected direcctional light used to cast shadows.
bool renderShadows() const
Returns whether shadow rendering is enabled.
int shadowMapResolution() const
Returns the resolution of the shadow map texture used to generate the shadows.
double maximumShadowRenderingDistance() const
Returns the maximum shadow rendering distance accounted for when rendering shadows Objects further aw...
double shadowBias() const
Returns the shadow bias used to correct the numerical imprecision of shadows (for the depth test) Thi...
Qt3DCore::QAttribute Qt3DQAttribute
Qt3DCore::QBuffer Qt3DQBuffer
Qt3DCore::QGeometry Qt3DQGeometry