QGIS API Documentation 4.3.0-Master (1930e81c918)
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;
68class QgsRectangle;
74
85class _3D_EXPORT QgsFrameGraph : public Qt3DCore::QEntity
86{
87 Q_OBJECT
88
89 public:
91 QgsFrameGraph( QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root );
92
94 Qt3DRender::QFrameGraphNode *frameGraphRoot() { return mRenderSurfaceSelector; }
95
97 Qt3DRender::QCamera *mainCamera() { return mMainCamera; }
98
100 Qt3DRender::QRenderCapture *renderCapture();
101
103 Qt3DRender::QRenderCapture *depthRenderCapture();
104
106 void addGlobalParameters( const QList<Qt3DRender::QParameter *> &parameters );
107
109 void setFrustumCullingEnabled( bool enabled );
110
112 void setClearColor( const QColor &clearColor );
113
115 void setSize( QSize s );
116
121 void setRenderCaptureEnabled( bool enabled );
122
127 void setDebugOverlayEnabled( bool enabled );
128
133 void setMsaaEnabled( bool enabled );
134
139 bool msaaEnabled() const { return mMsaaEnabled; }
140
142 QString dumpFrameGraph() const;
143
145 QString dumpSceneGraph() const;
146
154 void addClipPlanes( int nrClipPlanes );
155
162 void removeClipPlanes();
163
171 bool registerRenderView( std::unique_ptr<QgsAbstractRenderView> renderView, const QString &name, Qt3DRender::QFrameGraphNode *topNode = nullptr );
172
177 void unregisterRenderView( const QString &name );
178
183 void setRenderViewEnabled( const QString &name, bool enable );
184
189 bool isRenderViewEnabled( const QString &name );
190
195 QgsAbstractRenderView *renderView( const QString &name );
196
201 QgsShadowRenderView &shadowRenderView();
202
207 QgsForwardRenderView &forwardRenderView();
208
213 QgsDepthRenderView &depthRenderView();
214
219 QgsAmbientOcclusionRenderView &ambientOcclusionRenderView();
220
225 QgsBloomRenderView &bloomRenderView();
226
231 QgsOverlayTextureRenderView &overlayTextureRenderView();
232
237 QgsHighlightsRenderView &highlightsRenderView();
238
243 QgsPostprocessingRenderView &postprocessingRenderView();
244
249 QgsRubberBandRenderView &rubberBandRenderView();
250
255 void updateShadowSettings( const Qgs3DMapSettings &mapSettings );
256
261 void updateDebugDepthMapSettings( const Qgs3DMapSettings &settings );
262
267 void updateAmbientOcclusionSettings( const QgsAmbientOcclusionSettings &settings );
268
273 void updateEyeDomeSettings( const Qgs3DMapSettings &settings );
274
279 void updateBloomSettings( const QgsBloomSettings &settings );
280
286 void updateColorGradingSettings( const QgsColorGradingSettings &settings );
287
288 static const QString sForwardRenderView;
289 static const QString sShadowRenderView;
290 static const QString sAxiS3DRenderView;
291 static const QString sDepthRenderView;
292 static const QString sOverlayRenderView;
294 static const QString sAmbientOcclusionRenderView;
295 static const QString sBloomRenderView;
297 static const QString sPostprocRenderView;
298 static const QString sHighlightsRenderView;
299 static const QString sRubberRenderView;
300
301 private:
302 Qt3DRender::QRenderSurfaceSelector *mRenderSurfaceSelector = nullptr;
303 Qt3DRender::QViewport *mMainViewPort = nullptr;
304
305 Qt3DRender::QCamera *mMainCamera = nullptr;
306
307 // Storage for global parameters
308 // QRenderPassFilter has dual usage -- one for storage of filtering keys,
309 // the other for storage of parameters for use in shaders. Here we are
310 // using it for storage of parameters only, not for filtering!
311 Qt3DRender::QRenderPassFilter *mGlobalParamsStorage = nullptr;
312
313 // Separate thumbnail capture pass to save scaled-down images of the
314 // rendered view to aid in debugging (e.g., Tracy profiler frame images).
315 Qt3DRender::QRenderCapture *mThumbnailCapture = nullptr;
316 Qt3DRender::QTexture2D *mThumbnailTexture = nullptr;
317
318 QSize mSize = QSize( 1024, 768 );
319
320 QVector3D mLightDirection = QVector3D( 0.0, -1.0f, 0.0f );
321
322 Qt3DCore::QEntity *mRootEntity = nullptr;
323
325 QgsOverlayTextureEntity *mDepthTextureDebugging = nullptr;
326
327 void constructShadowRenderPass();
328 void constructForwardRenderPass();
329 void constructHighlightsPass();
330 void constructOverlayTexturePass( Qt3DRender::QFrameGraphNode *topNode = nullptr );
331 void constructPostprocessingPass( Qt3DRender::QFrameGraphNode *topNode = nullptr );
332 void constructDepthRenderPass();
333 void constructAmbientOcclusionRenderPass();
334 void constructBloomRenderPass();
335 void constructRubberBandsPass( Qt3DRender::QFrameGraphNode *topNode = nullptr );
336 void constructMsaaBlitNodes();
337
338 void constructThumbnailCapturePass();
339 void updateThumbnailTextureSize();
340 void onThumbnailCaptureCompleted( Qt3DRender::QRenderCaptureReply *reply );
341
342 bool mMsaaEnabled = false;
343 bool mMsaaBlitConfigured = false;
344 Qt3DRender::QBlitFramebuffer *mMsaaBlitNode = nullptr;
345 Qt3DRender::QBlitFramebuffer *mMsaaDepthBlitNode = nullptr;
346 Qt3DRender::QClearBuffers *mMsaaClearBuffers = nullptr;
347
348 // holds renderviews according to their name
349 std::map<QString, std::unique_ptr<QgsAbstractRenderView>> mRenderViewMap;
350
351 Q_DISABLE_COPY( QgsFrameGraph )
352};
353
354#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
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.
static const QString sRubberRenderView
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 rubberband rendering.
Container class that holds different objects related to shadow rendering.
Contains configuration for rendering shadows.