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