QGIS API Documentation 4.1.0-Master (26185ffb827)
Loading...
Searching...
No Matches
qgsframegraph.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsframegraph.h
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#ifndef QGSFRAMEGRAPH_H
17#define QGSFRAMEGRAPH_H
18
19#include <map>
20
21#include "qgis_3d.h"
23
24#include <QSize>
25#include <QWindow>
26#include <Qt3DRender/QBlitFramebuffer>
27#include <Qt3DRender/QCamera>
28#include <Qt3DRender/QCameraSelector>
29#include <Qt3DRender/QClearBuffers>
30#include <Qt3DRender/QCullFace>
31#include <Qt3DRender/QDebugOverlay>
32#include <Qt3DRender/QDepthTest>
33#include <Qt3DRender/QFrustumCulling>
34#include <Qt3DRender/QLayer>
35#include <Qt3DRender/QLayerFilter>
36#include <Qt3DRender/QParameter>
37#include <Qt3DRender/QPolygonOffset>
38#include <Qt3DRender/QRenderCapture>
39#include <Qt3DRender/QRenderPassFilter>
40#include <Qt3DRender/QRenderStateSet>
41#include <Qt3DRender/QRenderSurfaceSelector>
42#include <Qt3DRender/QRenderTarget>
43#include <Qt3DRender/QRenderTargetSelector>
44#include <Qt3DRender/QTexture>
45#include <Qt3DRender/QViewport>
46
47#define SIP_NO_FILE
48
49namespace Qt3DRender
50{
51 class QRenderCaptureReply;
52}
53
62class QgsLightSource;
67class QgsRectangle;
73
84class _3D_EXPORT QgsFrameGraph : public Qt3DCore::QEntity
85{
86 Q_OBJECT
87
88 public:
90 QgsFrameGraph( QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root );
91
93 Qt3DRender::QFrameGraphNode *frameGraphRoot() { return mRenderSurfaceSelector; }
94
96 Qt3DRender::QCamera *mainCamera() { return mMainCamera; }
97
99 Qt3DCore::QEntity *rubberBandsRootEntity() { return mRubberBandsRootEntity; }
100
102 Qt3DRender::QRenderCapture *renderCapture();
103
105 Qt3DRender::QRenderCapture *depthRenderCapture();
106
108 void addGlobalParameters( const QList<Qt3DRender::QParameter *> &parameters );
109
111 void setFrustumCullingEnabled( bool enabled );
112
114 void setClearColor( const QColor &clearColor );
115
117 void setSize( QSize s );
118
123 void setRenderCaptureEnabled( bool enabled );
124
129 void setDebugOverlayEnabled( bool enabled );
130
135 void setMsaaEnabled( bool enabled );
136
141 bool msaaEnabled() const { return mMsaaEnabled; }
142
144 QString dumpFrameGraph() const;
145
147 QString dumpSceneGraph() const;
148
156 void addClipPlanes( int nrClipPlanes );
157
164 void removeClipPlanes();
165
173 bool registerRenderView( std::unique_ptr<QgsAbstractRenderView> renderView, const QString &name, Qt3DRender::QFrameGraphNode *topNode = nullptr );
174
179 void unregisterRenderView( const QString &name );
180
185 void setRenderViewEnabled( const QString &name, bool enable );
186
191 bool isRenderViewEnabled( const QString &name );
192
197 QgsAbstractRenderView *renderView( const QString &name );
198
203 QgsShadowRenderView &shadowRenderView();
204
209 QgsForwardRenderView &forwardRenderView();
210
215 QgsDepthRenderView &depthRenderView();
216
221 QgsAmbientOcclusionRenderView &ambientOcclusionRenderView();
222
227 QgsBloomRenderView &bloomRenderView();
228
233 QgsOverlayTextureRenderView &overlayTextureRenderView();
234
239 QgsHighlightsRenderView &highlightsRenderView();
240
245 QgsPostprocessingRenderView &postprocessingRenderView();
246
251 void updateShadowSettings( const Qgs3DMapSettings &mapSettings );
252
257 void updateDebugDepthMapSettings( const Qgs3DMapSettings &settings );
258
263 void updateAmbientOcclusionSettings( const QgsAmbientOcclusionSettings &settings );
264
269 void updateEyeDomeSettings( const Qgs3DMapSettings &settings );
270
275 void updateBloomSettings( const QgsBloomSettings &settings );
276
282 void updateColorGradingSettings( const QgsColorGradingSettings &settings );
283
284 static const QString sForwardRenderView;
285 static const QString sShadowRenderView;
286 static const QString sAxiS3DRenderView;
287 static const QString sDepthRenderView;
288 static const QString sOverlayRenderView;
290 static const QString sAmbientOcclusionRenderView;
291 static const QString sBloomRenderView;
293 static const QString sPostprocRenderView;
294 static const QString sHighlightsRenderView;
295
296 private:
297 Qt3DRender::QRenderSurfaceSelector *mRenderSurfaceSelector = nullptr;
298 Qt3DRender::QViewport *mMainViewPort = nullptr;
299
300 Qt3DRender::QCamera *mMainCamera = nullptr;
301
302 // Storage for global parameters
303 // QRenderPassFilter has dual usage -- one for storage of filtering keys,
304 // the other for storage of parameters for use in shaders. Here we are
305 // using it for storage of parameters only, not for filtering!
306 Qt3DRender::QRenderPassFilter *mGlobalParamsStorage = nullptr;
307
308 // Post processing pass branch nodes:
309 Qt3DRender::QRenderTargetSelector *mRenderCaptureTargetSelector = nullptr;
310 Qt3DRender::QRenderCapture *mRenderCapture = nullptr;
311 // Post processing pass texture related objects:
312 Qt3DRender::QTexture2D *mRenderCaptureColorTexture = nullptr;
313 Qt3DRender::QTexture2D *mRenderCaptureDepthTexture = nullptr;
314
315 // Separate thumbnail capture pass to save scaled-down images of the
316 // rendered view to aid in debugging (e.g., Tracy profiler frame images).
317 Qt3DRender::QRenderCapture *mThumbnailCapture = nullptr;
318 Qt3DRender::QTexture2D *mThumbnailTexture = nullptr;
319
320 // Rubber bands pass
321 Qt3DRender::QCameraSelector *mRubberBandsCameraSelector = nullptr;
322 Qt3DRender::QLayerFilter *mRubberBandsLayerFilter = nullptr;
323 Qt3DRender::QRenderStateSet *mRubberBandsStateSet = nullptr;
324 Qt3DRender::QRenderTargetSelector *mRubberBandsRenderTargetSelector = nullptr;
325
326 QSize mSize = QSize( 1024, 768 );
327
328 QVector3D mLightDirection = QVector3D( 0.0, -1.0f, 0.0f );
329
330 Qt3DCore::QEntity *mRootEntity = nullptr;
331
332 Qt3DRender::QLayer *mRubberBandsLayer = nullptr;
333
334 Qt3DCore::QEntity *mRubberBandsRootEntity = nullptr;
335
337 QgsOverlayTextureEntity *mDepthTextureDebugging = nullptr;
338
339 void constructShadowRenderPass();
340 void constructForwardRenderPass();
341 void constructHighlightsPass();
342 void constructOverlayTexturePass( Qt3DRender::QFrameGraphNode *topNode = nullptr );
343 void constructPostprocessingPass( Qt3DRender::QFrameGraphNode *topNode = nullptr );
344 void constructDepthRenderPass();
345 void constructAmbientOcclusionRenderPass();
346 void constructBloomRenderPass();
347 Qt3DRender::QFrameGraphNode *constructRubberBandsPass();
348 void constructMsaaBlitNodes();
349
350 void constructThumbnailCapturePass();
351 void updateThumbnailTextureSize();
352 void onThumbnailCaptureCompleted( Qt3DRender::QRenderCaptureReply *reply );
353
354 bool mMsaaEnabled = false;
355 bool mMsaaBlitConfigured = false;
356 Qt3DRender::QBlitFramebuffer *mMsaaBlitNode = nullptr;
357 Qt3DRender::QBlitFramebuffer *mMsaaDepthBlitNode = nullptr;
358
359 // holds renderviews according to their name
360 std::map<QString, std::unique_ptr<QgsAbstractRenderView>> mRenderViewMap;
361
362 Q_DISABLE_COPY( QgsFrameGraph )
363};
364
365#endif // QGSFRAMEGRAPH_H
Definition of the world.
Base class for 3D render view.
Container class that holds different objects related to ambient occlusion rendering.
Contains the configuration of ambient occlusion rendering.
Container class that holds different objects related to bloom rendering.
Contains the configuration of the lighting "bloom" effect.
Object that controls camera movement based on user input.
Contains the configuration of the scene's color grading settings, such as exposure and tone mapping.
Container class that holds different objects related to depth rendering.
Definition of a directional light in a 3D map scene.
Container class that holds different objects related to forward rendering.
static const QString sPostprocRenderView
Postprocessing render view name.
bool msaaEnabled() const
Returns whether multisample anti-aliasing (MSAA) is enabled.
Qt3DRender::QFrameGraphNode * frameGraphRoot()
Returns the root of the frame graph object.
static const QString sOverlayRenderView
static const QString sDepthRenderView
static const QString sForwardRenderView
static const QString sBloomRenderView
static const QString sShadowRenderView
Qt3DCore::QEntity * rubberBandsRootEntity()
Returns entity for all rubber bands (to show them always on top).
static const QString sAxiS3DRenderView
static const QString sAmbientOcclusionRenderView
Ambient occlusion render view name.
static const QString sHighlightsRenderView
Qt3DRender::QCamera * mainCamera()
Returns the main camera.
QgsFrameGraph(QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root)
Constructor.
Container class that holds different objects related to highlighting identified features.
Base class for light sources in 3d scenes.
An entity responsible for rendering an overlay texture in 3D view.
Simple render view to preview overlay textures in 3D view.
An entity that is responsible for applying post processing effects.
Container class that holds different objects related to postprocessing rendering.
A rectangle specified with double values.
Container class that holds different objects related to shadow rendering.
Contains configuration for rendering shadows.