17#include "moc_qgsframegraph.cpp"
25#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
26#include <Qt3DRender/QAttribute>
27#include <Qt3DRender/QBuffer>
28#include <Qt3DRender/QGeometry>
34#include <Qt3DCore/QAttribute>
35#include <Qt3DCore/QBuffer>
36#include <Qt3DCore/QGeometry>
43#include <Qt3DRender/QGeometryRenderer>
44#include <Qt3DRender/QTechnique>
45#include <Qt3DRender/QGraphicsApiFilter>
46#include <Qt3DRender/QBlendEquation>
47#include <Qt3DRender/QColorMask>
48#include <Qt3DRender/QSortPolicy>
49#include <Qt3DRender/QPointSize>
50#include <Qt3DRender/QSeamlessCubemap>
51#include <Qt3DRender/QNoDepthMask>
52#include <Qt3DRender/QBlendEquationArguments>
53#include <Qt3DExtras/QTextureMaterial>
54#include <Qt3DRender/QAbstractTexture>
56#include <Qt3DRender/QNoDraw>
57#include <Qt3DRender/QClipPlane>
59Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructForwardRenderPass()
100 mMainCameraSelector =
new Qt3DRender::QCameraSelector;
101 mMainCameraSelector->setObjectName(
"Forward render pass CameraSelector" );
102 mMainCameraSelector->setCamera( mMainCamera );
104 mForwardRenderLayerFilter =
new Qt3DRender::QLayerFilter( mMainCameraSelector );
105 mForwardRenderLayerFilter->addLayer( mForwardRenderLayer );
107 mClipRenderStateSet =
new Qt3DRender::QRenderStateSet( mForwardRenderLayerFilter );
108 mClipRenderStateSet->setObjectName(
"Forward render pass Clip Plane RenderStateSet" );
110 mForwardColorTexture =
new Qt3DRender::QTexture2D;
111 mForwardColorTexture->setWidth( mSize.width() );
112 mForwardColorTexture->setHeight( mSize.height() );
113 mForwardColorTexture->setFormat( Qt3DRender::QAbstractTexture::RGB8_UNorm );
114 mForwardColorTexture->setGenerateMipMaps(
false );
115 mForwardColorTexture->setMagnificationFilter( Qt3DRender::QTexture2D::Linear );
116 mForwardColorTexture->setMinificationFilter( Qt3DRender::QTexture2D::Linear );
117 mForwardColorTexture->wrapMode()->setX( Qt3DRender::QTextureWrapMode::ClampToEdge );
118 mForwardColorTexture->wrapMode()->setY( Qt3DRender::QTextureWrapMode::ClampToEdge );
120 mForwardDepthTexture =
new Qt3DRender::QTexture2D;
121 mForwardDepthTexture->setWidth( mSize.width() );
122 mForwardDepthTexture->setHeight( mSize.height() );
123 mForwardDepthTexture->setFormat( Qt3DRender::QTexture2D::TextureFormat::DepthFormat );
124 mForwardDepthTexture->setGenerateMipMaps(
false );
125 mForwardDepthTexture->setMagnificationFilter( Qt3DRender::QTexture2D::Linear );
126 mForwardDepthTexture->setMinificationFilter( Qt3DRender::QTexture2D::Linear );
127 mForwardDepthTexture->wrapMode()->setX( Qt3DRender::QTextureWrapMode::ClampToEdge );
128 mForwardDepthTexture->wrapMode()->setY( Qt3DRender::QTextureWrapMode::ClampToEdge );
130 Qt3DRender::QRenderTarget *forwardRenderTarget =
new Qt3DRender::QRenderTarget;
131 Qt3DRender::QRenderTargetOutput *forwardRenderTargetDepthOutput =
new Qt3DRender::QRenderTargetOutput;
132 forwardRenderTargetDepthOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Depth );
133 forwardRenderTargetDepthOutput->setTexture( mForwardDepthTexture );
134 forwardRenderTarget->addOutput( forwardRenderTargetDepthOutput );
135 Qt3DRender::QRenderTargetOutput *forwardRenderTargetColorOutput =
new Qt3DRender::QRenderTargetOutput;
136 forwardRenderTargetColorOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Color0 );
137 forwardRenderTargetColorOutput->setTexture( mForwardColorTexture );
138 forwardRenderTarget->addOutput( forwardRenderTargetColorOutput );
140 mForwardRenderTargetSelector =
new Qt3DRender::QRenderTargetSelector( mClipRenderStateSet );
141 mForwardRenderTargetSelector->setTarget( forwardRenderTarget );
144 Qt3DRender::QLayerFilter *opaqueObjectsFilter =
new Qt3DRender::QLayerFilter( mForwardRenderTargetSelector );
145 opaqueObjectsFilter->addLayer( mTransparentObjectsPassLayer );
146 opaqueObjectsFilter->setFilterMode( Qt3DRender::QLayerFilter::DiscardAnyMatchingLayers );
148 Qt3DRender::QRenderStateSet *forwardedRenderStateSet =
new Qt3DRender::QRenderStateSet( opaqueObjectsFilter );
150 Qt3DRender::QDepthTest *depthTest =
new Qt3DRender::QDepthTest;
151 depthTest->setDepthFunction( Qt3DRender::QDepthTest::Less );
152 forwardedRenderStateSet->addRenderState( depthTest );
154 Qt3DRender::QCullFace *cullFace =
new Qt3DRender::QCullFace;
155 cullFace->setMode( Qt3DRender::QCullFace::CullingMode::Back );
156 forwardedRenderStateSet->addRenderState( cullFace );
158 mFrustumCulling =
new Qt3DRender::QFrustumCulling( forwardedRenderStateSet );
160 mForwardClearBuffers =
new Qt3DRender::QClearBuffers( mFrustumCulling );
161 mForwardClearBuffers->setClearColor( QColor::fromRgbF( 0.0, 0.0, 1.0, 1.0 ) );
162 mForwardClearBuffers->setBuffers( Qt3DRender::QClearBuffers::ColorDepthBuffer );
163 mForwardClearBuffers->setClearDepthValue( 1.0f );
166 Qt3DRender::QLayerFilter *transparentObjectsLayerFilter =
new Qt3DRender::QLayerFilter( mForwardRenderTargetSelector );
167 transparentObjectsLayerFilter->addLayer( mTransparentObjectsPassLayer );
168 transparentObjectsLayerFilter->setFilterMode( Qt3DRender::QLayerFilter::AcceptAnyMatchingLayers );
170 Qt3DRender::QSortPolicy *sortPolicy =
new Qt3DRender::QSortPolicy( transparentObjectsLayerFilter );
171 QVector<Qt3DRender::QSortPolicy::SortType> sortTypes;
172 sortTypes.push_back( Qt3DRender::QSortPolicy::BackToFront );
173 sortPolicy->setSortTypes( sortTypes );
175 Qt3DRender::QRenderStateSet *transparentObjectsRenderStateSetColor =
new Qt3DRender::QRenderStateSet( sortPolicy );
177 Qt3DRender::QDepthTest *depthTest =
new Qt3DRender::QDepthTest;
178 depthTest->setDepthFunction( Qt3DRender::QDepthTest::Less );
179 transparentObjectsRenderStateSetColor->addRenderState( depthTest );
181 Qt3DRender::QNoDepthMask *noDepthMask =
new Qt3DRender::QNoDepthMask;
182 transparentObjectsRenderStateSetColor->addRenderState( noDepthMask );
184 Qt3DRender::QCullFace *cullFace =
new Qt3DRender::QCullFace;
185 cullFace->setMode( Qt3DRender::QCullFace::CullingMode::NoCulling );
186 transparentObjectsRenderStateSetColor->addRenderState( cullFace );
188 Qt3DRender::QBlendEquation *blendEquation =
new Qt3DRender::QBlendEquation;
189 blendEquation->setBlendFunction( Qt3DRender::QBlendEquation::Add );
190 transparentObjectsRenderStateSetColor->addRenderState( blendEquation );
192 Qt3DRender::QBlendEquationArguments *blendEquationArgs =
new Qt3DRender::QBlendEquationArguments;
193 blendEquationArgs->setSourceRgb( Qt3DRender::QBlendEquationArguments::Blending::SourceAlpha );
194 blendEquationArgs->setDestinationRgb( Qt3DRender::QBlendEquationArguments::Blending::OneMinusSourceAlpha );
195 transparentObjectsRenderStateSetColor->addRenderState( blendEquationArgs );
199 Qt3DRender::QRenderStateSet *transparentObjectsRenderStateSetDepth =
new Qt3DRender::QRenderStateSet( sortPolicy );
201 Qt3DRender::QDepthTest *depthTest =
new Qt3DRender::QDepthTest;
202 depthTest->setDepthFunction( Qt3DRender::QDepthTest::Less );
203 transparentObjectsRenderStateSetDepth->addRenderState( depthTest );
205 Qt3DRender::QColorMask *noColorMask =
new Qt3DRender::QColorMask;
206 noColorMask->setAlphaMasked(
false );
207 noColorMask->setRedMasked(
false );
208 noColorMask->setGreenMasked(
false );
209 noColorMask->setBlueMasked(
false );
210 transparentObjectsRenderStateSetDepth->addRenderState( noColorMask );
212 Qt3DRender::QCullFace *cullFace =
new Qt3DRender::QCullFace;
213 cullFace->setMode( Qt3DRender::QCullFace::CullingMode::NoCulling );
214 transparentObjectsRenderStateSetDepth->addRenderState( cullFace );
217 mDebugOverlay =
new Qt3DRender::QDebugOverlay( mForwardClearBuffers );
218 mDebugOverlay->setEnabled(
false );
222 return mMainCameraSelector;
225Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructShadowRenderPass()
227 mLightCameraSelectorShadowPass =
new Qt3DRender::QCameraSelector;
228 mLightCameraSelectorShadowPass->setObjectName(
"Shadow render pass CameraSelector" );
229 mLightCameraSelectorShadowPass->setCamera( mLightCamera );
231 mShadowSceneEntitiesFilter =
new Qt3DRender::QLayerFilter( mLightCameraSelectorShadowPass );
232 mShadowSceneEntitiesFilter->addLayer( mCastShadowsLayer );
234 mShadowMapTexture =
new Qt3DRender::QTexture2D;
235 mShadowMapTexture->setWidth( mShadowMapResolution );
236 mShadowMapTexture->setHeight( mShadowMapResolution );
237 mShadowMapTexture->setFormat( Qt3DRender::QTexture2D::TextureFormat::DepthFormat );
238 mShadowMapTexture->setGenerateMipMaps(
false );
239 mShadowMapTexture->setMagnificationFilter( Qt3DRender::QTexture2D::Linear );
240 mShadowMapTexture->setMinificationFilter( Qt3DRender::QTexture2D::Linear );
241 mShadowMapTexture->wrapMode()->setX( Qt3DRender::QTextureWrapMode::ClampToEdge );
242 mShadowMapTexture->wrapMode()->setY( Qt3DRender::QTextureWrapMode::ClampToEdge );
244 Qt3DRender::QRenderTarget *shadowRenderTarget =
new Qt3DRender::QRenderTarget;
245 Qt3DRender::QRenderTargetOutput *shadowRenderTargetOutput =
new Qt3DRender::QRenderTargetOutput;
246 shadowRenderTargetOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Depth );
247 shadowRenderTargetOutput->setTexture( mShadowMapTexture );
248 shadowRenderTarget->addOutput( shadowRenderTargetOutput );
250 mShadowRenderTargetSelector =
new Qt3DRender::QRenderTargetSelector( mShadowSceneEntitiesFilter );
251 mShadowRenderTargetSelector->setTarget( shadowRenderTarget );
253 mShadowClearBuffers =
new Qt3DRender::QClearBuffers( mShadowRenderTargetSelector );
254 mShadowClearBuffers->setBuffers( Qt3DRender::QClearBuffers::BufferType::ColorDepthBuffer );
255 mShadowClearBuffers->setClearColor( QColor::fromRgbF( 0.0f, 1.0f, 0.0f ) );
257 mShadowRenderStateSet =
new Qt3DRender::QRenderStateSet( mShadowClearBuffers );
259 Qt3DRender::QDepthTest *shadowDepthTest =
new Qt3DRender::QDepthTest;
260 shadowDepthTest->setDepthFunction( Qt3DRender::QDepthTest::Less );
261 mShadowRenderStateSet->addRenderState( shadowDepthTest );
263 Qt3DRender::QCullFace *shadowCullFace =
new Qt3DRender::QCullFace;
264 shadowCullFace->setMode( Qt3DRender::QCullFace::CullingMode::Front );
265 mShadowRenderStateSet->addRenderState( shadowCullFace );
267 Qt3DRender::QPolygonOffset *polygonOffset =
new Qt3DRender::QPolygonOffset;
268 polygonOffset->setDepthSteps( 4.0 );
269 polygonOffset->setScaleFactor( 1.1 );
270 mShadowRenderStateSet->addRenderState( polygonOffset );
272 return mLightCameraSelectorShadowPass;
275Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructSubPostPassForTexturesPreview()
277 Qt3DRender::QLayerFilter *layerFilter =
new Qt3DRender::QLayerFilter;
278 layerFilter->setObjectName(
"Sub pass TexturesPreview" );
279 layerFilter->addLayer( mPreviewLayer );
281 Qt3DRender::QRenderStateSet *renderStateSet =
new Qt3DRender::QRenderStateSet( layerFilter );
282 Qt3DRender::QDepthTest *depthTest =
new Qt3DRender::QDepthTest;
283 depthTest->setDepthFunction( Qt3DRender::QDepthTest::Always );
284 renderStateSet->addRenderState( depthTest );
285 Qt3DRender::QCullFace *cullFace =
new Qt3DRender::QCullFace;
286 cullFace->setMode( Qt3DRender::QCullFace::NoCulling );
287 renderStateSet->addRenderState( cullFace );
292Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructSubPostPassForProcessing()
294 Qt3DRender::QCameraSelector *cameraSelector =
new Qt3DRender::QCameraSelector;
295 cameraSelector->setObjectName(
"Sub pass Postprocessing" );
296 cameraSelector->setCamera( mLightCamera );
298 Qt3DRender::QLayerFilter *layerFilter =
new Qt3DRender::QLayerFilter( cameraSelector );
301 new Qt3DRender::QClearBuffers( layerFilter );
303 Qt3DRender::QLayer *postProcessingLayer =
new Qt3DRender::QLayer();
305 layerFilter->addLayer( postProcessingLayer );
306 mPostprocessingEntity->setObjectName(
"PostProcessingPassEntity" );
308 return cameraSelector;
311Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructSubPostPassForRenderCapture()
313 Qt3DRender::QFrameGraphNode *top =
new Qt3DRender::QNoDraw;
314 top->setObjectName(
"Sub pass RenderCapture" );
316 mRenderCapture =
new Qt3DRender::QRenderCapture( top );
321Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructPostprocessingPass()
323 mRenderCaptureTargetSelector =
new Qt3DRender::QRenderTargetSelector;
324 mRenderCaptureTargetSelector->setObjectName(
"Postprocessing render pass" );
325 mRenderCaptureTargetSelector->setEnabled( mRenderCaptureEnabled );
327 Qt3DRender::QRenderTarget *renderTarget =
new Qt3DRender::QRenderTarget( mRenderCaptureTargetSelector );
333 Qt3DRender::QRenderTargetOutput *colorOutput =
new Qt3DRender::QRenderTargetOutput( renderTarget );
334 colorOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Color0 );
337 mRenderCaptureColorTexture =
new Qt3DRender::QTexture2D( colorOutput );
338 mRenderCaptureColorTexture->setSize( mSize.width(), mSize.height() );
339 mRenderCaptureColorTexture->setFormat( Qt3DRender::QAbstractTexture::RGB8_UNorm );
340 mRenderCaptureColorTexture->setMinificationFilter( Qt3DRender::QAbstractTexture::Linear );
341 mRenderCaptureColorTexture->setMagnificationFilter( Qt3DRender::QAbstractTexture::Linear );
342 mRenderCaptureColorTexture->setObjectName(
"PostProcessingPass::ColorTarget" );
345 colorOutput->setTexture( mRenderCaptureColorTexture );
346 renderTarget->addOutput( colorOutput );
348 Qt3DRender::QRenderTargetOutput *depthOutput =
new Qt3DRender::QRenderTargetOutput( renderTarget );
350 depthOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Depth );
351 mRenderCaptureDepthTexture =
new Qt3DRender::QTexture2D( depthOutput );
352 mRenderCaptureDepthTexture->setSize( mSize.width(), mSize.height() );
353 mRenderCaptureDepthTexture->setFormat( Qt3DRender::QAbstractTexture::DepthFormat );
354 mRenderCaptureDepthTexture->setMinificationFilter( Qt3DRender::QAbstractTexture::Linear );
355 mRenderCaptureDepthTexture->setMagnificationFilter( Qt3DRender::QAbstractTexture::Linear );
356 mRenderCaptureDepthTexture->setComparisonFunction( Qt3DRender::QAbstractTexture::CompareLessEqual );
357 mRenderCaptureDepthTexture->setComparisonMode( Qt3DRender::QAbstractTexture::CompareRefToTexture );
358 mRenderCaptureDepthTexture->setObjectName(
"PostProcessingPass::DepthTarget" );
360 depthOutput->setTexture( mRenderCaptureDepthTexture );
361 renderTarget->addOutput( depthOutput );
363 mRenderCaptureTargetSelector->setTarget( renderTarget );
366 constructSubPostPassForProcessing()->setParent( mRenderCaptureTargetSelector );
367 constructSubPostPassForTexturesPreview()->setParent( mRenderCaptureTargetSelector );
368 constructSubPostPassForRenderCapture()->setParent( mRenderCaptureTargetSelector );
370 return mRenderCaptureTargetSelector;
373Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructAmbientOcclusionRenderPass()
375 mAmbientOcclusionRenderCameraSelector =
new Qt3DRender::QCameraSelector;
376 mAmbientOcclusionRenderCameraSelector->setObjectName(
"AmbientOcclusion render pass CameraSelector" );
377 mAmbientOcclusionRenderCameraSelector->setCamera( mMainCamera );
379 mAmbientOcclusionRenderStateSet =
new Qt3DRender::QRenderStateSet( mAmbientOcclusionRenderCameraSelector );
381 Qt3DRender::QDepthTest *depthRenderDepthTest =
new Qt3DRender::QDepthTest;
382 depthRenderDepthTest->setDepthFunction( Qt3DRender::QDepthTest::Always );;
383 Qt3DRender::QCullFace *depthRenderCullFace =
new Qt3DRender::QCullFace;
384 depthRenderCullFace->setMode( Qt3DRender::QCullFace::NoCulling );
386 mAmbientOcclusionRenderStateSet->addRenderState( depthRenderDepthTest );
387 mAmbientOcclusionRenderStateSet->addRenderState( depthRenderCullFace );
389 mAmbientOcclusionRenderLayerFilter =
new Qt3DRender::QLayerFilter( mAmbientOcclusionRenderStateSet );
391 mAmbientOcclusionRenderCaptureTargetSelector =
new Qt3DRender::QRenderTargetSelector( mAmbientOcclusionRenderLayerFilter );
392 Qt3DRender::QRenderTarget *colorRenderTarget =
new Qt3DRender::QRenderTarget( mAmbientOcclusionRenderCaptureTargetSelector );
398 Qt3DRender::QRenderTargetOutput *colorOutput =
new Qt3DRender::QRenderTargetOutput( colorRenderTarget );
399 colorOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Color0 );
402 mAmbientOcclusionRenderTexture =
new Qt3DRender::QTexture2D( colorOutput );
403 mAmbientOcclusionRenderTexture->setSize( mSize.width(), mSize.height() );
404 mAmbientOcclusionRenderTexture->setFormat( Qt3DRender::QAbstractTexture::R32F );
405 mAmbientOcclusionRenderTexture->setMinificationFilter( Qt3DRender::QAbstractTexture::Linear );
406 mAmbientOcclusionRenderTexture->setMagnificationFilter( Qt3DRender::QAbstractTexture::Linear );
409 colorOutput->setTexture( mAmbientOcclusionRenderTexture );
410 colorRenderTarget->addOutput( colorOutput );
412 mAmbientOcclusionRenderCaptureTargetSelector->setTarget( colorRenderTarget );
414 Qt3DRender::QLayer *ambientOcclusionRenderLayer =
new Qt3DRender::QLayer();
416 mAmbientOcclusionRenderLayerFilter->addLayer( ambientOcclusionRenderLayer );
418 return mAmbientOcclusionRenderCameraSelector;
421Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructAmbientOcclusionBlurPass()
423 mAmbientOcclusionBlurCameraSelector =
new Qt3DRender::QCameraSelector;
424 mAmbientOcclusionBlurCameraSelector->setObjectName(
"AmbientOcclusion blur pass CameraSelector" );
425 mAmbientOcclusionBlurCameraSelector->setCamera( mMainCamera );
427 mAmbientOcclusionBlurStateSet =
new Qt3DRender::QRenderStateSet( mAmbientOcclusionBlurCameraSelector );
429 Qt3DRender::QDepthTest *depthRenderDepthTest =
new Qt3DRender::QDepthTest;
430 depthRenderDepthTest->setDepthFunction( Qt3DRender::QDepthTest::Always );;
431 Qt3DRender::QCullFace *depthRenderCullFace =
new Qt3DRender::QCullFace;
432 depthRenderCullFace->setMode( Qt3DRender::QCullFace::NoCulling );
434 mAmbientOcclusionBlurStateSet->addRenderState( depthRenderDepthTest );
435 mAmbientOcclusionBlurStateSet->addRenderState( depthRenderCullFace );
437 mAmbientOcclusionBlurLayerFilter =
new Qt3DRender::QLayerFilter( mAmbientOcclusionBlurStateSet );
439 mAmbientOcclusionBlurRenderCaptureTargetSelector =
new Qt3DRender::QRenderTargetSelector( mAmbientOcclusionBlurLayerFilter );
440 Qt3DRender::QRenderTarget *depthRenderTarget =
new Qt3DRender::QRenderTarget( mAmbientOcclusionBlurRenderCaptureTargetSelector );
446 Qt3DRender::QRenderTargetOutput *colorOutput =
new Qt3DRender::QRenderTargetOutput( depthRenderTarget );
447 colorOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Color0 );
450 mAmbientOcclusionBlurTexture =
new Qt3DRender::QTexture2D( colorOutput );
451 mAmbientOcclusionBlurTexture->setSize( mSize.width(), mSize.height() );
452 mAmbientOcclusionBlurTexture->setFormat( Qt3DRender::QAbstractTexture::R32F );
453 mAmbientOcclusionBlurTexture->setMinificationFilter( Qt3DRender::QAbstractTexture::Linear );
454 mAmbientOcclusionBlurTexture->setMagnificationFilter( Qt3DRender::QAbstractTexture::Linear );
457 colorOutput->setTexture( mAmbientOcclusionBlurTexture );
458 depthRenderTarget->addOutput( colorOutput );
460 mAmbientOcclusionBlurRenderCaptureTargetSelector->setTarget( depthRenderTarget );
462 Qt3DRender::QLayer *ambientOcclusionBlurLayer =
new Qt3DRender::QLayer();
464 mAmbientOcclusionBlurLayerFilter->addLayer( ambientOcclusionBlurLayer );
466 return mAmbientOcclusionBlurCameraSelector;
470Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructRubberBandsPass()
472 mRubberBandsCameraSelector =
new Qt3DRender::QCameraSelector;
473 mRubberBandsCameraSelector->setObjectName(
"RubberBands Pass CameraSelector" );
474 mRubberBandsCameraSelector->setCamera( mMainCamera );
476 mRubberBandsLayerFilter =
new Qt3DRender::QLayerFilter( mRubberBandsCameraSelector );
477 mRubberBandsLayerFilter->addLayer( mRubberBandsLayer );
479 mRubberBandsStateSet =
new Qt3DRender::QRenderStateSet( mRubberBandsLayerFilter );
480 Qt3DRender::QDepthTest *depthTest =
new Qt3DRender::QDepthTest;
481 depthTest->setDepthFunction( Qt3DRender::QDepthTest::Always );
482 mRubberBandsStateSet->addRenderState( depthTest );
487 mRubberBandsRenderTargetSelector =
new Qt3DRender::QRenderTargetSelector( mRubberBandsStateSet );
488 mRubberBandsRenderTargetSelector->setTarget( mForwardRenderTargetSelector->target() );
490 return mRubberBandsCameraSelector;
495Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructDepthRenderPass()
499 mDepthRenderCameraSelector =
new Qt3DRender::QCameraSelector;
500 mDepthRenderCameraSelector->setObjectName(
"Depth render view CameraSelector" );
501 mDepthRenderCameraSelector->setCamera( mMainCamera );
503 mDepthRenderStateSet =
new Qt3DRender::QRenderStateSet( mDepthRenderCameraSelector );
505 Qt3DRender::QDepthTest *depthRenderDepthTest =
new Qt3DRender::QDepthTest;
506 depthRenderDepthTest->setDepthFunction( Qt3DRender::QDepthTest::Always );;
507 Qt3DRender::QCullFace *depthRenderCullFace =
new Qt3DRender::QCullFace;
508 depthRenderCullFace->setMode( Qt3DRender::QCullFace::NoCulling );
510 mDepthRenderStateSet->addRenderState( depthRenderDepthTest );
511 mDepthRenderStateSet->addRenderState( depthRenderCullFace );
513 mDepthRenderLayerFilter =
new Qt3DRender::QLayerFilter( mDepthRenderStateSet );
514 mDepthRenderLayerFilter->addLayer( mDepthRenderPassLayer );
516 mDepthRenderCaptureTargetSelector =
new Qt3DRender::QRenderTargetSelector( mDepthRenderLayerFilter );
517 Qt3DRender::QRenderTarget *depthRenderTarget =
new Qt3DRender::QRenderTarget( mDepthRenderCaptureTargetSelector );
523 Qt3DRender::QRenderTargetOutput *colorOutput =
new Qt3DRender::QRenderTargetOutput( depthRenderTarget );
524 colorOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Color0 );
527 mDepthRenderCaptureColorTexture =
new Qt3DRender::QTexture2D( colorOutput );
528 mDepthRenderCaptureColorTexture->setSize( mSize.width(), mSize.height() );
529 mDepthRenderCaptureColorTexture->setFormat( Qt3DRender::QAbstractTexture::RGB8_UNorm );
530 mDepthRenderCaptureColorTexture->setMinificationFilter( Qt3DRender::QAbstractTexture::Linear );
531 mDepthRenderCaptureColorTexture->setMagnificationFilter( Qt3DRender::QAbstractTexture::Linear );
534 colorOutput->setTexture( mDepthRenderCaptureColorTexture );
535 depthRenderTarget->addOutput( colorOutput );
537 Qt3DRender::QRenderTargetOutput *depthOutput =
new Qt3DRender::QRenderTargetOutput( depthRenderTarget );
539 depthOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Depth );
540 mDepthRenderCaptureDepthTexture =
new Qt3DRender::QTexture2D( depthOutput );
541 mDepthRenderCaptureDepthTexture->setSize( mSize.width(), mSize.height() );
542 mDepthRenderCaptureDepthTexture->setFormat( Qt3DRender::QAbstractTexture::DepthFormat );
543 mDepthRenderCaptureDepthTexture->setMinificationFilter( Qt3DRender::QAbstractTexture::Linear );
544 mDepthRenderCaptureDepthTexture->setMagnificationFilter( Qt3DRender::QAbstractTexture::Linear );
545 mDepthRenderCaptureDepthTexture->setComparisonFunction( Qt3DRender::QAbstractTexture::CompareLessEqual );
546 mDepthRenderCaptureDepthTexture->setComparisonMode( Qt3DRender::QAbstractTexture::CompareRefToTexture );
548 depthOutput->setTexture( mDepthRenderCaptureDepthTexture );
549 depthRenderTarget->addOutput( depthOutput );
551 mDepthRenderCaptureTargetSelector->setTarget( depthRenderTarget );
554 mDepthRenderCapture =
new Qt3DRender::QRenderCapture( mDepthRenderCaptureTargetSelector );
556 return mDepthRenderCameraSelector;
559Qt3DCore::QEntity *QgsFrameGraph::constructDepthRenderQuad()
561 Qt3DCore::QEntity *quad =
new Qt3DCore::QEntity;
562 quad->setObjectName(
"depthRenderQuad" );
566 const QVector<float> vert = { -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
568 const QByteArray vertexArr( (
const char * ) vert.constData(), vert.size() *
sizeof(
float ) );
571 vertexBuffer->setData( vertexArr );
573 positionAttribute->setName( Qt3DQAttribute::defaultPositionAttributeName() );
574 positionAttribute->setVertexBaseType( Qt3DQAttribute::Float );
575 positionAttribute->setVertexSize( 3 );
576 positionAttribute->setAttributeType( Qt3DQAttribute::VertexAttribute );
577 positionAttribute->setBuffer( vertexBuffer );
578 positionAttribute->setByteOffset( 0 );
579 positionAttribute->setByteStride( 3 *
sizeof(
float ) );
580 positionAttribute->setCount( 6 );
582 geom->addAttribute( positionAttribute );
584 Qt3DRender::QGeometryRenderer *renderer =
new Qt3DRender::QGeometryRenderer;
585 renderer->setPrimitiveType( Qt3DRender::QGeometryRenderer::PrimitiveType::Triangles );
586 renderer->setGeometry( geom );
588 quad->addComponent( renderer );
590 QMatrix4x4 modelMatrix;
591 modelMatrix.setToIdentity();
595 Qt3DRender::QMaterial *material =
new Qt3DRender::QMaterial;
596 Qt3DRender::QParameter *textureParameter =
new Qt3DRender::QParameter(
"depthTexture", mForwardDepthTexture );
597 Qt3DRender::QParameter *textureTransformParameter =
new Qt3DRender::QParameter(
"modelMatrix", QVariant::fromValue( modelMatrix ) );
598 material->addParameter( textureParameter );
599 material->addParameter( textureTransformParameter );
601 Qt3DRender::QEffect *effect =
new Qt3DRender::QEffect;
603 Qt3DRender::QTechnique *technique =
new Qt3DRender::QTechnique;
605 Qt3DRender::QGraphicsApiFilter *graphicsApiFilter = technique->graphicsApiFilter();
606 graphicsApiFilter->setApi( Qt3DRender::QGraphicsApiFilter::Api::OpenGL );
607 graphicsApiFilter->setProfile( Qt3DRender::QGraphicsApiFilter::OpenGLProfile::CoreProfile );
608 graphicsApiFilter->setMajorVersion( 1 );
609 graphicsApiFilter->setMinorVersion( 5 );
611 Qt3DRender::QRenderPass *renderPass =
new Qt3DRender::QRenderPass;
613 Qt3DRender::QShaderProgram *shader =
new Qt3DRender::QShaderProgram;
614 shader->setVertexShaderCode( Qt3DRender::QShaderProgram::loadSource( QUrl(
"qrc:/shaders/depth_render.vert" ) ) );
615 shader->setFragmentShaderCode( Qt3DRender::QShaderProgram::loadSource( QUrl(
"qrc:/shaders/depth_render.frag" ) ) );
616 renderPass->setShaderProgram( shader );
618 technique->addRenderPass( renderPass );
620 effect->addTechnique( technique );
621 material->setEffect( effect );
623 quad->addComponent( material );
663 mLightCamera =
new Qt3DRender::QCamera;
665 mPreviewLayer =
new Qt3DRender::QLayer;
666 mCastShadowsLayer =
new Qt3DRender::QLayer;
667 mForwardRenderLayer =
new Qt3DRender::QLayer;
668 mDepthRenderPassLayer =
new Qt3DRender::QLayer;
669 mTransparentObjectsPassLayer =
new Qt3DRender::QLayer;
670 mRubberBandsLayer =
new Qt3DRender::QLayer;
672 mRubberBandsLayer->setObjectName(
"mRubberBandsLayer" );
674 mPreviewLayer->setRecursive(
true );
675 mCastShadowsLayer->setRecursive(
true );
676 mForwardRenderLayer->setRecursive(
true );
677 mDepthRenderPassLayer->setRecursive(
true );
678 mTransparentObjectsPassLayer->setRecursive(
true );
679 mRubberBandsLayer->setRecursive(
true );
681 mRenderSurfaceSelector =
new Qt3DRender::QRenderSurfaceSelector;
683 QObject *surfaceObj =
dynamic_cast< QObject *
>( surface );
684 Q_ASSERT( surfaceObj );
686 mRenderSurfaceSelector->setSurface( surfaceObj );
687 mRenderSurfaceSelector->setExternalRenderTargetSize( mSize );
689 mMainViewPort =
new Qt3DRender::QViewport( mRenderSurfaceSelector );
690 mMainViewPort->setNormalizedRect( QRectF( 0.0f, 0.0f, 1.0f, 1.0f ) );
693 Qt3DRender::QFrameGraphNode *forwardRenderPass = constructForwardRenderPass();
694 forwardRenderPass->setParent( mMainViewPort );
697 Qt3DRender::QFrameGraphNode *rubberBandsPass = constructRubberBandsPass();
698 rubberBandsPass->setObjectName(
"rubberBandsPass" );
699 rubberBandsPass->setParent( mMainViewPort );
702 Qt3DRender::QFrameGraphNode *shadowRenderPass = constructShadowRenderPass();
703 shadowRenderPass->setParent( mMainViewPort );
706 Qt3DRender::QFrameGraphNode *depthBufferProcessingPass = constructDepthRenderPass();
707 depthBufferProcessingPass->setParent( mMainViewPort );
710 Qt3DRender::QFrameGraphNode *ambientOcclusionFactorRender = constructAmbientOcclusionRenderPass();
711 ambientOcclusionFactorRender->setParent( mMainViewPort );
713 Qt3DRender::QFrameGraphNode *ambientOcclusionBlurPass = constructAmbientOcclusionBlurPass();
714 ambientOcclusionBlurPass->setParent( mMainViewPort );
717 Qt3DRender::QFrameGraphNode *postprocessingPass = constructPostprocessingPass();
718 postprocessingPass->setParent( mMainViewPort );
719 postprocessingPass->setObjectName(
"PostProcessingPass" );
721 mRubberBandsRootEntity =
new Qt3DCore::QEntity( mRootEntity );
722 mRubberBandsRootEntity->setObjectName(
"mRubberBandsRootEntity" );
723 mRubberBandsRootEntity->addComponent( mRubberBandsLayer );
725 Qt3DRender::QParameter *depthMapIsDepthParam =
new Qt3DRender::QParameter(
"isDepth",
true );
726 Qt3DRender::QParameter *shadowMapIsDepthParam =
new Qt3DRender::QParameter(
"isDepth",
true );
728 mDebugDepthMapPreviewQuad = this->
addTexturePreviewOverlay( mForwardDepthTexture, QPointF( 0.9f, 0.9f ), QSizeF( 0.1, 0.1 ), QVector<Qt3DRender::QParameter *> { depthMapIsDepthParam } );
729 mDebugShadowMapPreviewQuad = this->
addTexturePreviewOverlay( mShadowMapTexture, QPointF( 0.9f, 0.9f ), QSizeF( 0.1, 0.1 ), QVector<Qt3DRender::QParameter *> { shadowMapIsDepthParam } );
730 mDebugDepthMapPreviewQuad->setEnabled(
false );
731 mDebugShadowMapPreviewQuad->setEnabled(
false );
733 mDepthRenderQuad = constructDepthRenderQuad();
734 mDepthRenderQuad->addComponent( mDepthRenderPassLayer );
735 mDepthRenderQuad->setParent( mRootEntity );
741 previewQuad->addComponent( mPreviewLayer );
742 previewQuad->setParent( mRootEntity );
743 mPreviewQuads.push_back( previewQuad );
748void calculateViewExtent( Qt3DRender::QCamera *camera,
float shadowRenderingDistance,
float z,
float &minX,
float &maxX,
float &minY,
float &maxY,
float &minZ,
float &maxZ )
750 const QVector3D cameraPos = camera->position();
751 const QMatrix4x4 projectionMatrix = camera->projectionMatrix();
752 const QMatrix4x4 viewMatrix = camera->viewMatrix();
754 QVector4D viewCenter = viewMatrix * QVector4D( camera->viewCenter(), 1.0f );
755 viewCenter /= viewCenter.w();
756 viewCenter = projectionMatrix * viewCenter;
757 viewCenter /= viewCenter.w();
758 depth = viewCenter.z();
759 QVector<QVector3D> viewFrustumPoints =
761 QVector3D( 0.0f, 0.0f, depth ),
762 QVector3D( 0.0f, 1.0f, depth ),
763 QVector3D( 1.0f, 0.0f, depth ),
764 QVector3D( 1.0f, 1.0f, depth ),
765 QVector3D( 0.0f, 0.0f, 0 ),
766 QVector3D( 0.0f, 1.0f, 0 ),
767 QVector3D( 1.0f, 0.0f, 0 ),
768 QVector3D( 1.0f, 1.0f, 0 )
770 maxX = std::numeric_limits<float>::lowest();
771 maxY = std::numeric_limits<float>::lowest();
772 maxZ = std::numeric_limits<float>::lowest();
773 minX = std::numeric_limits<float>::max();
774 minY = std::numeric_limits<float>::max();
775 minZ = std::numeric_limits<float>::max();
776 for (
int i = 0; i < viewFrustumPoints.size(); ++i )
779 viewFrustumPoints[i] = viewFrustumPoints[i].unproject( viewMatrix, projectionMatrix, QRect( 0, 0, 1, 1 ) );
780 minX = std::min( minX, viewFrustumPoints[i].x() );
781 maxX = std::max( maxX, viewFrustumPoints[i].x() );
782 minY = std::min( minY, viewFrustumPoints[i].y() );
783 maxY = std::max( maxY, viewFrustumPoints[i].y() );
784 minZ = std::min( minZ, viewFrustumPoints[i].z() );
785 maxZ = std::max( maxZ, viewFrustumPoints[i].z() );
790 const QVector3D pt = cameraPos;
791 const QVector3D vect = ( viewFrustumPoints[i] - pt ).normalized();
792 float t = ( z - pt.z() ) / vect.z();
794 t = shadowRenderingDistance;
796 t = std::min( t, shadowRenderingDistance );
797 viewFrustumPoints[i] = pt + t * vect;
798 minX = std::min( minX, viewFrustumPoints[i].x() );
799 maxX = std::max( maxX, viewFrustumPoints[i].x() );
800 minY = std::min( minY, viewFrustumPoints[i].y() );
801 maxY = std::max( maxY, viewFrustumPoints[i].y() );
802 minZ = std::min( minZ, viewFrustumPoints[i].z() );
803 maxZ = std::max( maxZ, viewFrustumPoints[i].z() );
809 float minX, maxX, minY, maxY, minZ, maxZ;
810 QVector3D lookingAt = mMainCamera->viewCenter();
811 const float d = 2 * ( mMainCamera->position() - mMainCamera->viewCenter() ).length();
814 calculateViewExtent( mMainCamera, maximumShadowRenderingDistance, lookingAt.z(), minX, maxX, minY, maxY, minZ, maxZ );
816 lookingAt = QVector3D( 0.5f * ( minX + maxX ), 0.5f * ( minY + maxY ), mMainCamera->viewCenter().z() );
817 const QVector3D lightPosition = lookingAt + QVector3D( 0.0f, 0.0f, d );
818 mLightCamera->setPosition( lightPosition );
819 mLightCamera->setViewCenter( lookingAt );
820 mLightCamera->setUpVector( QVector3D( 0.0f, 1.0f, 0.0f ) );
821 mLightCamera->rotateAboutViewCenter( QQuaternion::rotationTo( QVector3D( 0.0f, 0.0f, -1.0f ), lightDirection ) );
823 mLightCamera->setProjectionType( Qt3DRender::QCameraLens::ProjectionType::OrthographicProjection );
824 mLightCamera->lens()->setOrthographicProjection(
825 - 0.7f * ( maxX - minX ), 0.7f * ( maxX - minX ),
826 - 0.7f * ( maxY - minY ), 0.7f * ( maxY - minY ),
827 1.0f, 2 * ( lookingAt - lightPosition ).length() );
835 QObject *top = mRenderSurfaceSelector;
836 while ( top->parent() &&
dynamic_cast<Qt3DRender::QFrameGraphNode *
>( top->parent() ) )
840 context.
lowestId = mMainCamera->id().id();
843 return qPrintable( strList.join(
"\n" ) ) + QString(
"\n" );
849 return qPrintable( strList.join(
"\n" ) ) + QString(
"\n" );
854 mForwardClearBuffers->setClearColor( clearColor );
859 mShadowRenderingEnabled = enabled;
861 if ( mShadowRenderingEnabled )
862 mShadowSceneEntitiesFilter->setEnabled(
true );
864 mShadowSceneEntitiesFilter->setEnabled(
false );
875 mShadowMapResolution = resolution;
876 mShadowMapTexture->setWidth( mShadowMapResolution );
877 mShadowMapTexture->setHeight( mShadowMapResolution );
882 mAmbientOcclusionEnabled = enabled;
883 mAmbientOcclusionRenderEntity->setEnabled( enabled );
889 mAmbientOcclusionIntensity = intensity;
890 mAmbientOcclusionRenderEntity->
setIntensity( intensity );
895 mAmbientOcclusionRadius = radius;
896 mAmbientOcclusionRenderEntity->
setRadius( radius );
901 mAmbientOcclusionThreshold = threshold;
902 mAmbientOcclusionRenderEntity->
setThreshold( threshold );
907 if ( enabled == mFrustumCullingEnabled )
909 mFrustumCullingEnabled = enabled;
910 if ( mFrustumCullingEnabled )
911 mFrustumCulling->setParent( mForwardClearBuffers );
913 mFrustumCulling->setParent( ( Qt3DCore::QNode * )
nullptr );
918 mEyeDomeLightingEnabled = enabled;
919 mEyeDomeLightingStrength = strength;
920 mEyeDomeLightingDistance = distance;
928 mDebugShadowMapPreviewQuad->setEnabled( enabled );
933 case Qt::Corner::TopRightCorner:
934 mDebugShadowMapPreviewQuad->
setViewPort( QPointF( 1.0f - size / 2, 0.0f + size / 2 ), 0.5 * QSizeF( size, size ) );
936 case Qt::Corner::TopLeftCorner:
937 mDebugShadowMapPreviewQuad->
setViewPort( QPointF( 0.0f + size / 2, 0.0f + size / 2 ), 0.5 * QSizeF( size, size ) );
939 case Qt::Corner::BottomRightCorner:
940 mDebugShadowMapPreviewQuad->
setViewPort( QPointF( 1.0f - size / 2, 1.0f - size / 2 ), 0.5 * QSizeF( size, size ) );
942 case Qt::Corner::BottomLeftCorner:
943 mDebugShadowMapPreviewQuad->
setViewPort( QPointF( 0.0f + size / 2, 1.0f - size / 2 ), 0.5 * QSizeF( size, size ) );
951 mDebugDepthMapPreviewQuad->setEnabled( enabled );
957 case Qt::Corner::TopRightCorner:
958 mDebugDepthMapPreviewQuad->
setViewPort( QPointF( 1.0f - size / 2, 0.0f + size / 2 ), 0.5 * QSizeF( size, size ) );
960 case Qt::Corner::TopLeftCorner:
961 mDebugDepthMapPreviewQuad->
setViewPort( QPointF( 0.0f + size / 2, 0.0f + size / 2 ), 0.5 * QSizeF( size, size ) );
963 case Qt::Corner::BottomRightCorner:
964 mDebugDepthMapPreviewQuad->
setViewPort( QPointF( 1.0f - size / 2, 1.0f - size / 2 ), 0.5 * QSizeF( size, size ) );
966 case Qt::Corner::BottomLeftCorner:
967 mDebugDepthMapPreviewQuad->
setViewPort( QPointF( 0.0f + size / 2, 1.0f - size / 2 ), 0.5 * QSizeF( size, size ) );
976 mForwardColorTexture->setSize( mSize.width(), mSize.height() );
977 mForwardDepthTexture->setSize( mSize.width(), mSize.height() );
978 mRenderCaptureColorTexture->setSize( mSize.width(), mSize.height() );
979 mRenderCaptureDepthTexture->setSize( mSize.width(), mSize.height() );
980 mDepthRenderCaptureDepthTexture->setSize( mSize.width(), mSize.height() );
981 mDepthRenderCaptureColorTexture->setSize( mSize.width(), mSize.height() );
982 mRenderSurfaceSelector->setExternalRenderTargetSize( mSize );
984 mAmbientOcclusionRenderTexture->setSize( mSize.width(), mSize.height() );
985 mAmbientOcclusionBlurTexture->setSize( mSize.width(), mSize.height() );
990 if ( enabled == mRenderCaptureEnabled )
992 mRenderCaptureEnabled = enabled;
993 mRenderCaptureTargetSelector->setEnabled( mRenderCaptureEnabled );
998 mDebugOverlay->setEnabled( enabled );
1003 for ( Qt3DRender::QRenderState *state : mClipRenderStateSet->renderStates() )
1005 if ( qobject_cast<Qt3DRender::QClipPlane *>( state ) )
1007 mClipRenderStateSet->removeRenderState( state );
1018 for (
int i = 0; i < nrClipPlanes; ++i )
1020 Qt3DRender::QClipPlane *clipPlane =
new Qt3DRender::QClipPlane;
1021 clipPlane->setPlaneIndex( i );
1022 mClipRenderStateSet->addRenderState( clipPlane );
void setThreshold(float threshold)
Sets the amount of occlusion when the effects starts to kick in.
void setRadius(float radius)
Sets the radius for the ambient occlusion effect.
void setIntensity(float intensity)
Sets the intensity for the ambient occlusion effect.
QgsVector3D direction() const
Returns the direction of the light in degrees.
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 addClipPlanes(int nrClipPlanes)
Setups nrClipPlanes clip planes in the forward pass to enable OpenGL clipping.
QString dumpFrameGraph() const
Dumps frame graph as string.
void setRenderCaptureEnabled(bool enabled)
Sets whether it will be possible to render to an image.
void removeClipPlanes()
Disables OpenGL clipping.
void setShadowBias(float shadowBias)
Sets the shadow bias value.
void setupShadowMapDebugging(bool enabled, Qt::Corner corner, double size)
Sets the shadow map debugging view port.
void setClearColor(const QColor &clearColor)
Sets the clear color of the scene (background color)
void setShadowMapResolution(int resolution)
Sets the resolution of the shadow map.
QgsPreviewQuad * addTexturePreviewOverlay(Qt3DRender::QTexture2D *texture, const QPointF ¢erNDC, const QSizeF &size, QVector< Qt3DRender::QParameter * > additionalShaderParameters=QVector< Qt3DRender::QParameter * >())
Adds an preview entity that shows a texture in real time for debugging purposes.
void setAmbientOcclusionIntensity(float intensity)
Sets the ambient occlusion intensity.
float shadowBias() const
Returns the shadow bias value.
void setFrustumCullingEnabled(bool enabled)
Sets whether frustum culling is enabled.
void setDebugOverlayEnabled(bool enabled)
Sets whether debug overlay is enabled.
void setShadowRenderingEnabled(bool enabled)
Sets whether the shadow rendering is enabled.
void setupDepthMapDebugging(bool enabled, Qt::Corner corner, double size)
Sets the depth map debugging view port.
void setupDirectionalLight(const QgsDirectionalLightSettings &light, float maximumShadowRenderingDistance)
Sets shadow rendering to use a directional light.
void setAmbientOcclusionThreshold(float threshold)
Sets the ambient occlusion threshold.
QString dumpSceneGraph() const
Dumps scene graph as string.
void setupEyeDomeLighting(bool enabled, double strength, int distance)
Sets eye dome lighting shading related settings.
void setSize(QSize s)
Sets the size of the buffers used for rendering.
void setAmbientOcclusionEnabled(bool enabled)
Sets whether Screen Space Ambient Occlusion will be enabled.
void setAmbientOcclusionRadius(float radius)
Sets the ambient occlusion radius.
Qt3DRender::QCamera * mainCamera()
Returns the main camera.
QgsFrameGraph(QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root)
Constructor.
void setupShadowRenderingExtent(float minX, float maxX, float minY, float maxY)
Sets the parts of the scene where objects cast shadows.
void setAmbientOcclusionEnabled(bool enabled)
Sets whether screen space ambient occlusion is enabled.
void setShadowRenderingEnabled(bool enabled)
Sets whether shadow rendering is enabled.
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 setupDirectionalLight(QVector3D position, QVector3D direction)
Sets up a directional light that is used to render shadows.
void setEyeDomeLightingEnabled(bool enabled)
Sets whether eye dome lighting is enabled.
void setViewPort(const QPointF ¢erNDC, const QSizeF &size)
Sets where the quad will be located on the scene.
double y() const
Returns Y coordinate.
double z() const
Returns Z coordinate.
double x() const
Returns X coordinate.
Qt3DCore::QAttribute Qt3DQAttribute
Qt3DCore::QBuffer Qt3DQBuffer
Qt3DCore::QGeometry Qt3DQGeometry
Qt3DCore::QAttribute Qt3DQAttribute
void calculateViewExtent(Qt3DRender::QCamera *camera, float shadowRenderingDistance, float z, float &minX, float &maxX, float &minY, float &maxY, float &minZ, float &maxZ)
Qt3DCore::QBuffer Qt3DQBuffer
Qt3DCore::QGeometry Qt3DQGeometry