1 /*************************************************************************** 2 qgspostprocessingentity.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 QGSPOSTPROCESSINGENTITY_H 17 #define QGSPOSTPROCESSINGENTITY_H 18 19 #include <Qt3DCore/QEntity> 20 #include <Qt3DRender/QTexture> 21 #include <Qt3DRender/QMaterial> 22 #include <Qt3DRender/QEffect> 23 #include <Qt3DRender/QCamera> 24 25 class QgsShadowRenderingFrameGraph; 26 27 #define SIP_NO_FILE 28 29 /** 30 * \ingroup 3d 31 * \brief An entity that is responsible for applying post processing effect. 32 * 33 * Now it is used to make shadows. 34 * 35 * \note Not available in Python bindings 36 * 37 * \since QGIS 3.16 38 */ 39 class QgsPostprocessingEntity : public Qt3DCore::QEntity 40 { 41 public: 42 //! Constructor 43 QgsPostprocessingEntity( QgsShadowRenderingFrameGraph *frameGraph, QNode *parent = nullptr ); 44 //! Sets the parts of the scene where objects cast shadows 45 void setupShadowRenderingExtent( float minX, float maxX, float minZ, float maxZ ); 46 //! Sets up a directional light that is used to render shadows 47 void setupDirectionalLight( QVector3D position, QVector3D direction ); 48 //! Sets whether shadow rendering is enabled 49 void setShadowRenderingEnabled( bool enabled ); 50 //! Sets the shadow bias value 51 void setShadowBias( float shadowBias ); 52 //! Sets whether eye dome lighting is enabled 53 void setEyeDomeLightingEnabled( bool enabled ); 54 //! Sets the eye dome lighting strength 55 void setEyeDomeLightingStrength( double strength ); 56 //! Sets the eye dome lighting distance (contributes to the contrast of the image) 57 void setEyeDomeLightingDistance( int distance ); 58 private: 59 Qt3DRender::QMaterial *mMaterial = nullptr; 60 Qt3DRender::QEffect *mEffect = nullptr; 61 Qt3DRender::QParameter *mColorTextureParameter = nullptr; 62 Qt3DRender::QParameter *mDepthTextureParameter = nullptr; 63 Qt3DRender::QParameter *mShadowMapParameter = nullptr; 64 Qt3DRender::QCamera *mMainCamera = nullptr; 65 Qt3DRender::QParameter *mFarPlaneParameter = nullptr; 66 Qt3DRender::QParameter *mNearPlaneParameter = nullptr; 67 Qt3DRender::QParameter *mMainCameraInvViewMatrixParameter = nullptr; 68 Qt3DRender::QParameter *mMainCameraInvProjMatrixParameter = nullptr; 69 70 Qt3DRender::QCamera *mLightCamera = nullptr; 71 Qt3DRender::QParameter *mLightFarPlaneParameter = nullptr; 72 Qt3DRender::QParameter *mLightNearPlaneParameter = nullptr; 73 74 Qt3DRender::QParameter *mLightPosition = nullptr; 75 Qt3DRender::QParameter *mLightDirection = nullptr; 76 77 Qt3DRender::QParameter *mShadowMinX = nullptr; 78 Qt3DRender::QParameter *mShadowMaxX = nullptr; 79 Qt3DRender::QParameter *mShadowMinZ = nullptr; 80 Qt3DRender::QParameter *mShadowMaxZ = nullptr; 81 82 Qt3DRender::QParameter *mRenderShadowsParameter = nullptr; 83 Qt3DRender::QParameter *mShadowBiasParameter = nullptr; 84 Qt3DRender::QParameter *mEyeDomeLightingEnabledParameter = nullptr; 85 Qt3DRender::QParameter *mEyeDomeLightingStrengthParameter = nullptr; 86 Qt3DRender::QParameter *mEyeDomeLightingDistanceParameter = nullptr; 87 }; 88 89 #endif // QGSPOSTPROCESSINGENTITY_H 90