QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
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
18#include "qgs3dutils.h"
23#include "qgsdepthentity.h"
24#include "qgsdepthrenderview.h"
27#include "qgsframegraphutils.h"
29#include "qgsshadowrenderview.h"
30
31#include <Qt3DCore/QAttribute>
32#include <Qt3DCore/QBuffer>
33#include <Qt3DCore/QGeometry>
34#include <Qt3DRender/QAbstractTexture>
35#include <Qt3DRender/QBlendEquation>
36#include <Qt3DRender/QBlendEquationArguments>
37#include <Qt3DRender/QColorMask>
38#include <Qt3DRender/QGeometryRenderer>
39#include <Qt3DRender/QGraphicsApiFilter>
40#include <Qt3DRender/QNoDepthMask>
41#include <Qt3DRender/QNoDraw>
42#include <Qt3DRender/QSortPolicy>
43#include <Qt3DRender/QTechnique>
44
45#include "moc_qgsframegraph.cpp"
46
47const QString QgsFrameGraph::FORWARD_RENDERVIEW = "forward";
48const QString QgsFrameGraph::SHADOW_RENDERVIEW = "shadow";
49const QString QgsFrameGraph::AXIS3D_RENDERVIEW = "3daxis";
50const QString QgsFrameGraph::DEPTH_RENDERVIEW = "depth";
51const QString QgsFrameGraph::DEBUG_RENDERVIEW = "debug_texture";
52const QString QgsFrameGraph::AMBIENT_OCCLUSION_RENDERVIEW = "ambient_occlusion";
53
54void QgsFrameGraph::constructForwardRenderPass()
55{
56 registerRenderView( std::make_unique<QgsForwardRenderView>( FORWARD_RENDERVIEW, mMainCamera ), FORWARD_RENDERVIEW );
57}
58
59void QgsFrameGraph::constructShadowRenderPass()
60{
61 registerRenderView( std::make_unique<QgsShadowRenderView>( SHADOW_RENDERVIEW ), SHADOW_RENDERVIEW );
62}
63
64void QgsFrameGraph::constructDebugTexturePass( Qt3DRender::QFrameGraphNode *topNode )
65{
66 registerRenderView( std::make_unique<QgsDebugTextureRenderView>( DEBUG_RENDERVIEW ), DEBUG_RENDERVIEW, topNode );
67}
68
69Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructSubPostPassForProcessing()
70{
71 Qt3DRender::QCameraSelector *cameraSelector = new Qt3DRender::QCameraSelector;
72 cameraSelector->setObjectName( "Sub pass Postprocessing" );
73 cameraSelector->setCamera( shadowRenderView().lightCamera() );
74
75 Qt3DRender::QLayerFilter *layerFilter = new Qt3DRender::QLayerFilter( cameraSelector );
76
77 // could be the first of this branch
78 new Qt3DRender::QClearBuffers( layerFilter );
79
80 Qt3DRender::QLayer *postProcessingLayer = new Qt3DRender::QLayer();
81 mPostprocessingEntity = new QgsPostprocessingEntity( this, postProcessingLayer, mRootEntity );
82 layerFilter->addLayer( postProcessingLayer );
83 mPostprocessingEntity->setObjectName( "PostProcessingPassEntity" );
84
85 return cameraSelector;
86}
87
88Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructSubPostPassForRenderCapture()
89{
90 Qt3DRender::QFrameGraphNode *top = new Qt3DRender::QNoDraw;
91 top->setObjectName( "Sub pass RenderCapture" );
92
93 mRenderCapture = new Qt3DRender::QRenderCapture( top );
94
95 return top;
96}
97
98Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructPostprocessingPass()
99{
100 mRenderCaptureTargetSelector = new Qt3DRender::QRenderTargetSelector;
101 mRenderCaptureTargetSelector->setObjectName( "Postprocessing render pass" );
102 mRenderCaptureTargetSelector->setEnabled( mRenderCaptureEnabled );
103
104 Qt3DRender::QRenderTarget *renderTarget = new Qt3DRender::QRenderTarget( mRenderCaptureTargetSelector );
105
106 // The lifetime of the objects created here is managed
107 // automatically, as they become children of this object.
108
109 // Create a render target output for rendering color.
110 Qt3DRender::QRenderTargetOutput *colorOutput = new Qt3DRender::QRenderTargetOutput( renderTarget );
111 colorOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Color0 );
112
113 // Create a texture to render into.
114 mRenderCaptureColorTexture = new Qt3DRender::QTexture2D( colorOutput );
115 mRenderCaptureColorTexture->setSize( mSize.width(), mSize.height() );
116 mRenderCaptureColorTexture->setFormat( Qt3DRender::QAbstractTexture::RGB8_UNorm );
117 mRenderCaptureColorTexture->setMinificationFilter( Qt3DRender::QAbstractTexture::Linear );
118 mRenderCaptureColorTexture->setMagnificationFilter( Qt3DRender::QAbstractTexture::Linear );
119 mRenderCaptureColorTexture->setObjectName( "PostProcessingPass::ColorTarget" );
120
121 // Hook the texture up to our output, and the output up to this object.
122 colorOutput->setTexture( mRenderCaptureColorTexture );
123 renderTarget->addOutput( colorOutput );
124
125 Qt3DRender::QRenderTargetOutput *depthOutput = new Qt3DRender::QRenderTargetOutput( renderTarget );
126
127 depthOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Depth );
128 mRenderCaptureDepthTexture = new Qt3DRender::QTexture2D( depthOutput );
129 mRenderCaptureDepthTexture->setSize( mSize.width(), mSize.height() );
130 mRenderCaptureDepthTexture->setFormat( Qt3DRender::QAbstractTexture::DepthFormat );
131 mRenderCaptureDepthTexture->setMinificationFilter( Qt3DRender::QAbstractTexture::Linear );
132 mRenderCaptureDepthTexture->setMagnificationFilter( Qt3DRender::QAbstractTexture::Linear );
133 mRenderCaptureDepthTexture->setComparisonFunction( Qt3DRender::QAbstractTexture::CompareLessEqual );
134 mRenderCaptureDepthTexture->setComparisonMode( Qt3DRender::QAbstractTexture::CompareRefToTexture );
135 mRenderCaptureDepthTexture->setObjectName( "PostProcessingPass::DepthTarget" );
136
137 depthOutput->setTexture( mRenderCaptureDepthTexture );
138 renderTarget->addOutput( depthOutput );
139
140 mRenderCaptureTargetSelector->setTarget( renderTarget );
141
142 // sub passes:
143 constructSubPostPassForProcessing()->setParent( mRenderCaptureTargetSelector );
144 constructDebugTexturePass( mRenderCaptureTargetSelector );
145 constructSubPostPassForRenderCapture()->setParent( mRenderCaptureTargetSelector );
146
147 return mRenderCaptureTargetSelector;
148}
149
150void QgsFrameGraph::constructAmbientOcclusionRenderPass()
151{
152 Qt3DRender::QTexture2D *forwardDepthTexture = forwardRenderView().depthTexture();
153
154 QgsAmbientOcclusionRenderView *aorv = new QgsAmbientOcclusionRenderView( AMBIENT_OCCLUSION_RENDERVIEW, mMainCamera, mSize, forwardDepthTexture, mRootEntity );
155 registerRenderView( std::unique_ptr<QgsAmbientOcclusionRenderView>( aorv ), AMBIENT_OCCLUSION_RENDERVIEW );
156}
157
158Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructRubberBandsPass()
159{
160 mRubberBandsCameraSelector = new Qt3DRender::QCameraSelector;
161 mRubberBandsCameraSelector->setObjectName( "RubberBands Pass CameraSelector" );
162 mRubberBandsCameraSelector->setCamera( mMainCamera );
163
164 mRubberBandsLayerFilter = new Qt3DRender::QLayerFilter( mRubberBandsCameraSelector );
165 mRubberBandsLayerFilter->addLayer( mRubberBandsLayer );
166
167 Qt3DRender::QBlendEquationArguments *blendState = new Qt3DRender::QBlendEquationArguments;
168 blendState->setSourceRgb( Qt3DRender::QBlendEquationArguments::SourceAlpha );
169 blendState->setDestinationRgb( Qt3DRender::QBlendEquationArguments::OneMinusSourceAlpha );
170
171 Qt3DRender::QBlendEquation *blendEquation = new Qt3DRender::QBlendEquation;
172 blendEquation->setBlendFunction( Qt3DRender::QBlendEquation::Add );
173
174 mRubberBandsStateSet = new Qt3DRender::QRenderStateSet( mRubberBandsLayerFilter );
175 Qt3DRender::QDepthTest *depthTest = new Qt3DRender::QDepthTest;
176 depthTest->setDepthFunction( Qt3DRender::QDepthTest::Always );
177 mRubberBandsStateSet->addRenderState( depthTest );
178 mRubberBandsStateSet->addRenderState( blendState );
179 mRubberBandsStateSet->addRenderState( blendEquation );
180
181 // Here we attach our drawings to the render target also used by forward pass.
182 // This is kind of okay, but as a result, post-processing effects get applied
183 // to rubber bands too. Ideally we would want them on top of everything.
184 mRubberBandsRenderTargetSelector = new Qt3DRender::QRenderTargetSelector( mRubberBandsStateSet );
185 mRubberBandsRenderTargetSelector->setTarget( forwardRenderView().renderTargetSelector()->target() );
186
187 return mRubberBandsCameraSelector;
188}
189
190
191void QgsFrameGraph::constructDepthRenderPass()
192{
193 // entity used to draw the depth texture and convert it to rgb image
194 Qt3DRender::QTexture2D *forwardDepthTexture = forwardRenderView().depthTexture();
195 QgsDepthRenderView *rv = new QgsDepthRenderView( DEPTH_RENDERVIEW, mSize, forwardDepthTexture, mRootEntity );
196 registerRenderView( std::unique_ptr<QgsDepthRenderView>( rv ), DEPTH_RENDERVIEW );
197}
198
199Qt3DRender::QRenderCapture *QgsFrameGraph::depthRenderCapture()
200{
202}
203
204QgsFrameGraph::QgsFrameGraph( QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root )
205 : Qt3DCore::QEntity( root )
206 , mSize( s )
207{
208 // general overview of how the frame graph looks:
209 //
210 // +------------------------+ using window or
211 // | QRenderSurfaceSelector | offscreen surface
212 // +------------------------+
213 // |
214 // +-----------+
215 // | QViewport | (0,0,1,1)
216 // +-----------+
217 // |
218 // +--------------------------+-------------------+-----------------+
219 // | | | |
220 // +--------------------+ +--------------+ +-----------------+ +-----------------+
221 // | two forward passes | | shadows pass | | depth buffer | | post-processing |
222 // | (solid objects | | | | processing pass | | passes |
223 // | and transparent) | +--------------+ +-----------------+ +-----------------+
224 // +--------------------+
225 //
226 // Notes:
227 // - depth buffer processing pass is used whenever we need depth map information
228 // (for camera navigation) and it converts depth texture to a color texture
229 // so that we can capture it with QRenderCapture - currently it is unable
230 // to capture depth buffer, only colors (see QTBUG-65155)
231 // - there are multiple post-processing passes that take rendered output
232 // of the scene, optionally apply effects (add shadows, ambient occlusion,
233 // eye dome lighting) and finally output to the given surface
234 // - there may be also two more passes when 3D axis is shown - see Qgs3DAxis
235
236 mRootEntity = root;
237 mMainCamera = mainCamera;
238
239 mRubberBandsLayer = new Qt3DRender::QLayer;
240 mRubberBandsLayer->setObjectName( "mRubberBandsLayer" );
241 mRubberBandsLayer->setRecursive( true );
242
243 mRenderSurfaceSelector = new Qt3DRender::QRenderSurfaceSelector;
244
245 QObject *surfaceObj = dynamic_cast<QObject *>( surface );
246 Q_ASSERT( surfaceObj );
247
248 mRenderSurfaceSelector->setSurface( surfaceObj );
249 mRenderSurfaceSelector->setExternalRenderTargetSize( mSize );
250
251 mMainViewPort = new Qt3DRender::QViewport( mRenderSurfaceSelector );
252 mMainViewPort->setNormalizedRect( QRectF( 0.0f, 0.0f, 1.0f, 1.0f ) );
253
254 // Forward render
255 constructForwardRenderPass();
256
257 // rubber bands (they should be always on top)
258 Qt3DRender::QFrameGraphNode *rubberBandsPass = constructRubberBandsPass();
259 rubberBandsPass->setObjectName( "rubberBandsPass" );
260 rubberBandsPass->setParent( mMainViewPort );
261
262 // shadow rendering pass
263 constructShadowRenderPass();
264
265 // depth buffer processing
266 constructDepthRenderPass();
267
268 // Ambient occlusion factor render pass
269 constructAmbientOcclusionRenderPass();
270
271 // post process
272 Qt3DRender::QFrameGraphNode *postprocessingPass = constructPostprocessingPass();
273 postprocessingPass->setParent( mMainViewPort );
274 postprocessingPass->setObjectName( "PostProcessingPass" );
275
276 mRubberBandsRootEntity = new Qt3DCore::QEntity( mRootEntity );
277 mRubberBandsRootEntity->setObjectName( "mRubberBandsRootEntity" );
278 mRubberBandsRootEntity->addComponent( mRubberBandsLayer );
279}
280
281void QgsFrameGraph::unregisterRenderView( const QString &name )
282{
283 if ( mRenderViewMap.find( name ) != mRenderViewMap.end() )
284 {
285 mRenderViewMap[name]->topGraphNode()->setParent( ( QNode * ) nullptr );
286 mRenderViewMap.erase( name );
287 }
288}
289
290bool QgsFrameGraph::registerRenderView( std::unique_ptr<QgsAbstractRenderView> renderView, const QString &name, Qt3DRender::QFrameGraphNode *topNode )
291{
292 bool out;
293 if ( mRenderViewMap.find( name ) == mRenderViewMap.end() )
294 {
295 mRenderViewMap[name] = std::move( renderView );
296 mRenderViewMap[name]->topGraphNode()->setParent( topNode ? topNode : mMainViewPort );
297 mRenderViewMap[name]->updateWindowResize( mSize.width(), mSize.height() );
298 out = true;
299 }
300 else
301 out = false;
302
303 return out;
304}
305
306void QgsFrameGraph::setRenderViewEnabled( const QString &name, bool enable )
307{
308 if ( mRenderViewMap[name] )
309 {
310 mRenderViewMap[name]->setEnabled( enable );
311 }
312}
313
315{
316 if ( mRenderViewMap.find( name ) != mRenderViewMap.end() )
317 {
318 return mRenderViewMap[name].get();
319 }
320 return nullptr;
321}
322
323bool QgsFrameGraph::isRenderViewEnabled( const QString &name )
324{
325 return mRenderViewMap[name] != nullptr && mRenderViewMap[name]->isEnabled();
326}
327
329{
331
332 aoRenderView.setRadius( settings.radius() );
333 aoRenderView.setIntensity( settings.intensity() );
334 aoRenderView.setThreshold( settings.threshold() );
335 aoRenderView.setEnabled( settings.isEnabled() );
336
337 mPostprocessingEntity->setAmbientOcclusionEnabled( settings.isEnabled() );
338}
339
341{
342 mPostprocessingEntity->setEyeDomeLightingEnabled( settings.eyeDomeLightingEnabled() );
343 mPostprocessingEntity->setEyeDomeLightingStrength( settings.eyeDomeLightingStrength() );
344 mPostprocessingEntity->setEyeDomeLightingDistance( settings.eyeDomeLightingDistance() );
345}
346
347void QgsFrameGraph::updateShadowSettings( const QgsShadowSettings &shadowSettings, const QList<QgsLightSource *> &lightSources )
348{
349 if ( shadowSettings.renderShadows() )
350 {
351 int selectedLight = shadowSettings.selectedDirectionalLight();
352 QgsDirectionalLightSettings *light = nullptr;
353 for ( int i = 0, dirLight = 0; !light && i < lightSources.size(); i++ )
354 {
355 if ( lightSources[i]->type() == Qgis::LightSourceType::Directional )
356 {
357 if ( dirLight == selectedLight )
358 light = qgis::down_cast< QgsDirectionalLightSettings * >( lightSources[i] );
359 dirLight++;
360 }
361 }
362
363 if ( light )
364 {
365 shadowRenderView().setMapSize( shadowSettings.shadowMapResolution(), shadowSettings.shadowMapResolution() );
367 mPostprocessingEntity->setShadowRenderingEnabled( true );
368 mPostprocessingEntity->setShadowBias( static_cast<float>( shadowSettings.shadowBias() ) );
369 mPostprocessingEntity->updateShadowSettings( *light, static_cast<float>( shadowSettings.maximumShadowRenderingDistance() ) );
370 }
371 }
372 else
373 {
374 shadowRenderView().setEnabled( false );
375 mPostprocessingEntity->setShadowRenderingEnabled( false );
376 }
377}
378
380{
381 QgsDebugTextureRenderView *debugRenderView = dynamic_cast<QgsDebugTextureRenderView *>( mRenderViewMap[DEBUG_RENDERVIEW].get() );
382 if ( !debugRenderView )
383 return;
384
385 if ( !mShadowTextureDebugging && settings.debugShadowMapEnabled() )
386 {
387 Qt3DRender::QTexture2D *shadowDepthTexture = shadowRenderView().mapTexture();
388 mShadowTextureDebugging = new QgsDebugTextureEntity( shadowDepthTexture, debugRenderView->debugLayer(), this );
389 }
390
391 debugRenderView->setEnabled( settings.debugShadowMapEnabled() || settings.debugDepthMapEnabled() );
392
393 if ( mShadowTextureDebugging )
394 {
395 mShadowTextureDebugging->setEnabled( settings.debugShadowMapEnabled() );
396 if ( settings.debugShadowMapEnabled() )
397 mShadowTextureDebugging->setPosition( settings.debugShadowMapCorner(), settings.debugShadowMapSize() );
398 else
399 {
400 delete mShadowTextureDebugging;
401 mShadowTextureDebugging = nullptr;
402 }
403 }
404}
405
407{
408 QgsDebugTextureRenderView *debugRenderView = dynamic_cast<QgsDebugTextureRenderView *>( mRenderViewMap[DEBUG_RENDERVIEW].get() );
409 if ( !debugRenderView )
410 return;
411
412 if ( !mDepthTextureDebugging && settings.debugDepthMapEnabled() )
413 {
414 Qt3DRender::QTexture2D *forwardDepthTexture = forwardRenderView().depthTexture();
415 mDepthTextureDebugging = new QgsDebugTextureEntity( forwardDepthTexture, debugRenderView->debugLayer(), this );
416 }
417
418 debugRenderView->setEnabled( settings.debugShadowMapEnabled() || settings.debugDepthMapEnabled() );
419
420 if ( mDepthTextureDebugging )
421 {
422 mDepthTextureDebugging->setEnabled( settings.debugDepthMapEnabled() );
423 if ( settings.debugDepthMapEnabled() )
424 mDepthTextureDebugging->setPosition( settings.debugDepthMapCorner(), settings.debugDepthMapSize() );
425 else
426 {
427 delete mDepthTextureDebugging;
428 mDepthTextureDebugging = nullptr;
429 }
430 }
431}
432
434{
435 QObject *top = mRenderSurfaceSelector;
436 while ( top->parent() && dynamic_cast<Qt3DRender::QFrameGraphNode *>( top->parent() ) )
437 top = top->parent();
438
440 context.lowestId = mMainCamera->id().id();
441 QStringList strList = QgsFrameGraphUtils::dumpFrameGraph( dynamic_cast<Qt3DRender::QFrameGraphNode *>( top ), context );
442
443 return strList.join( "\n" ) + QString( "\n" );
444}
445
447{
448 QStringList strList = QgsFrameGraphUtils::dumpSceneGraph( mRootEntity, QgsFrameGraphUtils::FgDumpContext() );
449 return strList.join( "\n" ) + QString( "\n" );
450}
451
452void QgsFrameGraph::setClearColor( const QColor &clearColor )
453{
454 forwardRenderView().setClearColor( clearColor );
455}
456
461
463{
464 mSize = s;
465 for ( auto it = mRenderViewMap.begin(); it != mRenderViewMap.end(); ++it )
466 {
467 QgsAbstractRenderView *rv = it->second.get();
468 rv->updateWindowResize( mSize.width(), mSize.height() );
469 }
470
471 mRenderCaptureColorTexture->setSize( mSize.width(), mSize.height() );
472 mRenderCaptureDepthTexture->setSize( mSize.width(), mSize.height() );
473 mRenderSurfaceSelector->setExternalRenderTargetSize( mSize );
474}
475
476Qt3DRender::QRenderCapture *QgsFrameGraph::renderCapture()
477{
478 return mRenderCapture;
479}
480
482{
483 if ( enabled == mRenderCaptureEnabled )
484 return;
485 mRenderCaptureEnabled = enabled;
486 mRenderCaptureTargetSelector->setEnabled( mRenderCaptureEnabled );
487}
488
493
498
499void QgsFrameGraph::addClipPlanes( int nrClipPlanes )
500{
501 forwardRenderView().addClipPlanes( nrClipPlanes );
502}
503
505{
507 return *( dynamic_cast<QgsForwardRenderView *>( rv ) );
508}
509
511{
513 return *( dynamic_cast<QgsShadowRenderView *>( rv ) );
514}
515
517{
518 QgsAbstractRenderView *rv = mRenderViewMap[QgsFrameGraph::DEPTH_RENDERVIEW].get();
519 return *( dynamic_cast<QgsDepthRenderView *>( rv ) );
520}
521
@ Directional
Directional light source.
Definition qgis.h:4204
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 bool isEnabled() const
Returns true if render view is enabled.
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.
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.
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.
Container class that holds different objects related to shadow rendering.
void setMapSize(int width, int height)
Update shadow depth texture size.
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...