QGIS API Documentation 4.1.0-Master (376402f9aeb)
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;
63
64
75class _3D_EXPORT QgsFrameGraph : public Qt3DCore::QEntity
76{
77 Q_OBJECT
78
79 public:
81 QgsFrameGraph( QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root );
82
84 Qt3DRender::QFrameGraphNode *frameGraphRoot() { return mRenderSurfaceSelector; }
85
87 Qt3DRender::QCamera *mainCamera() { return mMainCamera; }
88
90 QgsPostprocessingEntity *postprocessingEntity() { return mPostprocessingEntity; }
91
93 Qt3DCore::QEntity *rubberBandsRootEntity() { return mRubberBandsRootEntity; }
94
96 Qt3DRender::QRenderCapture *renderCapture();
97
99 Qt3DRender::QRenderCapture *depthRenderCapture();
100
102 void addGlobalParameters( const QList<Qt3DRender::QParameter *> &parameters );
103
105 void setFrustumCullingEnabled( bool enabled );
106
108 void setClearColor( const QColor &clearColor );
109
111 void setSize( QSize s );
112
117 void setRenderCaptureEnabled( bool enabled );
118
123 void setDebugOverlayEnabled( bool enabled );
124
129 void setMsaaEnabled( bool enabled );
130
135 bool msaaEnabled() const { return mMsaaEnabled; }
136
138 QString dumpFrameGraph() const;
139
141 QString dumpSceneGraph() const;
142
150 void addClipPlanes( int nrClipPlanes );
151
158 void removeClipPlanes();
159
167 bool registerRenderView( std::unique_ptr<QgsAbstractRenderView> renderView, const QString &name, Qt3DRender::QFrameGraphNode *topNode = nullptr );
168
173 void unregisterRenderView( const QString &name );
174
179 void setRenderViewEnabled( const QString &name, bool enable );
180
185 bool isRenderViewEnabled( const QString &name );
186
191 QgsAbstractRenderView *renderView( const QString &name );
192
197 QgsShadowRenderView &shadowRenderView();
198
203 QgsForwardRenderView &forwardRenderView();
204
209 QgsDepthRenderView &depthRenderView();
210
215 QgsAmbientOcclusionRenderView &ambientOcclusionRenderView();
216
221 QgsOverlayTextureRenderView &overlayTextureRenderView();
222
227 QgsHighlightsRenderView &highlightsRenderView();
228
233 void updateShadowSettings( const QgsShadowSettings &shadowSettings, const QList<QgsLightSource *> &lightSources );
234
239 void updateDebugShadowMapSettings( const Qgs3DMapSettings &settings );
240
245 void updateDebugDepthMapSettings( const Qgs3DMapSettings &settings );
246
251 void updateAmbientOcclusionSettings( const QgsAmbientOcclusionSettings &settings );
252
257 void updateEyeDomeSettings( const Qgs3DMapSettings &settings );
258
259 static const QString FORWARD_RENDERVIEW;
260 static const QString SHADOW_RENDERVIEW;
261 static const QString AXIS3D_RENDERVIEW;
262 static const QString DEPTH_RENDERVIEW;
263 static const QString OVERLAY_RENDERVIEW;
265 static const QString AMBIENT_OCCLUSION_RENDERVIEW;
266 static const QString HIGHLIGHTS_RENDERVIEW;
267
268 private:
269 Qt3DRender::QRenderSurfaceSelector *mRenderSurfaceSelector = nullptr;
270 Qt3DRender::QViewport *mMainViewPort = nullptr;
271
272 Qt3DRender::QCamera *mMainCamera = nullptr;
273
274 // Storage for global parameters
275 // QRenderPassFilter has dual usage -- one for storage of filtering keys,
276 // the other for storage of parameters for use in shaders. Here we are
277 // using it for storage of parameters only, not for filtering!
278 Qt3DRender::QRenderPassFilter *mGlobalParamsStorage = nullptr;
279
280 // Post processing pass branch nodes:
281 Qt3DRender::QRenderTargetSelector *mRenderCaptureTargetSelector = nullptr;
282 Qt3DRender::QRenderCapture *mRenderCapture = nullptr;
283 // Post processing pass texture related objects:
284 Qt3DRender::QTexture2D *mRenderCaptureColorTexture = nullptr;
285 Qt3DRender::QTexture2D *mRenderCaptureDepthTexture = nullptr;
286
287 // Rubber bands pass
288 Qt3DRender::QCameraSelector *mRubberBandsCameraSelector = nullptr;
289 Qt3DRender::QLayerFilter *mRubberBandsLayerFilter = nullptr;
290 Qt3DRender::QRenderStateSet *mRubberBandsStateSet = nullptr;
291 Qt3DRender::QRenderTargetSelector *mRubberBandsRenderTargetSelector = nullptr;
292
293 QSize mSize = QSize( 1024, 768 );
294
295 QVector3D mLightDirection = QVector3D( 0.0, -1.0f, 0.0f );
296
297 Qt3DCore::QEntity *mRootEntity = nullptr;
298
299 Qt3DRender::QLayer *mRubberBandsLayer = nullptr;
300
301 QgsPostprocessingEntity *mPostprocessingEntity = nullptr;
302
303 Qt3DCore::QEntity *mRubberBandsRootEntity = nullptr;
304
306 QgsOverlayTextureEntity *mShadowTextureDebugging = nullptr;
308 QgsOverlayTextureEntity *mDepthTextureDebugging = nullptr;
309
310 void constructShadowRenderPass();
311 void constructForwardRenderPass();
312 void constructHighlightsPass();
313 void constructOverlayTexturePass( Qt3DRender::QFrameGraphNode *topNode = nullptr );
314 Qt3DRender::QFrameGraphNode *constructPostprocessingPass();
315 void constructDepthRenderPass();
316 void constructAmbientOcclusionRenderPass();
317 Qt3DRender::QFrameGraphNode *constructRubberBandsPass();
318 void constructMsaaBlitNodes();
319
320 Qt3DRender::QFrameGraphNode *constructSubPostPassForProcessing();
321 Qt3DRender::QFrameGraphNode *constructSubPostPassForRenderCapture();
322
323 bool mRenderCaptureEnabled = false;
324 bool mMsaaEnabled = false;
325 bool mMsaaBlitConfigured = false;
326 Qt3DRender::QBlitFramebuffer *mMsaaBlitNode = nullptr;
327 Qt3DRender::QBlitFramebuffer *mMsaaDepthBlitNode = nullptr;
328
329 // holds renderviews according to their name
330 std::map<QString, std::unique_ptr<QgsAbstractRenderView>> mRenderViewMap;
331
332 Q_DISABLE_COPY( QgsFrameGraph )
333};
334
335#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.
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 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.