QGIS API Documentation 4.1.0-Master (06b85429c24)
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 // Separate thumbnail capture pass to save scaled-down images of the
309 // rendered view to aid in debugging (e.g., Tracy profiler frame images).
310 Qt3DRender::QRenderCapture *mThumbnailCapture = nullptr;
311 Qt3DRender::QTexture2D *mThumbnailTexture = nullptr;
312
313 // Rubber bands pass
314 Qt3DRender::QCameraSelector *mRubberBandsCameraSelector = nullptr;
315 Qt3DRender::QLayerFilter *mRubberBandsLayerFilter = nullptr;
316 Qt3DRender::QRenderStateSet *mRubberBandsStateSet = nullptr;
317 Qt3DRender::QRenderTargetSelector *mRubberBandsRenderTargetSelector = nullptr;
318
319 QSize mSize = QSize( 1024, 768 );
320
321 QVector3D mLightDirection = QVector3D( 0.0, -1.0f, 0.0f );
322
323 Qt3DCore::QEntity *mRootEntity = nullptr;
324
325 Qt3DRender::QLayer *mRubberBandsLayer = nullptr;
326
327 Qt3DCore::QEntity *mRubberBandsRootEntity = nullptr;
328
330 QgsOverlayTextureEntity *mDepthTextureDebugging = nullptr;
331
332 void constructShadowRenderPass();
333 void constructForwardRenderPass();
334 void constructHighlightsPass();
335 void constructOverlayTexturePass( Qt3DRender::QFrameGraphNode *topNode = nullptr );
336 void constructPostprocessingPass( Qt3DRender::QFrameGraphNode *topNode = nullptr );
337 void constructDepthRenderPass();
338 void constructAmbientOcclusionRenderPass();
339 void constructBloomRenderPass();
340 Qt3DRender::QFrameGraphNode *constructRubberBandsPass();
341 void constructMsaaBlitNodes();
342
343 void constructThumbnailCapturePass();
344 void updateThumbnailTextureSize();
345 void onThumbnailCaptureCompleted( Qt3DRender::QRenderCaptureReply *reply );
346
347 bool mMsaaEnabled = false;
348 bool mMsaaBlitConfigured = false;
349 Qt3DRender::QBlitFramebuffer *mMsaaBlitNode = nullptr;
350 Qt3DRender::QBlitFramebuffer *mMsaaDepthBlitNode = nullptr;
351
352 // holds renderviews according to their name
353 std::map<QString, std::unique_ptr<QgsAbstractRenderView>> mRenderViewMap;
354
355 Q_DISABLE_COPY( QgsFrameGraph )
356};
357
358#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.