QGIS API Documentation 3.41.0-Master (cea29feecf2)
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:
55 explicit QgsMetalRoughMaterial( Qt3DCore::QNode *parent = nullptr );
56 ~QgsMetalRoughMaterial() override;
57
58 QVariant baseColor() const;
59 QVariant metalness() const;
60 QVariant roughness() const;
61 QVariant ambientOcclusion() const;
62 QVariant normal() const;
63 float textureScale() const;
64
72 bool flatShadingEnabled() const;
73
74 public slots:
75 void setBaseColor( const QVariant &baseColor );
76 void setMetalness( const QVariant &metalness );
77 void setRoughness( const QVariant &roughness );
78 void setAmbientOcclusion( const QVariant &ambientOcclusion );
79 void setNormal( const QVariant &normal );
80 void setTextureScale( float textureScale );
81 void setFlatShadingEnabled( bool enabled );
82
83 signals:
84 void baseColorChanged( const QVariant &baseColor );
85 void metalnessChanged( const QVariant &metalness );
86 void roughnessChanged( const QVariant &roughness );
87 void ambientOcclusionChanged( const QVariant &ambientOcclusion );
88 void normalChanged( const QVariant &normal );
89 void textureScaleChanged( float textureScale );
90
91 private:
92 void init();
93
94 void handleTextureScaleChanged( const QVariant &var );
95 void updateFragmentShader();
96
97 Qt3DRender::QParameter *mBaseColorParameter = nullptr;
98 Qt3DRender::QParameter *mMetalnessParameter = nullptr;
99 Qt3DRender::QParameter *mRoughnessParameter = nullptr;
100 Qt3DRender::QParameter *mBaseColorMapParameter = nullptr;
101 Qt3DRender::QParameter *mMetalnessMapParameter = nullptr;
102 Qt3DRender::QParameter *mRoughnessMapParameter = nullptr;
103 Qt3DRender::QParameter *mAmbientOcclusionMapParameter = nullptr;
104 Qt3DRender::QParameter *mNormalMapParameter = nullptr;
105 Qt3DRender::QParameter *mTextureScaleParameter = nullptr;
106 Qt3DRender::QEffect *mMetalRoughEffect = nullptr;
107 Qt3DRender::QTechnique *mMetalRoughGL3Technique = nullptr;
108 Qt3DRender::QRenderPass *mMetalRoughGL3RenderPass = nullptr;
109 Qt3DRender::QShaderProgram *mMetalRoughGL3Shader = nullptr;
110 Qt3DRender::QFilterKey *mFilterKey = nullptr;
111 bool mUsingBaseColorMap = false;
112 bool mUsingMetalnessMap = false;
113 bool mUsingRoughnessMap = false;
114 bool mUsingAmbientOcclusionMap = false;
115 bool mUsingNormalMap = false;
116 bool mFlatShading = false;
117};
118
120
121#endif // QGSMETALROUGHMATERIAL_H