QGIS API Documentation 4.1.0-Master (ca2ac17535b)
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;
66class QgsRectangle;
72
83class _3D_EXPORT QgsFrameGraph : public Qt3DCore::QEntity
84{
85 Q_OBJECT
86
87 public:
89 QgsFrameGraph( QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root );
90
92 Qt3DRender::QFrameGraphNode *frameGraphRoot() { return mRenderSurfaceSelector; }
93
95 Qt3DRender::QCamera *mainCamera() { return mMainCamera; }
96
98 QgsPostprocessingEntity *postprocessingEntity() { return mPostprocessingEntity; }
99
101 Qt3DCore::QEntity *rubberBandsRootEntity() { return mRubberBandsRootEntity; }
102
104 Qt3DRender::QRenderCapture *renderCapture();
105
107 Qt3DRender::QRenderCapture *depthRenderCapture();
108
110 void addGlobalParameters( const QList<Qt3DRender::QParameter *> &parameters );
111
113 void setFrustumCullingEnabled( bool enabled );
114
116 void setClearColor( const QColor &clearColor );
117
119 void setSize( QSize s );
120
125 void setRenderCaptureEnabled( bool enabled );
126
131 void setDebugOverlayEnabled( bool enabled );
132
137 void setMsaaEnabled( bool enabled );
138
143 bool msaaEnabled() const { return mMsaaEnabled; }
144
146 QString dumpFrameGraph() const;
147
149 QString dumpSceneGraph() const;
150
158 void addClipPlanes( int nrClipPlanes );
159
166 void removeClipPlanes();
167
175 bool registerRenderView( std::unique_ptr<QgsAbstractRenderView> renderView, const QString &name, Qt3DRender::QFrameGraphNode *topNode = nullptr );
176
181 void unregisterRenderView( const QString &name );
182
187 void setRenderViewEnabled( const QString &name, bool enable );
188
193 bool isRenderViewEnabled( const QString &name );
194
199 QgsAbstractRenderView *renderView( const QString &name );
200
205 QgsShadowRenderView &shadowRenderView();
206
211 QgsForwardRenderView &forwardRenderView();
212
217 QgsDepthRenderView &depthRenderView();
218
223 QgsAmbientOcclusionRenderView &ambientOcclusionRenderView();
224
229 QgsBloomRenderView &bloomRenderView();
230
235 QgsOverlayTextureRenderView &overlayTextureRenderView();
236
241 QgsHighlightsRenderView &highlightsRenderView();
242
247 void updateShadowSettings( const Qgs3DMapSettings &mapSettings );
248
253 void updateDebugDepthMapSettings( const Qgs3DMapSettings &settings );
254
259 void updateAmbientOcclusionSettings( const QgsAmbientOcclusionSettings &settings );
260
265 void updateEyeDomeSettings( const Qgs3DMapSettings &settings );
266
271 void updateBloomSettings( const QgsBloomSettings &settings );
272
278 void updateColorGradingSettings( const QgsColorGradingSettings &settings );
279
280 static const QString FORWARD_RENDERVIEW;
281 static const QString SHADOW_RENDERVIEW;
282 static const QString AXIS3D_RENDERVIEW;
283 static const QString DEPTH_RENDERVIEW;
284 static const QString OVERLAY_RENDERVIEW;
286 static const QString AMBIENT_OCCLUSION_RENDERVIEW;
287 static const QString BLOOM_RENDERVIEW;
288 static const QString HIGHLIGHTS_RENDERVIEW;
289
290 private:
291 Qt3DRender::QRenderSurfaceSelector *mRenderSurfaceSelector = nullptr;
292 Qt3DRender::QViewport *mMainViewPort = nullptr;
293
294 Qt3DRender::QCamera *mMainCamera = nullptr;
295
296 // Storage for global parameters
297 // QRenderPassFilter has dual usage -- one for storage of filtering keys,
298 // the other for storage of parameters for use in shaders. Here we are
299 // using it for storage of parameters only, not for filtering!
300 Qt3DRender::QRenderPassFilter *mGlobalParamsStorage = nullptr;
301
302 // Post processing pass branch nodes:
303 Qt3DRender::QRenderTargetSelector *mRenderCaptureTargetSelector = nullptr;
304 Qt3DRender::QRenderCapture *mRenderCapture = nullptr;
305 // Post processing pass texture related objects:
306 Qt3DRender::QTexture2D *mRenderCaptureColorTexture = nullptr;
307 Qt3DRender::QTexture2D *mRenderCaptureDepthTexture = nullptr;
308
309 // Separate thumbnail capture pass to save scaled-down images of the
310 // rendered view to aid in debugging (e.g., Tracy profiler frame images).
311 Qt3DRender::QRenderCapture *mThumbnailCapture = nullptr;
312 Qt3DRender::QTexture2D *mThumbnailTexture = nullptr;
313
314 // Rubber bands pass
315 Qt3DRender::QCameraSelector *mRubberBandsCameraSelector = nullptr;
316 Qt3DRender::QLayerFilter *mRubberBandsLayerFilter = nullptr;
317 Qt3DRender::QRenderStateSet *mRubberBandsStateSet = nullptr;
318 Qt3DRender::QRenderTargetSelector *mRubberBandsRenderTargetSelector = nullptr;
319
320 QSize mSize = QSize( 1024, 768 );
321
322 QVector3D mLightDirection = QVector3D( 0.0, -1.0f, 0.0f );
323
324 Qt3DCore::QEntity *mRootEntity = nullptr;
325
326 Qt3DRender::QLayer *mRubberBandsLayer = nullptr;
327
328 QgsPostprocessingEntity *mPostprocessingEntity = nullptr;
329
330 Qt3DCore::QEntity *mRubberBandsRootEntity = nullptr;
331
333 QgsOverlayTextureEntity *mDepthTextureDebugging = nullptr;
334
335 void constructShadowRenderPass();
336 void constructForwardRenderPass();
337 void constructHighlightsPass();
338 void constructOverlayTexturePass( Qt3DRender::QFrameGraphNode *topNode = nullptr );
339 Qt3DRender::QFrameGraphNode *constructPostprocessingPass();
340 void constructDepthRenderPass();
341 void constructAmbientOcclusionRenderPass();
342 void constructBloomRenderPass();
343 Qt3DRender::QFrameGraphNode *constructRubberBandsPass();
344 void constructMsaaBlitNodes();
345
346 Qt3DRender::QFrameGraphNode *constructSubPostPassForProcessing();
347 Qt3DRender::QFrameGraphNode *constructSubPostPassForRenderCapture();
348
349 void constructThumbnailCapturePass();
350 void updateThumbnailTextureSize();
351 void onThumbnailCaptureCompleted( Qt3DRender::QRenderCaptureReply *reply );
352
353 bool mRenderCaptureEnabled = false;
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.
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.