QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgsmetalroughmaterial.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmetalroughmaterial.h
3 --------------------------------------
4 Date : December 2023
5 Copyright : (C) 2023 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
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 QGSMETALROUGHMATERIAL_H
17#define QGSMETALROUGHMATERIAL_H
18
19#include "qgis_3d.h"
20#include "qgsmaterial.h"
21
22#include <QObject>
23
24#define SIP_NO_FILE
25
26// adapted from Qt's qmetalroughmaterial.h
27namespace Qt3DRender
28{
29
30 class QFilterKey;
31 class QEffect;
32 class QAbstractTexture;
33 class QTechnique;
34 class QParameter;
35 class QShaderProgram;
36 class QShaderProgramBuilder;
37 class QRenderPass;
38
39} // namespace Qt3DRender
40
42
48class _3D_EXPORT QgsMetalRoughMaterial : public QgsMaterial
49{
50 Q_OBJECT
51 public:
52
56 explicit QgsMetalRoughMaterial( Qt3DCore::QNode *parent = nullptr );
57 ~QgsMetalRoughMaterial() override;
58
59 QVariant baseColor() const;
60 QVariant metalness() const;
61 QVariant roughness() const;
62 QVariant ambientOcclusion() const;
63 QVariant normal() const;
64 float textureScale() const;
65
73 bool flatShadingEnabled() const;
74
75 public slots:
76 void setBaseColor( const QVariant &baseColor );
77 void setMetalness( const QVariant &metalness );
78 void setRoughness( const QVariant &roughness );
79 void setAmbientOcclusion( const QVariant &ambientOcclusion );
80 void setNormal( const QVariant &normal );
81 void setTextureScale( float textureScale );
82 void setFlatShadingEnabled( bool enabled );
83
84 signals:
85 void baseColorChanged( const QVariant &baseColor );
86 void metalnessChanged( const QVariant &metalness );
87 void roughnessChanged( const QVariant &roughness );
88 void ambientOcclusionChanged( const QVariant &ambientOcclusion );
89 void normalChanged( const QVariant &normal );
90 void textureScaleChanged( float textureScale );
91
92 private:
93 void init();
94
95 void handleTextureScaleChanged( const QVariant &var );
96 void updateFragmentShader();
97
98 Qt3DRender::QParameter *mBaseColorParameter = nullptr;
99 Qt3DRender::QParameter *mMetalnessParameter = nullptr;
100 Qt3DRender::QParameter *mRoughnessParameter = nullptr;
101 Qt3DRender::QParameter *mBaseColorMapParameter = nullptr;
102 Qt3DRender::QParameter *mMetalnessMapParameter = nullptr;
103 Qt3DRender::QParameter *mRoughnessMapParameter = nullptr;
104 Qt3DRender::QParameter *mAmbientOcclusionMapParameter = nullptr;
105 Qt3DRender::QParameter *mNormalMapParameter = nullptr;
106 Qt3DRender::QParameter *mTextureScaleParameter = nullptr;
107 Qt3DRender::QEffect *mMetalRoughEffect = nullptr;
108 Qt3DRender::QTechnique *mMetalRoughGL3Technique = nullptr;
109 Qt3DRender::QRenderPass *mMetalRoughGL3RenderPass = nullptr;
110 Qt3DRender::QShaderProgram *mMetalRoughGL3Shader = nullptr;
111 Qt3DRender::QFilterKey *mFilterKey = nullptr;
112 bool mUsingBaseColorMap = false;
113 bool mUsingMetalnessMap = false;
114 bool mUsingRoughnessMap = false;
115 bool mUsingAmbientOcclusionMap = false;
116 bool mUsingNormalMap = false;
117 bool mFlatShading = false;
118
119};
120
122
123#endif // QGSMETALROUGHMATERIAL_H