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 );
384 Qt3DRender::QCullFace *depthRenderCullFace =
new Qt3DRender::QCullFace;
385 depthRenderCullFace->setMode( Qt3DRender::QCullFace::NoCulling );
387 mAmbientOcclusionRenderStateSet->addRenderState( depthRenderDepthTest );
388 mAmbientOcclusionRenderStateSet->addRenderState( depthRenderCullFace );
390 mAmbientOcclusionRenderLayerFilter =
new Qt3DRender::QLayerFilter( mAmbientOcclusionRenderStateSet );
392 mAmbientOcclusionRenderCaptureTargetSelector =
new Qt3DRender::QRenderTargetSelector( mAmbientOcclusionRenderLayerFilter );
393 Qt3DRender::QRenderTarget *colorRenderTarget =
new Qt3DRender::QRenderTarget( mAmbientOcclusionRenderCaptureTargetSelector );
399 Qt3DRender::QRenderTargetOutput *colorOutput =
new Qt3DRender::QRenderTargetOutput( colorRenderTarget );
400 colorOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Color0 );
403 mAmbientOcclusionRenderTexture =
new Qt3DRender::QTexture2D( colorOutput );
404 mAmbientOcclusionRenderTexture->setSize( mSize.width(), mSize.height() );
405 mAmbientOcclusionRenderTexture->setFormat( Qt3DRender::QAbstractTexture::R32F );
406 mAmbientOcclusionRenderTexture->setMinificationFilter( Qt3DRender::QAbstractTexture::Linear );
407 mAmbientOcclusionRenderTexture->setMagnificationFilter( Qt3DRender::QAbstractTexture::Linear );
410 colorOutput->setTexture( mAmbientOcclusionRenderTexture );
411 colorRenderTarget->addOutput( colorOutput );
413 mAmbientOcclusionRenderCaptureTargetSelector->setTarget( colorRenderTarget );
415 Qt3DRender::QLayer *ambientOcclusionRenderLayer =
new Qt3DRender::QLayer();
417 mAmbientOcclusionRenderLayerFilter->addLayer( ambientOcclusionRenderLayer );
419 return mAmbientOcclusionRenderCameraSelector;
422Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructAmbientOcclusionBlurPass()
424 mAmbientOcclusionBlurCameraSelector =
new Qt3DRender::QCameraSelector;
425 mAmbientOcclusionBlurCameraSelector->setObjectName(
"AmbientOcclusion blur pass CameraSelector" );
426 mAmbientOcclusionBlurCameraSelector->setCamera( mMainCamera );
428 mAmbientOcclusionBlurStateSet =
new Qt3DRender::QRenderStateSet( mAmbientOcclusionBlurCameraSelector );
430 Qt3DRender::QDepthTest *depthRenderDepthTest =
new Qt3DRender::QDepthTest;
431 depthRenderDepthTest->setDepthFunction( Qt3DRender::QDepthTest::Always );
433 Qt3DRender::QCullFace *depthRenderCullFace =
new Qt3DRender::QCullFace;
434 depthRenderCullFace->setMode( Qt3DRender::QCullFace::NoCulling );
436 mAmbientOcclusionBlurStateSet->addRenderState( depthRenderDepthTest );
437 mAmbientOcclusionBlurStateSet->addRenderState( depthRenderCullFace );
439 mAmbientOcclusionBlurLayerFilter =
new Qt3DRender::QLayerFilter( mAmbientOcclusionBlurStateSet );
441 mAmbientOcclusionBlurRenderCaptureTargetSelector =
new Qt3DRender::QRenderTargetSelector( mAmbientOcclusionBlurLayerFilter );
442 Qt3DRender::QRenderTarget *depthRenderTarget =
new Qt3DRender::QRenderTarget( mAmbientOcclusionBlurRenderCaptureTargetSelector );
448 Qt3DRender::QRenderTargetOutput *colorOutput =
new Qt3DRender::QRenderTargetOutput( depthRenderTarget );
449 colorOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Color0 );
452 mAmbientOcclusionBlurTexture =
new Qt3DRender::QTexture2D( colorOutput );
453 mAmbientOcclusionBlurTexture->setSize( mSize.width(), mSize.height() );
454 mAmbientOcclusionBlurTexture->setFormat( Qt3DRender::QAbstractTexture::R32F );
455 mAmbientOcclusionBlurTexture->setMinificationFilter( Qt3DRender::QAbstractTexture::Linear );
456 mAmbientOcclusionBlurTexture->setMagnificationFilter( Qt3DRender::QAbstractTexture::Linear );
459 colorOutput->setTexture( mAmbientOcclusionBlurTexture );
460 depthRenderTarget->addOutput( colorOutput );
462 mAmbientOcclusionBlurRenderCaptureTargetSelector->setTarget( depthRenderTarget );
464 Qt3DRender::QLayer *ambientOcclusionBlurLayer =
new Qt3DRender::QLayer();
466 mAmbientOcclusionBlurLayerFilter->addLayer( ambientOcclusionBlurLayer );
468 return mAmbientOcclusionBlurCameraSelector;
472Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructRubberBandsPass()
474 mRubberBandsCameraSelector =
new Qt3DRender::QCameraSelector;
475 mRubberBandsCameraSelector->setObjectName(
"RubberBands Pass CameraSelector" );
476 mRubberBandsCameraSelector->setCamera( mMainCamera );
478 mRubberBandsLayerFilter =
new Qt3DRender::QLayerFilter( mRubberBandsCameraSelector );
479 mRubberBandsLayerFilter->addLayer( mRubberBandsLayer );
481 mRubberBandsStateSet =
new Qt3DRender::QRenderStateSet( mRubberBandsLayerFilter );
482 Qt3DRender::QDepthTest *depthTest =
new Qt3DRender::QDepthTest;
483 depthTest->setDepthFunction( Qt3DRender::QDepthTest::Always );
484 mRubberBandsStateSet->addRenderState( depthTest );
489 mRubberBandsRenderTargetSelector =
new Qt3DRender::QRenderTargetSelector( mRubberBandsStateSet );
490 mRubberBandsRenderTargetSelector->setTarget( mForwardRenderTargetSelector->target() );
492 return mRubberBandsCameraSelector;
496Qt3DRender::QFrameGraphNode *QgsFrameGraph::constructDepthRenderPass()
500 mDepthRenderCameraSelector =
new Qt3DRender::QCameraSelector;
501 mDepthRenderCameraSelector->setObjectName(
"Depth render view CameraSelector" );
502 mDepthRenderCameraSelector->setCamera( mMainCamera );
504 mDepthRenderStateSet =
new Qt3DRender::QRenderStateSet( mDepthRenderCameraSelector );
506 Qt3DRender::QDepthTest *depthRenderDepthTest =
new Qt3DRender::QDepthTest;
507 depthRenderDepthTest->setDepthFunction( Qt3DRender::QDepthTest::Always );
509 Qt3DRender::QCullFace *depthRenderCullFace =
new Qt3DRender::QCullFace;
510 depthRenderCullFace->setMode( Qt3DRender::QCullFace::NoCulling );
512 mDepthRenderStateSet->addRenderState( depthRenderDepthTest );
513 mDepthRenderStateSet->addRenderState( depthRenderCullFace );
515 mDepthRenderLayerFilter =
new Qt3DRender::QLayerFilter( mDepthRenderStateSet );
516 mDepthRenderLayerFilter->addLayer( mDepthRenderPassLayer );
518 mDepthRenderCaptureTargetSelector =
new Qt3DRender::QRenderTargetSelector( mDepthRenderLayerFilter );
519 Qt3DRender::QRenderTarget *depthRenderTarget =
new Qt3DRender::QRenderTarget( mDepthRenderCaptureTargetSelector );
525 Qt3DRender::QRenderTargetOutput *colorOutput =
new Qt3DRender::QRenderTargetOutput( depthRenderTarget );
526 colorOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Color0 );
529 mDepthRenderCaptureColorTexture =
new Qt3DRender::QTexture2D( colorOutput );
530 mDepthRenderCaptureColorTexture->setSize( mSize.width(), mSize.height() );
531 mDepthRenderCaptureColorTexture->setFormat( Qt3DRender::QAbstractTexture::RGB8_UNorm );
532 mDepthRenderCaptureColorTexture->setMinificationFilter( Qt3DRender::QAbstractTexture::Linear );
533 mDepthRenderCaptureColorTexture->setMagnificationFilter( Qt3DRender::QAbstractTexture::Linear );
536 colorOutput->setTexture( mDepthRenderCaptureColorTexture );
537 depthRenderTarget->addOutput( colorOutput );
539 Qt3DRender::QRenderTargetOutput *depthOutput =
new Qt3DRender::QRenderTargetOutput( depthRenderTarget );
541 depthOutput->setAttachmentPoint( Qt3DRender::QRenderTargetOutput::Depth );
542 mDepthRenderCaptureDepthTexture =
new Qt3DRender::QTexture2D( depthOutput );
543 mDepthRenderCaptureDepthTexture->setSize( mSize.width(), mSize.height() );
544 mDepthRenderCaptureDepthTexture->setFormat( Qt3DRender::QAbstractTexture::DepthFormat );
545 mDepthRenderCaptureDepthTexture->setMinificationFilter( Qt3DRender::QAbstractTexture::Linear );
546 mDepthRenderCaptureDepthTexture->setMagnificationFilter( Qt3DRender::QAbstractTexture::Linear );
547 mDepthRenderCaptureDepthTexture->setComparisonFunction( Qt3DRender::QAbstractTexture::CompareLessEqual );
548 mDepthRenderCaptureDepthTexture->setComparisonMode( Qt3DRender::QAbstractTexture::CompareRefToTexture );
550 depthOutput->setTexture( mDepthRenderCaptureDepthTexture );
551 depthRenderTarget->addOutput( depthOutput );
553 mDepthRenderCaptureTargetSelector->setTarget( depthRenderTarget );
556 mDepthRenderCapture =
new Qt3DRender::QRenderCapture( mDepthRenderCaptureTargetSelector );
558 return mDepthRenderCameraSelector;
561Qt3DCore::QEntity *QgsFrameGraph::constructDepthRenderQuad()
563 Qt3DCore::QEntity *quad =
new Qt3DCore::QEntity;
564 quad->setObjectName(
"depthRenderQuad" );
568 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 };
570 const QByteArray vertexArr( (
const char * ) vert.constData(), vert.size() *
sizeof(
float ) );
573 vertexBuffer->setData( vertexArr );
575 positionAttribute->setName( Qt3DQAttribute::defaultPositionAttributeName() );
576 positionAttribute->setVertexBaseType( Qt3DQAttribute::Float );
577 positionAttribute->setVertexSize( 3 );
578 positionAttribute->setAttributeType( Qt3DQAttribute::VertexAttribute );
579 positionAttribute->setBuffer( vertexBuffer );
580 positionAttribute->setByteOffset( 0 );
581 positionAttribute->setByteStride( 3 *
sizeof(
float ) );
582 positionAttribute->setCount( 6 );
584 geom->addAttribute( positionAttribute );
586 Qt3DRender::QGeometryRenderer *renderer =
new Qt3DRender::QGeometryRenderer;
587 renderer->setPrimitiveType( Qt3DRender::QGeometryRenderer::PrimitiveType::Triangles );
588 renderer->setGeometry( geom );
590 quad->addComponent( renderer );
592 QMatrix4x4 modelMatrix;
593 modelMatrix.setToIdentity();
597 Qt3DRender::QMaterial *material =
new Qt3DRender::QMaterial;
598 Qt3DRender::QParameter *textureParameter =
new Qt3DRender::QParameter(
"depthTexture", mForwardDepthTexture );
599 Qt3DRender::QParameter *textureTransformParameter =
new Qt3DRender::QParameter(
"modelMatrix", QVariant::fromValue( modelMatrix ) );
600 material->addParameter( textureParameter );
601 material->addParameter( textureTransformParameter );
603 Qt3DRender::QEffect *effect =
new Qt3DRender::QEffect;
605 Qt3DRender::QTechnique *technique =
new Qt3DRender::QTechnique;
607 Qt3DRender::QGraphicsApiFilter *graphicsApiFilter = technique->graphicsApiFilter();
608 graphicsApiFilter->setApi( Qt3DRender::QGraphicsApiFilter::Api::OpenGL );
609 graphicsApiFilter->setProfile( Qt3DRender::QGraphicsApiFilter::OpenGLProfile::CoreProfile );
610 graphicsApiFilter->setMajorVersion( 1 );
611 graphicsApiFilter->setMinorVersion( 5 );
613 Qt3DRender::QRenderPass *renderPass =
new Qt3DRender::QRenderPass;
615 Qt3DRender::QShaderProgram *shader =
new Qt3DRender::QShaderProgram;
616 shader->setVertexShaderCode( Qt3DRender::QShaderProgram::loadSource( QUrl(
"qrc:/shaders/depth_render.vert" ) ) );
617 shader->setFragmentShaderCode( Qt3DRender::QShaderProgram::loadSource( QUrl(
"qrc:/shaders/depth_render.frag" ) ) );
618 renderPass->setShaderProgram( shader );
620 technique->addRenderPass( renderPass );
622 effect->addTechnique( technique );
623 material->setEffect( effect );
625 quad->addComponent( material );
664 mLightCamera =
new Qt3DRender::QCamera;
666 mPreviewLayer =
new Qt3DRender::QLayer;
667 mCastShadowsLayer =
new Qt3DRender::QLayer;
668 mForwardRenderLayer =
new Qt3DRender::QLayer;
669 mDepthRenderPassLayer =
new Qt3DRender::QLayer;
670 mTransparentObjectsPassLayer =
new Qt3DRender::QLayer;
671 mRubberBandsLayer =
new Qt3DRender::QLayer;
673 mRubberBandsLayer->setObjectName(
"mRubberBandsLayer" );
675 mPreviewLayer->setRecursive(
true );
676 mCastShadowsLayer->setRecursive(
true );
677 mForwardRenderLayer->setRecursive(
true );
678 mDepthRenderPassLayer->setRecursive(
true );
679 mTransparentObjectsPassLayer->setRecursive(
true );
680 mRubberBandsLayer->setRecursive(
true );
682 mRenderSurfaceSelector =
new Qt3DRender::QRenderSurfaceSelector;
684 QObject *surfaceObj =
dynamic_cast<QObject *
>( surface );
685 Q_ASSERT( surfaceObj );
687 mRenderSurfaceSelector->setSurface( surfaceObj );
688 mRenderSurfaceSelector->setExternalRenderTargetSize( mSize );
690 mMainViewPort =
new Qt3DRender::QViewport( mRenderSurfaceSelector );
691 mMainViewPort->setNormalizedRect( QRectF( 0.0f, 0.0f, 1.0f, 1.0f ) );
694 Qt3DRender::QFrameGraphNode *forwardRenderPass = constructForwardRenderPass();
695 forwardRenderPass->setParent( mMainViewPort );
698 Qt3DRender::QFrameGraphNode *rubberBandsPass = constructRubberBandsPass();
699 rubberBandsPass->setObjectName(
"rubberBandsPass" );
700 rubberBandsPass->setParent( mMainViewPort );
703 Qt3DRender::QFrameGraphNode *shadowRenderPass = constructShadowRenderPass();
704 shadowRenderPass->setParent( mMainViewPort );
707 Qt3DRender::QFrameGraphNode *depthBufferProcessingPass = constructDepthRenderPass();
708 depthBufferProcessingPass->setParent( mMainViewPort );
711 Qt3DRender::QFrameGraphNode *ambientOcclusionFactorRender = constructAmbientOcclusionRenderPass();
712 ambientOcclusionFactorRender->setParent( mMainViewPort );
714 Qt3DRender::QFrameGraphNode *ambientOcclusionBlurPass = constructAmbientOcclusionBlurPass();
715 ambientOcclusionBlurPass->setParent( mMainViewPort );
718 Qt3DRender::QFrameGraphNode *postprocessingPass = constructPostprocessingPass();
719 postprocessingPass->setParent( mMainViewPort );
720 postprocessingPass->setObjectName(
"PostProcessingPass" );
722 mRubberBandsRootEntity =
new Qt3DCore::QEntity( mRootEntity );
723 mRubberBandsRootEntity->setObjectName(
"mRubberBandsRootEntity" );
724 mRubberBandsRootEntity->addComponent( mRubberBandsLayer );
726 Qt3DRender::QParameter *depthMapIsDepthParam =
new Qt3DRender::QParameter(
"isDepth",
true );
727 Qt3DRender::QParameter *shadowMapIsDepthParam =
new Qt3DRender::QParameter(
"isDepth",
true );
729 mDebugDepthMapPreviewQuad = this->
addTexturePreviewOverlay( mForwardDepthTexture, QPointF( 0.9f, 0.9f ), QSizeF( 0.1, 0.1 ), QVector<Qt3DRender::QParameter *> { depthMapIsDepthParam } );
730 mDebugShadowMapPreviewQuad = this->
addTexturePreviewOverlay( mShadowMapTexture, QPointF( 0.9f, 0.9f ), QSizeF( 0.1, 0.1 ), QVector<Qt3DRender::QParameter *> { shadowMapIsDepthParam } );
731 mDebugDepthMapPreviewQuad->setEnabled(
false );
732 mDebugShadowMapPreviewQuad->setEnabled(
false );
734 mDepthRenderQuad = constructDepthRenderQuad();
735 mDepthRenderQuad->addComponent( mDepthRenderPassLayer );
736 mDepthRenderQuad->setParent( mRootEntity );
742 previewQuad->addComponent( mPreviewLayer );
743 previewQuad->setParent( mRootEntity );
744 mPreviewQuads.push_back( previewQuad );
749void calculateViewExtent( Qt3DRender::QCamera *camera,
float shadowRenderingDistance,
float z,
float &minX,
float &maxX,
float &minY,
float &maxY,
float &minZ,
float &maxZ )
751 const QVector3D cameraPos = camera->position();
752 const QMatrix4x4 projectionMatrix = camera->projectionMatrix();
753 const QMatrix4x4 viewMatrix = camera->viewMatrix();
755 QVector4D viewCenter = viewMatrix * QVector4D( camera->viewCenter(), 1.0f );
756 viewCenter /= viewCenter.w();
757 viewCenter = projectionMatrix * viewCenter;
758 viewCenter /= viewCenter.w();
759 depth = viewCenter.z();
760 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()
836 QObject *top = mRenderSurfaceSelector;
837 while ( top->parent() &&
dynamic_cast<Qt3DRender::QFrameGraphNode *
>( top->parent() ) )
841 context.
lowestId = mMainCamera->id().id();
844 return qPrintable( strList.join(
"\n" ) ) + QString(
"\n" );
850 return qPrintable( strList.join(
"\n" ) ) + QString(
"\n" );
855 mForwardClearBuffers->setClearColor( clearColor );
860 mShadowRenderingEnabled = enabled;
862 if ( mShadowRenderingEnabled )
863 mShadowSceneEntitiesFilter->setEnabled(
true );
865 mShadowSceneEntitiesFilter->setEnabled(
false );
876 mShadowMapResolution = resolution;
877 mShadowMapTexture->setWidth( mShadowMapResolution );
878 mShadowMapTexture->setHeight( mShadowMapResolution );
883 mAmbientOcclusionEnabled = enabled;
884 mAmbientOcclusionRenderEntity->setEnabled( enabled );
890 mAmbientOcclusionIntensity = intensity;
891 mAmbientOcclusionRenderEntity->
setIntensity( intensity );
896 mAmbientOcclusionRadius = radius;
897 mAmbientOcclusionRenderEntity->
setRadius( radius );
902 mAmbientOcclusionThreshold = threshold;
903 mAmbientOcclusionRenderEntity->
setThreshold( threshold );
908 if ( enabled == mFrustumCullingEnabled )
910 mFrustumCullingEnabled = enabled;
911 if ( mFrustumCullingEnabled )
912 mFrustumCulling->setParent( mForwardClearBuffers );
914 mFrustumCulling->setParent( ( Qt3DCore::QNode * )
nullptr );
919 mEyeDomeLightingEnabled = enabled;
920 mEyeDomeLightingStrength = strength;
921 mEyeDomeLightingDistance = distance;
929 mDebugShadowMapPreviewQuad->setEnabled( enabled );
934 case Qt::Corner::TopRightCorner:
935 mDebugShadowMapPreviewQuad->
setViewPort( QPointF( 1.0f - size / 2, 0.0f + size / 2 ), 0.5 * QSizeF( size, size ) );
937 case Qt::Corner::TopLeftCorner:
938 mDebugShadowMapPreviewQuad->
setViewPort( QPointF( 0.0f + size / 2, 0.0f + size / 2 ), 0.5 * QSizeF( size, size ) );
940 case Qt::Corner::BottomRightCorner:
941 mDebugShadowMapPreviewQuad->
setViewPort( QPointF( 1.0f - size / 2, 1.0f - size / 2 ), 0.5 * QSizeF( size, size ) );
943 case Qt::Corner::BottomLeftCorner:
944 mDebugShadowMapPreviewQuad->
setViewPort( QPointF( 0.0f + size / 2, 1.0f - size / 2 ), 0.5 * QSizeF( size, size ) );
952 mDebugDepthMapPreviewQuad->setEnabled( enabled );
958 case Qt::Corner::TopRightCorner:
959 mDebugDepthMapPreviewQuad->
setViewPort( QPointF( 1.0f - size / 2, 0.0f + size / 2 ), 0.5 * QSizeF( size, size ) );
961 case Qt::Corner::TopLeftCorner:
962 mDebugDepthMapPreviewQuad->
setViewPort( QPointF( 0.0f + size / 2, 0.0f + size / 2 ), 0.5 * QSizeF( size, size ) );
964 case Qt::Corner::BottomRightCorner:
965 mDebugDepthMapPreviewQuad->
setViewPort( QPointF( 1.0f - size / 2, 1.0f - size / 2 ), 0.5 * QSizeF( size, size ) );
967 case Qt::Corner::BottomLeftCorner:
968 mDebugDepthMapPreviewQuad->
setViewPort( QPointF( 0.0f + size / 2, 1.0f - size / 2 ), 0.5 * QSizeF( size, size ) );
977 mForwardColorTexture->setSize( mSize.width(), mSize.height() );
978 mForwardDepthTexture->setSize( mSize.width(), mSize.height() );
979 mRenderCaptureColorTexture->setSize( mSize.width(), mSize.height() );
980 mRenderCaptureDepthTexture->setSize( mSize.width(), mSize.height() );
981 mDepthRenderCaptureDepthTexture->setSize( mSize.width(), mSize.height() );
982 mDepthRenderCaptureColorTexture->setSize( mSize.width(), mSize.height() );
983 mRenderSurfaceSelector->setExternalRenderTargetSize( mSize );
985 mAmbientOcclusionRenderTexture->setSize( mSize.width(), mSize.height() );
986 mAmbientOcclusionBlurTexture->setSize( mSize.width(), mSize.height() );
991 if ( enabled == mRenderCaptureEnabled )
993 mRenderCaptureEnabled = enabled;
994 mRenderCaptureTargetSelector->setEnabled( mRenderCaptureEnabled );
999 mDebugOverlay->setEnabled( enabled );
1004 for ( Qt3DRender::QRenderState *state : mClipRenderStateSet->renderStates() )
1006 if ( qobject_cast<Qt3DRender::QClipPlane *>( state ) )
1008 mClipRenderStateSet->removeRenderState( state );
1019 for (
int i = 0; i < nrClipPlanes; ++i )
1021 Qt3DRender::QClipPlane *clipPlane =
new Qt3DRender::QClipPlane;
1022 clipPlane->setPlaneIndex( i );
1023 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