31 Q_PROPERTY(Lighting lighting READ lighting WRITE setLighting NOTIFY lightingChanged)
32 Q_PROPERTY(BlendMode blendMode READ blendMode WRITE setBlendMode NOTIFY blendModeChanged)
34 Q_PROPERTY(QColor diffuseColor READ diffuseColor WRITE setDiffuseColor NOTIFY diffuseColorChanged)
35 Q_PROPERTY(QQuick3DTexture *diffuseMap READ diffuseMap WRITE setDiffuseMap NOTIFY diffuseMapChanged)
37 Q_PROPERTY(QVector3D emissiveFactor READ emissiveFactor WRITE setEmissiveFactor NOTIFY emissiveFactorChanged)
38 Q_PROPERTY(QQuick3DTexture *emissiveMap READ emissiveMap WRITE setEmissiveMap NOTIFY emissiveMapChanged)
40 Q_PROPERTY(QQuick3DTexture *specularReflectionMap READ specularReflectionMap WRITE setSpecularReflectionMap NOTIFY specularReflectionMapChanged)
41 Q_PROPERTY(QQuick3DTexture *specularMap READ specularMap WRITE setSpecularMap NOTIFY specularMapChanged)
42 Q_PROPERTY(SpecularModel specularModel READ specularModel WRITE setSpecularModel NOTIFY specularModelChanged)
43 Q_PROPERTY(QColor specularTint READ specularTint WRITE setSpecularTint NOTIFY specularTintChanged)
45 Q_PROPERTY(
float indexOfRefraction READ indexOfRefraction WRITE setIndexOfRefraction NOTIFY indexOfRefractionChanged)
46 Q_PROPERTY(
float fresnelPower READ fresnelPower WRITE setFresnelPower NOTIFY fresnelPowerChanged)
47 Q_PROPERTY(
float specularAmount READ specularAmount WRITE setSpecularAmount NOTIFY specularAmountChanged)
48 Q_PROPERTY(
float specularRoughness READ specularRoughness WRITE setSpecularRoughness NOTIFY specularRoughnessChanged)
49 Q_PROPERTY(QQuick3DTexture *roughnessMap READ roughnessMap WRITE setRoughnessMap NOTIFY roughnessMapChanged)
50 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping roughnessChannel READ roughnessChannel WRITE setRoughnessChannel NOTIFY roughnessChannelChanged)
52 Q_PROPERTY(
float opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
53 Q_PROPERTY(QQuick3DTexture *opacityMap READ opacityMap WRITE setOpacityMap NOTIFY opacityMapChanged)
54 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping opacityChannel READ opacityChannel WRITE setOpacityChannel NOTIFY opacityChannelChanged)
56 Q_PROPERTY(QQuick3DTexture *bumpMap READ bumpMap WRITE setBumpMap NOTIFY bumpMapChanged)
57 Q_PROPERTY(
float bumpAmount READ bumpAmount WRITE setBumpAmount NOTIFY bumpAmountChanged)
59 Q_PROPERTY(QQuick3DTexture *normalMap READ normalMap WRITE setNormalMap NOTIFY normalMapChanged)
61 Q_PROPERTY(QQuick3DTexture *translucencyMap READ translucencyMap WRITE setTranslucencyMap NOTIFY translucencyMapChanged)
62 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping translucencyChannel READ translucencyChannel WRITE setTranslucencyChannel NOTIFY translucencyChannelChanged)
63 Q_PROPERTY(
float translucentFalloff READ translucentFalloff WRITE setTranslucentFalloff NOTIFY translucentFalloffChanged)
65 Q_PROPERTY(
float diffuseLightWrap READ diffuseLightWrap WRITE setDiffuseLightWrap NOTIFY diffuseLightWrapChanged)
67 Q_PROPERTY(
bool vertexColorsEnabled READ vertexColorsEnabled WRITE setVertexColorsEnabled NOTIFY vertexColorsEnabledChanged)
69 Q_PROPERTY(
float pointSize READ pointSize WRITE setPointSize NOTIFY pointSizeChanged)
70 Q_PROPERTY(
float lineWidth READ lineWidth WRITE setLineWidth NOTIFY lineWidthChanged)
72 QML_NAMED_ELEMENT(DefaultMaterial)
75 enum Lighting { NoLighting = 0, FragmentLighting };
78 enum BlendMode { SourceOver = 0, Screen, Multiply };
81 enum SpecularModel { Default = 0, KGGX };
84 explicit QQuick3DDefaultMaterial(QQuick3DObject *parent =
nullptr);
85 ~QQuick3DDefaultMaterial() override;
87 Lighting lighting()
const;
88 BlendMode blendMode()
const;
89 QColor diffuseColor()
const;
90 QQuick3DTexture *diffuseMap()
const;
91 QVector3D emissiveFactor()
const;
92 QQuick3DTexture *emissiveMap()
const;
93 QQuick3DTexture *specularReflectionMap()
const;
94 QQuick3DTexture *specularMap()
const;
95 SpecularModel specularModel()
const;
96 QColor specularTint()
const;
97 float indexOfRefraction()
const;
98 float fresnelPower()
const;
99 float specularAmount()
const;
100 float specularRoughness()
const;
101 QQuick3DTexture *roughnessMap()
const;
102 float opacity()
const;
103 QQuick3DTexture *opacityMap()
const;
104 QQuick3DTexture *bumpMap()
const;
105 float bumpAmount()
const;
106 QQuick3DTexture *normalMap()
const;
108 QQuick3DTexture *translucencyMap()
const;
109 float translucentFalloff()
const;
110 float diffuseLightWrap()
const;
111 bool vertexColorsEnabled()
const;
112 TextureChannelMapping roughnessChannel()
const;
113 TextureChannelMapping opacityChannel()
const;
114 TextureChannelMapping translucencyChannel()
const;
116 float pointSize()
const;
117 float lineWidth()
const;
121 void setLighting(QQuick3DDefaultMaterial::Lighting lighting);
122 void setBlendMode(QQuick3DDefaultMaterial::BlendMode blendMode);
123 void setDiffuseColor(QColor diffuseColor);
124 void setDiffuseMap(QQuick3DTexture *diffuseMap);
125 void setEmissiveFactor(QVector3D emissiveFactor);
126 void setEmissiveMap(QQuick3DTexture *emissiveMap);
128 void setSpecularReflectionMap(QQuick3DTexture *specularReflectionMap);
129 void setSpecularMap(QQuick3DTexture *specularMap);
130 void setSpecularModel(QQuick3DDefaultMaterial::SpecularModel specularModel);
131 void setSpecularTint(QColor specularTint);
132 void setIndexOfRefraction(
float indexOfRefraction);
133 void setFresnelPower(
float fresnelPower);
134 void setSpecularAmount(
float specularAmount);
135 void setSpecularRoughness(
float specularRoughness);
136 void setRoughnessMap(QQuick3DTexture *roughnessMap);
137 void setOpacity(
float opacity);
138 void setOpacityMap(QQuick3DTexture *opacityMap);
139 void setBumpMap(QQuick3DTexture *bumpMap);
140 void setBumpAmount(
float bumpAmount);
141 void setNormalMap(QQuick3DTexture *normalMap);
143 void setTranslucencyMap(QQuick3DTexture *translucencyMap);
144 void setTranslucentFalloff(
float translucentFalloff);
145 void setDiffuseLightWrap(
float diffuseLightWrap);
146 void setVertexColorsEnabled(
bool vertexColorsEnabled);
148 void setRoughnessChannel(QQuick3DMaterial::TextureChannelMapping channel);
149 void setOpacityChannel(QQuick3DMaterial::TextureChannelMapping channel);
150 void setTranslucencyChannel(QQuick3DMaterial::TextureChannelMapping channel);
152 void setPointSize(
float size);
153 void setLineWidth(
float width);
156 void lightingChanged(QQuick3DDefaultMaterial::Lighting lighting);
157 void blendModeChanged(QQuick3DDefaultMaterial::BlendMode blendMode);
158 void diffuseColorChanged(QColor diffuseColor);
159 void diffuseMapChanged(QQuick3DTexture *diffuseMap);
160 void emissiveFactorChanged(QVector3D emissiveFactor);
161 void emissiveMapChanged(QQuick3DTexture *emissiveMap);
162 void specularReflectionMapChanged(QQuick3DTexture *specularReflectionMap);
163 void specularMapChanged(QQuick3DTexture *specularMap);
164 void specularModelChanged(QQuick3DDefaultMaterial::SpecularModel specularModel);
165 void specularTintChanged(QColor specularTint);
166 void indexOfRefractionChanged(
float indexOfRefraction);
167 void fresnelPowerChanged(
float fresnelPower);
168 void specularAmountChanged(
float specularAmount);
169 void specularRoughnessChanged(
float specularRoughness);
170 void roughnessMapChanged(QQuick3DTexture *roughnessMap);
171 void opacityChanged(
float opacity);
172 void opacityMapChanged(QQuick3DTexture *opacityMap);
173 void bumpMapChanged(QQuick3DTexture *bumpMap);
174 void bumpAmountChanged(
float bumpAmount);
175 void normalMapChanged(QQuick3DTexture *normalMap);
176 void translucencyMapChanged(QQuick3DTexture *translucencyMap);
177 void translucentFalloffChanged(
float translucentFalloff);
178 void diffuseLightWrapChanged(
float diffuseLightWrap);
179 void vertexColorsEnabledChanged(
bool vertexColorsEnabled);
180 void roughnessChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
181 void opacityChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
182 void translucencyChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
183 void pointSizeChanged();
184 void lineWidthChanged();
187 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
188 void markAllDirty() override;
189 void itemChange(ItemChange,
const ItemChangeData &) override;
192 LightingModeDirty = 0x00000001,
193 BlendModeDirty = 0x00000002,
194 DiffuseDirty = 0x00000004,
195 EmissiveDirty = 0x00000008,
196 SpecularDirty = 0x00000010,
197 OpacityDirty = 0x00000020,
198 BumpDirty = 0x00000040,
199 NormalDirty = 0x00000080,
200 TranslucencyDirty = 0x00000100,
201 VertexColorsDirty = 0x00000200,
202 PointSizeDirty = 0x00000400,
203 LineWidthDirty = 0x00000800
206 void updateSceneManager(QQuick3DSceneManager *sceneManager);
207 Lighting m_lighting = FragmentLighting;
208 BlendMode m_blendMode = SourceOver;
209 QColor m_diffuseColor;
210 QQuick3DTexture *m_diffuseMap =
nullptr;
211 QVector3D m_emissiveFactor;
212 QQuick3DTexture *m_emissiveMap =
nullptr;
214 QQuick3DTexture *m_specularReflectionMap =
nullptr;
215 QQuick3DTexture *m_specularMap =
nullptr;
216 SpecularModel m_specularModel = Default;
217 QColor m_specularTint;
218 float m_indexOfRefraction = 1.45f;
219 float m_fresnelPower = 0.0f;
220 float m_specularAmount = 0.0f;
221 float m_specularRoughness = 0.0f;
222 QQuick3DTexture *m_roughnessMap =
nullptr;
223 float m_opacity = 1.0f;
224 QQuick3DTexture *m_opacityMap =
nullptr;
225 QQuick3DTexture *m_bumpMap =
nullptr;
226 float m_bumpAmount = 0.0f;
227 QQuick3DTexture *m_normalMap =
nullptr;
229 QQuick3DTexture *m_translucencyMap =
nullptr;
230 float m_translucentFalloff = 0.0f;
231 float m_diffuseLightWrap = 0.0f;
232 bool m_vertexColorsEnabled =
false;
234 TextureChannelMapping m_roughnessChannel = QQuick3DMaterial::R;
235 TextureChannelMapping m_opacityChannel = QQuick3DMaterial::A;
236 TextureChannelMapping m_translucencyChannel = QQuick3DMaterial::A;
238 float m_pointSize = 1.0f;
239 float m_lineWidth = 1.0f;
241 quint32 m_dirtyAttributes = 0xffffffff;
242 void markDirty(DirtyType type);