QGIS API Documentation 4.1.0-Master (9af12b5a203)
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 <QWindow>
25#include <Qt3DRender/QBlitFramebuffer>
26#include <Qt3DRender/QCamera>
27#include <Qt3DRender/QCameraSelector>
28#include <Qt3DRender/QClearBuffers>
29#include <Qt3DRender/QCullFace>
30#include <Qt3DRender/QDebugOverlay>
31#include <Qt3DRender/QDepthTest>
32#include <Qt3DRender/QFrustumCulling>
33#include <Qt3DRender/QLayer>
34#include <Qt3DRender/QLayerFilter>
35#include <Qt3DRender/QParameter>
36#include <Qt3DRender/QPolygonOffset>
37#include <Qt3DRender/QRenderCapture>
38#include <Qt3DRender/QRenderPassFilter>
39#include <Qt3DRender/QRenderStateSet>
40#include <Qt3DRender/QRenderSurfaceSelector>
41#include <Qt3DRender/QRenderTarget>
42#include <Qt3DRender/QRenderTargetSelector>
43#include <Qt3DRender/QTexture>
44#include <Qt3DRender/QViewport>
45
46#define SIP_NO_FILE
47
56class QgsLightSource;
60class QgsRectangle;
65
76class _3D_EXPORT QgsFrameGraph : public Qt3DCore::QEntity
77{
78 Q_OBJECT
79
80 public:
82 QgsFrameGraph( QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root );
83
85 Qt3DRender::QFrameGraphNode *frameGraphRoot() { return mRenderSurfaceSelector; }
86
88 Qt3DRender::QCamera *mainCamera() { return mMainCamera; }
89
91 QgsPostprocessingEntity *postprocessingEntity() { return mPostprocessingEntity; }
92
94 Qt3DCore::QEntity *rubberBandsRootEntity() { return mRubberBandsRootEntity; }
95
97 Qt3DRender::QRenderCapture *renderCapture();
98
100 Qt3DRender::QRenderCapture *depthRenderCapture();
101
103 void addGlobalParameters( const QList<Qt3DRender::QParameter *> &parameters );
104
106 void setFrustumCullingEnabled( bool enabled );
107
109 void setClearColor( const QColor &clearColor );
110
112 void setSize( QSize s );
113
118 void setRenderCaptureEnabled( bool enabled );
119
124 void setDebugOverlayEnabled( bool enabled );
125
130 void setMsaaEnabled( bool enabled );
131
136 bool msaaEnabled() const { return mMsaaEnabled; }
137
139 QString dumpFrameGraph() const;
140
142 QString dumpSceneGraph() const;
143
151 void addClipPlanes( int nrClipPlanes );
152
159 void removeClipPlanes();
160
168 bool registerRenderView( std::unique_ptr<QgsAbstractRenderView> renderView, const QString &name, Qt3DRender::QFrameGraphNode *topNode = nullptr );
169
174 void unregisterRenderView( const QString &name );
175
180 void setRenderViewEnabled( const QString &name, bool enable );
181
186 bool isRenderViewEnabled( const QString &name );
187
192 QgsAbstractRenderView *renderView( const QString &name );
193
198 QgsShadowRenderView &shadowRenderView();
199
204 QgsForwardRenderView &forwardRenderView();
205
210 QgsDepthRenderView &depthRenderView();
211
216 QgsAmbientOcclusionRenderView &ambientOcclusionRenderView();
217
222 QgsBloomRenderView &bloomRenderView();
223
228 QgsOverlayTextureRenderView &overlayTextureRenderView();
229
234 QgsHighlightsRenderView &highlightsRenderView();
235
240 void updateShadowSettings( const QgsShadowSettings &shadowSettings, const QList<QgsLightSource *> &lightSources );
241
246 void updateDebugDepthMapSettings( const Qgs3DMapSettings &settings );
247
252 void updateAmbientOcclusionSettings( const QgsAmbientOcclusionSettings &settings );
253
258 void updateEyeDomeSettings( const Qgs3DMapSettings &settings );
259
264 void updateBloomSettings( const QgsBloomSettings &settings );
265
266 static const QString FORWARD_RENDERVIEW;
267 static const QString SHADOW_RENDERVIEW;
268 static const QString AXIS3D_RENDERVIEW;
269 static const QString DEPTH_RENDERVIEW;
270 static const QString OVERLAY_RENDERVIEW;
272 static const QString AMBIENT_OCCLUSION_RENDERVIEW;
273 static const QString BLOOM_RENDERVIEW;
274 static const QString HIGHLIGHTS_RENDERVIEW;
275
276 private:
277 Qt3DRender::QRenderSurfaceSelector *mRenderSurfaceSelector = nullptr;
278 Qt3DRender::QViewport *mMainViewPort = nullptr;
279
280 Qt3DRender::QCamera *mMainCamera = nullptr;
281
282 // Storage for global parameters
283 // QRenderPassFilter has dual usage -- one for storage of filtering keys,
284 // the other for storage of parameters for use in shaders. Here we are
285 // using it for storage of parameters only, not for filtering!
286 Qt3DRender::QRenderPassFilter *mGlobalParamsStorage = nullptr;
287
288 // Post processing pass branch nodes:
289 Qt3DRender::QRenderTargetSelector *mRenderCaptureTargetSelector = nullptr;
290 Qt3DRender::QRenderCapture *mRenderCapture = nullptr;
291 // Post processing pass texture related objects:
292 Qt3DRender::QTexture2D *mRenderCaptureColorTexture = nullptr;
293 Qt3DRender::QTexture2D *mRenderCaptureDepthTexture = nullptr;
294
295 // Rubber bands pass
296 Qt3DRender::QCameraSelector *mRubberBandsCameraSelector = nullptr;
297 Qt3DRender::QLayerFilter *mRubberBandsLayerFilter = nullptr;
298 Qt3DRender::QRenderStateSet *mRubberBandsStateSet = nullptr;
299 Qt3DRender::QRenderTargetSelector *mRubberBandsRenderTargetSelector = nullptr;
300
301 QSize mSize = QSize( 1024, 768 );
302
303 QVector3D mLightDirection = QVector3D( 0.0, -1.0f, 0.0f );
304
305 Qt3DCore::QEntity *mRootEntity = nullptr;
306
307 Qt3DRender::QLayer *mRubberBandsLayer = nullptr;
308
309 QgsPostprocessingEntity *mPostprocessingEntity = nullptr;
310
311 Qt3DCore::QEntity *mRubberBandsRootEntity = nullptr;
312
314 QgsOverlayTextureEntity *mDepthTextureDebugging = nullptr;
315
316 void constructShadowRenderPass();
317 void constructForwardRenderPass();
318 void constructHighlightsPass();
319 void constructOverlayTexturePass( Qt3DRender::QFrameGraphNode *topNode = nullptr );
320 Qt3DRender::QFrameGraphNode *constructPostprocessingPass();
321 void constructDepthRenderPass();
322 void constructAmbientOcclusionRenderPass();
323 void constructBloomRenderPass();
324 Qt3DRender::QFrameGraphNode *constructRubberBandsPass();
325 void constructMsaaBlitNodes();
326
327 Qt3DRender::QFrameGraphNode *constructSubPostPassForProcessing();
328 Qt3DRender::QFrameGraphNode *constructSubPostPassForRenderCapture();
329
330 bool mRenderCaptureEnabled = false;
331 bool mMsaaEnabled = false;
332 bool mMsaaBlitConfigured = false;
333 Qt3DRender::QBlitFramebuffer *mMsaaBlitNode = nullptr;
334 Qt3DRender::QBlitFramebuffer *mMsaaDepthBlitNode = nullptr;
335
336 // holds renderviews according to their name
337 std::map<QString, std::unique_ptr<QgsAbstractRenderView>> mRenderViewMap;
338
339 Q_DISABLE_COPY( QgsFrameGraph )
340};
341
342#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.
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.
bool msaaEnabled() const
Returns whether multisample anti-aliasing (MSAA) is enabled.
static const QString AMBIENT_OCCLUSION_RENDERVIEW
Ambient occlusion render view name.
Qt3DRender::QFrameGraphNode * frameGraphRoot()
Returns the root of the frame graph object.
QgsPostprocessingEntity * postprocessingEntity()
Returns the postprocessing entity.
static const QString FORWARD_RENDERVIEW
Qt3DCore::QEntity * rubberBandsRootEntity()
Returns entity for all rubber bands (to show them always on top).
static const QString SHADOW_RENDERVIEW
static const QString HIGHLIGHTS_RENDERVIEW
static const QString OVERLAY_RENDERVIEW
static const QString AXIS3D_RENDERVIEW
static const QString BLOOM_RENDERVIEW
static const QString DEPTH_RENDERVIEW
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.
A rectangle specified with double values.
Container class that holds different objects related to shadow rendering.
Contains configuration for rendering shadows.