Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquick3dprincipledmaterial_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
6#ifndef QSSGPRINCIPLEDMATERIAL_H
7#define QSSGPRINCIPLEDMATERIAL_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtQuick3D/private/qquick3dmaterial_p.h>
21#include <QtQuick3D/private/qquick3dtexture_p.h>
22
23#include <QColor>
24#include <QHash>
25
27
28class Q_QUICK3D_EXPORT QQuick3DPrincipledMaterial : public QQuick3DMaterial
29{
30 Q_OBJECT
31 Q_PROPERTY(Lighting lighting READ lighting WRITE setLighting NOTIFY lightingChanged)
32 Q_PROPERTY(BlendMode blendMode READ blendMode WRITE setBlendMode NOTIFY blendModeChanged)
33
34 Q_PROPERTY(QColor baseColor READ baseColor WRITE setBaseColor NOTIFY baseColorChanged)
35 Q_PROPERTY(QQuick3DTexture *baseColorMap READ baseColorMap WRITE setBaseColorMap NOTIFY baseColorMapChanged)
36 Q_PROPERTY(bool baseColorSingleChannelEnabled READ baseColorSingleChannelEnabled WRITE setBaseColorSingleChannelEnabled NOTIFY baseColorSingleChannelEnabledChanged REVISION(6, 8))
37 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping baseColorChannel READ baseColorChannel WRITE setBaseColorChannel NOTIFY baseColorChannelChanged REVISION(6, 8))
38
39 Q_PROPERTY(float metalness READ metalness WRITE setMetalness NOTIFY metalnessChanged)
40 Q_PROPERTY(QQuick3DTexture *metalnessMap READ metalnessMap WRITE setMetalnessMap NOTIFY metalnessMapChanged)
41 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping metalnessChannel READ metalnessChannel WRITE setMetalnessChannel NOTIFY metalnessChannelChanged)
42
43 Q_PROPERTY(float specularAmount READ specularAmount WRITE setSpecularAmount NOTIFY specularAmountChanged)
44 Q_PROPERTY(QQuick3DTexture *specularMap READ specularMap WRITE setSpecularMap NOTIFY specularMapChanged)
45 Q_PROPERTY(float specularTint READ specularTint WRITE setSpecularTint NOTIFY specularTintChanged)
46 Q_PROPERTY(bool specularSingleChannelEnabled READ specularSingleChannelEnabled WRITE setSpecularSingleChannelEnabled NOTIFY specularSingleChannelEnabledChanged REVISION(6, 8))
47 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping specularChannel READ specularChannel WRITE setSpecularChannel NOTIFY specularChannelChanged REVISION(6, 8))
48
49 Q_PROPERTY(float roughness READ roughness WRITE setRoughness NOTIFY roughnessChanged)
50 Q_PROPERTY(QQuick3DTexture *roughnessMap READ roughnessMap WRITE setRoughnessMap NOTIFY roughnessMapChanged)
51 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping roughnessChannel READ roughnessChannel WRITE setRoughnessChannel NOTIFY roughnessChannelChanged)
52
53 Q_PROPERTY(QVector3D emissiveFactor READ emissiveFactor WRITE setEmissiveFactor NOTIFY emissiveFactorChanged)
54 Q_PROPERTY(QQuick3DTexture *emissiveMap READ emissiveMap WRITE setEmissiveMap NOTIFY emissiveMapChanged)
55 Q_PROPERTY(bool emissiveSingleChannelEnabled READ emissiveSingleChannelEnabled WRITE setEmissiveSingleChannelEnabled NOTIFY emissiveSingleChannelEnabledChanged REVISION(6, 8))
56 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping emissiveChannel READ emissiveChannel WRITE setEmissiveChannel NOTIFY emissiveChannelChanged REVISION(6, 8))
57
58 Q_PROPERTY(bool invertOpacityMapValue READ invertOpacityMapValue WRITE setInvertOpacityMapValue NOTIFY invertOpacityMapValueChanged REVISION(6, 8))
59 Q_PROPERTY(float opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
60 Q_PROPERTY(QQuick3DTexture *opacityMap READ opacityMap WRITE setOpacityMap NOTIFY opacityMapChanged)
61 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping opacityChannel READ opacityChannel WRITE setOpacityChannel NOTIFY opacityChannelChanged)
62
63 Q_PROPERTY(QQuick3DTexture *normalMap READ normalMap WRITE setNormalMap NOTIFY normalMapChanged)
64 Q_PROPERTY(float normalStrength READ normalStrength WRITE setNormalStrength NOTIFY normalStrengthChanged)
65
66 Q_PROPERTY(QQuick3DTexture *specularReflectionMap READ specularReflectionMap WRITE setSpecularReflectionMap NOTIFY specularReflectionMapChanged)
67
68 Q_PROPERTY(QQuick3DTexture *occlusionMap READ occlusionMap WRITE setOcclusionMap NOTIFY occlusionMapChanged)
69 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping occlusionChannel READ occlusionChannel WRITE setOcclusionChannel NOTIFY occlusionChannelChanged)
70 Q_PROPERTY(float occlusionAmount READ occlusionAmount WRITE setOcclusionAmount NOTIFY occlusionAmountChanged)
71
72 Q_PROPERTY(AlphaMode alphaMode READ alphaMode WRITE setAlphaMode NOTIFY alphaModeChanged)
73 Q_PROPERTY(float alphaCutoff READ alphaCutoff WRITE setAlphaCutoff NOTIFY alphaCutoffChanged)
74
75 Q_PROPERTY(float pointSize READ pointSize WRITE setPointSize NOTIFY pointSizeChanged)
76 Q_PROPERTY(float lineWidth READ lineWidth WRITE setLineWidth NOTIFY lineWidthChanged)
77
78 Q_PROPERTY(QQuick3DTexture *heightMap READ heightMap WRITE setHeightMap NOTIFY heightMapChanged REVISION(6, 2))
79 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping heightChannel READ heightChannel WRITE setHeightChannel NOTIFY heightChannelChanged REVISION(6, 2))
80 Q_PROPERTY(float heightAmount READ heightAmount WRITE setHeightAmount NOTIFY heightAmountChanged REVISION(6, 2))
81 Q_PROPERTY(int minHeightMapSamples READ minHeightMapSamples WRITE setMinHeightMapSamples NOTIFY minHeightMapSamplesChanged REVISION(6, 2))
82 Q_PROPERTY(int maxHeightMapSamples READ maxHeightMapSamples WRITE setMaxHeightMapSamples NOTIFY maxHeightMapSamplesChanged REVISION(6, 2))
83
84 Q_PROPERTY(float clearcoatAmount READ clearcoatAmount WRITE setClearcoatAmount NOTIFY clearcoatAmountChanged REVISION(6, 3))
85 Q_PROPERTY(QQuick3DTexture *clearcoatMap READ clearcoatMap WRITE setClearcoatMap NOTIFY clearcoatMapChanged REVISION(6, 3))
86 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping clearcoatChannel READ clearcoatChannel WRITE setClearcoatChannel NOTIFY
87 clearcoatChannelChanged REVISION(6, 3))
88 Q_PROPERTY(float clearcoatRoughnessAmount READ clearcoatRoughnessAmount WRITE setClearcoatRoughnessAmount NOTIFY
89 clearcoatRoughnessAmountChanged REVISION(6, 3))
90 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping clearcoatRoughnessChannel READ clearcoatRoughnessChannel WRITE
91 setClearcoatRoughnessChannel NOTIFY clearcoatRoughnessChannelChanged REVISION(6, 3))
92 Q_PROPERTY(QQuick3DTexture *clearcoatRoughnessMap READ clearcoatRoughnessMap WRITE setClearcoatRoughnessMap NOTIFY
93 clearcoatRoughnessMapChanged REVISION(6, 3))
94 Q_PROPERTY(QQuick3DTexture *clearcoatNormalMap READ clearcoatNormalMap WRITE setClearcoatNormalMap NOTIFY
95 clearcoatNormalMapChanged REVISION(6, 3))
96 Q_PROPERTY(float clearcoatNormalStrength READ clearcoatNormalStrength WRITE setClearcoatNormalStrength NOTIFY clearcoatNormalStrengthChanged REVISION(6, 8))
98 Q_PROPERTY(float transmissionFactor READ transmissionFactor WRITE setTransmissionFactor NOTIFY transmissionFactorChanged)
99 Q_PROPERTY(QQuick3DTexture * transmissionMap READ transmissionMap WRITE setTransmissionMap NOTIFY transmissionMapChanged)
100 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping transmissionChannel READ transmissionChannel WRITE setTransmissionChannel NOTIFY transmissionChannelChanged)
102 Q_PROPERTY(float thicknessFactor READ thicknessFactor WRITE setThicknessFactor NOTIFY thicknessFactorChanged REVISION(6, 3))
103 Q_PROPERTY(QQuick3DTexture *thicknessMap READ thicknessMap WRITE setThicknessMap NOTIFY thicknessMapChanged REVISION(6, 3))
104 Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping thicknessChannel READ thicknessChannel WRITE setThicknessChannel NOTIFY
105 thicknessChannelChanged REVISION(6, 3))
106 Q_PROPERTY(float attenuationDistance READ attenuationDistance WRITE setAttenuationDistance NOTIFY attenuationDistanceChanged REVISION(6, 3))
107 Q_PROPERTY(QColor attenuationColor READ attenuationColor WRITE setAttenuationColor NOTIFY attenuationColorChanged REVISION(6, 3))
109 Q_PROPERTY(float indexOfRefraction READ indexOfRefraction WRITE setIndexOfRefraction NOTIFY indexOfRefractionChanged REVISION(6, 3))
111 Q_PROPERTY(bool vertexColorsEnabled READ vertexColorsEnabled WRITE setVertexColorsEnabled NOTIFY vertexColorsEnabledChanged REVISION(6, 5))
113 Q_PROPERTY(bool fresnelScaleBiasEnabled READ fresnelScaleBiasEnabled WRITE setFresnelScaleBiasEnabled NOTIFY fresnelScaleBiasEnabledChanged REVISION(6, 8))
114 Q_PROPERTY(float fresnelScale READ fresnelScale WRITE setFresnelScale NOTIFY fresnelScaleChanged REVISION(6, 8))
115 Q_PROPERTY(float fresnelBias READ fresnelBias WRITE setFresnelBias NOTIFY fresnelBiasChanged REVISION(6, 8))
116 Q_PROPERTY(float fresnelPower READ fresnelPower WRITE setFresnelPower NOTIFY fresnelPowerChanged REVISION(6, 8))
118 Q_PROPERTY(bool clearcoatFresnelScaleBiasEnabled READ clearcoatFresnelScaleBiasEnabled WRITE setClearcoatFresnelScaleBiasEnabled NOTIFY clearcoatFresnelScaleBiasEnabledChanged REVISION(6, 8))
119 Q_PROPERTY(float clearcoatFresnelScale READ clearcoatFresnelScale WRITE setClearcoatFresnelScale NOTIFY clearcoatFresnelScaleChanged REVISION(6, 8))
120 Q_PROPERTY(float clearcoatFresnelBias READ clearcoatFresnelBias WRITE setClearcoatFresnelBias NOTIFY clearcoatFresnelBiasChanged REVISION(6, 8))
121 Q_PROPERTY(float clearcoatFresnelPower READ clearcoatFresnelPower WRITE setClearcoatFresnelPower NOTIFY clearcoatFresnelPowerChanged REVISION(6, 8))
122
123 Q_PROPERTY(bool vertexColorsMaskEnabled READ vertexColorsMaskEnabled WRITE setVertexColorsMaskEnabled NOTIFY vertexColorsMaskEnabledChanged REVISION(6, 8))
124 Q_PROPERTY(VertexColorMaskFlags vertexColorRedMask READ vertexColorRedMask WRITE setVertexColorRedMask NOTIFY vertexColorRedMaskChanged REVISION(6, 8))
125 Q_PROPERTY(VertexColorMaskFlags vertexColorGreenMask READ vertexColorGreenMask WRITE setVertexColorGreenMask NOTIFY vertexColorGreenMaskChanged REVISION(6, 8))
126 Q_PROPERTY(VertexColorMaskFlags vertexColorBlueMask READ vertexColorBlueMask WRITE setVertexColorBlueMask NOTIFY vertexColorBlueMaskChanged REVISION(6, 8))
127 Q_PROPERTY(VertexColorMaskFlags vertexColorAlphaMask READ vertexColorAlphaMask WRITE setVertexColorAlphaMask NOTIFY vertexColorAlphaMaskChanged REVISION(6, 8))
129 QML_NAMED_ELEMENT(PrincipledMaterial)
130
131public:
132 enum Lighting {
133 NoLighting = 0,
134 FragmentLighting
135 };
136 Q_ENUM(Lighting)
137
138 enum BlendMode {
139 SourceOver = 0,
140 Screen,
141 Multiply
142 };
143 Q_ENUM(BlendMode)
144
145 enum AlphaMode {
146 Default = 0,
147 Mask,
148 Blend,
149 Opaque
150 };
151 Q_ENUM(AlphaMode)
153 enum VertexColorMask {
154 NoMask = QQuick3DMaterial::NoMask,
155 RoughnessMask = QQuick3DMaterial::RoughnessMask,
156 NormalStrengthMask = QQuick3DMaterial::NormalStrengthMask,
157 SpecularAmountMask = QQuick3DMaterial::SpecularAmountMask,
158 ClearcoatAmountMask = QQuick3DMaterial::ClearcoatAmountMask,
159 ClearcoatRoughnessAmountMask = QQuick3DMaterial::ClearcoatRoughnessAmountMask,
160 ClearcoatNormalStrengthMask = QQuick3DMaterial::ClearcoatNormalStrengthMask,
161 HeightAmountMask = QQuick3DMaterial::HeightAmountMask,
162 MetalnessMask = QQuick3DMaterial::MetalnessMask,
163 OcclusionAmountMask = QQuick3DMaterial::OcclusionAmountMask,
164 ThicknessFactorMask = QQuick3DMaterial::ThicknessFactorMask,
165 TransmissionFactorMask = QQuick3DMaterial::TransmissionFactorMask
166 };
167 Q_ENUM(VertexColorMask)
168 Q_DECLARE_FLAGS(VertexColorMaskFlags, VertexColorMask)
169 Q_FLAG(VertexColorMaskFlags)
170
171 explicit QQuick3DPrincipledMaterial(QQuick3DObject *parent = nullptr);
172 ~QQuick3DPrincipledMaterial() override;
174 Lighting lighting() const;
175 BlendMode blendMode() const;
176 QColor baseColor() const;
177 QQuick3DTexture *baseColorMap() const;
178 Q_REVISION(6, 8) bool baseColorSingleChannelEnabled() const;
179 Q_REVISION(6, 8) TextureChannelMapping baseColorChannel() const;
180 Q_REVISION(6, 8) bool specularSingleChannelEnabled() const;
181 Q_REVISION(6, 8) TextureChannelMapping specularChannel() const;
182 Q_REVISION(6, 8) bool emissiveSingleChannelEnabled() const;
183 Q_REVISION(6, 8) TextureChannelMapping emissiveChannel() const;
184 QQuick3DTexture *emissiveMap() const;
185 QVector3D emissiveFactor() const;
186 QQuick3DTexture *specularReflectionMap() const;
187 QQuick3DTexture *specularMap() const;
188 float specularTint() const;
189 float specularAmount() const;
190 float roughness() const;
191 QQuick3DTexture *roughnessMap() const;
192 Q_REVISION(6, 8) bool invertOpacityMapValue() const;
193 float opacity() const;
194 QQuick3DTexture *opacityMap() const;
195 QQuick3DTexture *normalMap() const;
196 float metalness() const;
197 QQuick3DTexture *metalnessMap() const;
198 float normalStrength() const;
199 QQuick3DTexture *occlusionMap() const;
200 float occlusionAmount() const;
201 AlphaMode alphaMode() const;
202 float alphaCutoff() const;
203 TextureChannelMapping metalnessChannel() const;
204 TextureChannelMapping roughnessChannel() const;
205 TextureChannelMapping opacityChannel() const;
206 TextureChannelMapping occlusionChannel() const;
207 float pointSize() const;
208 float lineWidth() const;
209 Q_REVISION(6, 2) QQuick3DTexture *heightMap() const;
210 Q_REVISION(6, 2) TextureChannelMapping heightChannel() const;
211 Q_REVISION(6, 2) float heightAmount() const;
212 Q_REVISION(6, 2) int minHeightMapSamples() const;
213 Q_REVISION(6, 2) int maxHeightMapSamples() const;
215 Q_REVISION(6, 3) float clearcoatAmount() const;
216 Q_REVISION(6, 3) QQuick3DTexture *clearcoatMap() const;
217 Q_REVISION(6, 3) TextureChannelMapping clearcoatChannel() const;
218 Q_REVISION(6, 3) float clearcoatRoughnessAmount() const;
219 Q_REVISION(6, 3) TextureChannelMapping clearcoatRoughnessChannel() const;
220 Q_REVISION(6, 3) QQuick3DTexture *clearcoatRoughnessMap() const;
221 Q_REVISION(6, 3) QQuick3DTexture *clearcoatNormalMap() const;
222 Q_REVISION(6, 8) float clearcoatNormalStrength() const;
224 Q_REVISION(6, 3) float transmissionFactor() const;
225 Q_REVISION(6, 3) QQuick3DTexture *transmissionMap() const;
226 Q_REVISION(6, 3) TextureChannelMapping transmissionChannel() const;
227
228 Q_REVISION(6, 3) float thicknessFactor() const;
229 Q_REVISION(6, 3) QQuick3DTexture *thicknessMap() const;
230 Q_REVISION(6, 3) const TextureChannelMapping &thicknessChannel() const;
231 Q_REVISION(6, 3) float attenuationDistance() const;
232 Q_REVISION(6, 3) const QColor &attenuationColor() const;
233
234 Q_REVISION(6, 3) float indexOfRefraction() const;
235 Q_REVISION(6, 8) bool fresnelScaleBiasEnabled() const;
236 Q_REVISION(6, 8) float fresnelScale() const;
237 Q_REVISION(6, 8) float fresnelBias() const;
238 Q_REVISION(6, 8) float fresnelPower() const;
240 Q_REVISION(6, 8) bool clearcoatFresnelScaleBiasEnabled() const;
241 Q_REVISION(6, 8) float clearcoatFresnelScale() const;
242 Q_REVISION(6, 8) float clearcoatFresnelBias() const;
243 Q_REVISION(6, 8) float clearcoatFresnelPower() const;
245 Q_REVISION(6, 5) bool vertexColorsEnabled() const;
247 Q_REVISION(6, 8) bool vertexColorsMaskEnabled() const;
248
249 Q_REVISION(6, 8) VertexColorMaskFlags vertexColorRedMask() const;
250 Q_REVISION(6, 8) VertexColorMaskFlags vertexColorGreenMask() const;
251 Q_REVISION(6, 8) VertexColorMaskFlags vertexColorBlueMask() const;
252 Q_REVISION(6, 8) VertexColorMaskFlags vertexColorAlphaMask() const;
254public Q_SLOTS:
255 void setLighting(QQuick3DPrincipledMaterial::Lighting lighting);
256 void setBlendMode(QQuick3DPrincipledMaterial::BlendMode blendMode);
257 void setBaseColor(QColor baseColor);
258 void setBaseColorMap(QQuick3DTexture *baseColorMap);
259 Q_REVISION(6, 8) void setBaseColorSingleChannelEnabled(bool baseColorSingleChannelEnabled);
260 Q_REVISION(6, 8) void setBaseColorChannel(QQuick3DMaterial::TextureChannelMapping channel);
261 Q_REVISION(6, 8) void setSpecularSingleChannelEnabled(bool specularSingleChannelEnabled);
262 Q_REVISION(6, 8) void setSpecularChannel(QQuick3DMaterial::TextureChannelMapping channel);
263 Q_REVISION(6, 8) void setEmissiveSingleChannelEnabled(bool emissiveSingleChannelEnabled);
264 Q_REVISION(6, 8) void setEmissiveChannel(QQuick3DMaterial::TextureChannelMapping channel);
265 void setEmissiveMap(QQuick3DTexture *emissiveMap);
266 void setEmissiveFactor(QVector3D emissiveFactor);
267 void setSpecularReflectionMap(QQuick3DTexture *specularReflectionMap);
268 void setSpecularMap(QQuick3DTexture *specularMap);
269 void setSpecularTint(float specularTint);
270 void setSpecularAmount(float specularAmount);
271 void setRoughness(float roughness);
272 void setRoughnessMap(QQuick3DTexture *roughnessMap);
273 Q_REVISION(6, 8) void setInvertOpacityMapValue(bool invertOpacityMapValue);
274 void setOpacity(float opacity);
275 void setOpacityMap(QQuick3DTexture *opacityMap);
276 void setNormalMap(QQuick3DTexture *normalMap);
277 void setMetalness(float metalnessAmount);
278 void setMetalnessMap(QQuick3DTexture *metalnessMap);
279 void setNormalStrength(float normalStrength);
280 void setOcclusionMap(QQuick3DTexture *occlusionMap);
281 void setOcclusionAmount(float occlusionAmount);
282 void setAlphaMode(QQuick3DPrincipledMaterial::AlphaMode alphaMode);
283 void setAlphaCutoff(float alphaCutoff);
284 void setMetalnessChannel(QQuick3DMaterial::TextureChannelMapping channel);
285 void setRoughnessChannel(QQuick3DMaterial::TextureChannelMapping channel);
286 void setOpacityChannel(QQuick3DMaterial::TextureChannelMapping channel);
287 void setOcclusionChannel(QQuick3DMaterial::TextureChannelMapping channel);
288 void setPointSize(float size);
289 void setLineWidth(float width);
290 Q_REVISION(6, 2) void setHeightMap(QQuick3DTexture *heightMap);
291 Q_REVISION(6, 2) void setHeightChannel(QQuick3DMaterial::TextureChannelMapping channel);
292 Q_REVISION(6, 2) void setHeightAmount(float heightAmount);
293 Q_REVISION(6, 2) void setMinHeightMapSamples(int samples);
294 Q_REVISION(6, 2) void setMaxHeightMapSamples(int samples);
296 Q_REVISION(6, 3) void setClearcoatAmount(float newClearcoatAmount);
297 Q_REVISION(6, 3) void setClearcoatMap(QQuick3DTexture *newClearcoatMap);
298 Q_REVISION(6, 3) void setClearcoatChannel(QQuick3DMaterial::TextureChannelMapping newClearcoatChannel);
299 Q_REVISION(6, 3) void setClearcoatRoughnessAmount(float newClearcoatRoughnessAmount);
300 Q_REVISION(6, 3) void setClearcoatRoughnessChannel(QQuick3DMaterial::TextureChannelMapping newClearcoatRoughnessChannel);
301 Q_REVISION(6, 3) void setClearcoatRoughnessMap(QQuick3DTexture *newClearcoatRoughnessMap);
302 Q_REVISION(6, 3) void setClearcoatNormalMap(QQuick3DTexture *newClearcoatNormalMap);
303 Q_REVISION(6, 8) void setClearcoatNormalStrength(float clearcoatNormalStrength);
305 Q_REVISION(6, 3) void setTransmissionFactor(float newTransmissionFactor);
306 Q_REVISION(6, 3) void setTransmissionMap(QQuick3DTexture *newTransmissionMap);
307 Q_REVISION(6, 3) void setTransmissionChannel(QQuick3DMaterial::TextureChannelMapping newTransmissionChannel);
308
309 Q_REVISION(6, 3) void setThicknessFactor(float newThicknessFactor);
310 Q_REVISION(6, 3) void setThicknessMap(QQuick3DTexture *newThicknessMap);
311 Q_REVISION(6, 3) void setThicknessChannel(const QQuick3DMaterial::TextureChannelMapping &newThicknessChannel);
312 Q_REVISION(6, 3) void setAttenuationDistance(float newAttenuationDistance);
313 Q_REVISION(6, 3) void setAttenuationColor(const QColor &newAttenuationColor);
314
315 Q_REVISION(6, 3) void setIndexOfRefraction(float indexOfRefraction);
316 Q_REVISION(6, 8) void setFresnelScaleBiasEnabled(bool fresnelScaleBias);
317 Q_REVISION(6, 8) void setFresnelScale(float fresnelScale);
318 Q_REVISION(6, 8) void setFresnelBias(float fresnelBias);
319 Q_REVISION(6, 8) void setFresnelPower(float fresnelPower);
321 Q_REVISION(6, 8) void setClearcoatFresnelScaleBiasEnabled(bool clearcoatFresnelScaleBias);
322 Q_REVISION(6, 8) void setClearcoatFresnelScale(float clearcoatFresnelScale);
323 Q_REVISION(6, 8) void setClearcoatFresnelBias(float clearcoatFresnelBias);
324 Q_REVISION(6, 8) void setClearcoatFresnelPower(float clearcoatFresnelPower);
326 Q_REVISION(6, 5) void setVertexColorsEnabled(bool vertexColorsEnabled);
327
328 Q_REVISION(6, 8) void setVertexColorsMaskEnabled(bool vertexColorsMaskEnabled);
329 Q_REVISION(6, 8) void setVertexColorRedMask(VertexColorMaskFlags vertexColorRedMask);
330 Q_REVISION(6, 8) void setVertexColorGreenMask(VertexColorMaskFlags vertexColorGreenMask);
331 Q_REVISION(6, 8) void setVertexColorBlueMask(VertexColorMaskFlags vertexColorBlueMask);
332 Q_REVISION(6, 8) void setVertexColorAlphaMask(VertexColorMaskFlags vertexColorAlphaMask);
334Q_SIGNALS:
335 void lightingChanged(QQuick3DPrincipledMaterial::Lighting lighting);
336 void blendModeChanged(QQuick3DPrincipledMaterial::BlendMode blendMode);
337 void baseColorChanged(QColor baseColor);
338 void baseColorMapChanged(QQuick3DTexture *baseColorMap);
339 Q_REVISION(6, 8) void baseColorSingleChannelEnabledChanged(bool baseColorSingleChannelEnabled);
340 Q_REVISION(6, 8) void baseColorChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
341 Q_REVISION(6, 8) void specularSingleChannelEnabledChanged(bool specularColorSingleChannelEnabled);
342 Q_REVISION(6, 8) void specularChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
343 Q_REVISION(6, 8) void emissiveSingleChannelEnabledChanged(bool emissiveColorSingleChannelEnabled);
344 Q_REVISION(6, 8) void emissiveChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
345 void emissiveMapChanged(QQuick3DTexture *emissiveMap);
346 void emissiveFactorChanged(QVector3D emissiveFactor);
347 void specularReflectionMapChanged(QQuick3DTexture *specularReflectionMap);
348 void specularMapChanged(QQuick3DTexture *specularMap);
349 void specularTintChanged(float specularTint);
350 void specularAmountChanged(float specularAmount);
351 void roughnessChanged(float roughness);
352 void roughnessMapChanged(QQuick3DTexture *roughnessMap);
353 Q_REVISION(6, 8) void invertOpacityMapValueChanged(bool invertOpacityMapValue);
354 void opacityChanged(float opacity);
355 void opacityMapChanged(QQuick3DTexture *opacityMap);
356 void normalMapChanged(QQuick3DTexture *normalMap);
357 void metalnessChanged(float metalness);
358 void metalnessMapChanged(QQuick3DTexture *metalnessMap);
359 void normalStrengthChanged(float normalStrength);
360 void occlusionMapChanged(QQuick3DTexture *occlusionMap);
361 void occlusionAmountChanged(float occlusionAmount);
362 void alphaModeChanged(QQuick3DPrincipledMaterial::AlphaMode alphaMode);
363 void alphaCutoffChanged(float alphaCutoff);
364 void metalnessChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
365 void roughnessChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
366 void opacityChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
367 void occlusionChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
368 void pointSizeChanged();
369 void lineWidthChanged();
370 Q_REVISION(6, 2) void heightMapChanged(QQuick3DTexture *heightMap);
371 Q_REVISION(6, 2) void heightChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
372 Q_REVISION(6, 2) void heightAmountChanged(float heightAmount);
373 Q_REVISION(6, 2) void minHeightMapSamplesChanged(int samples);
374 Q_REVISION(6, 2) void maxHeightMapSamplesChanged(int samples);
376 Q_REVISION(6, 3) void clearcoatAmountChanged(float amount);
377 Q_REVISION(6, 3) void clearcoatMapChanged(QQuick3DTexture *texture);
378 Q_REVISION(6, 3) void clearcoatChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
379 Q_REVISION(6, 3) void clearcoatRoughnessAmountChanged(float amount);
380 Q_REVISION(6, 3) void clearcoatRoughnessChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
381 Q_REVISION(6, 3) void clearcoatRoughnessMapChanged(QQuick3DTexture *texture);
382 Q_REVISION(6, 3) void clearcoatNormalMapChanged(QQuick3DTexture *texture);
383 Q_REVISION(6, 8) void clearcoatNormalStrengthChanged(float clearcoatNormalStrength);
385 Q_REVISION(6, 3) void transmissionFactorChanged(float amount);
386 Q_REVISION(6, 3) void transmissionMapChanged(QQuick3DTexture *texture);
387 Q_REVISION(6, 3) void transmissionChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
388
389 Q_REVISION(6, 3) void thicknessFactorChanged(float amount);
390 Q_REVISION(6, 3) void thicknessMapChanged(QQuick3DTexture *texture);
391 Q_REVISION(6, 3) void thicknessChannelChanged(QQuick3DMaterial::TextureChannelMapping channel);
392 Q_REVISION(6, 3) void attenuationDistanceChanged(float distance);
393 Q_REVISION(6, 3) void attenuationColorChanged(QColor color);
394
395 Q_REVISION(6, 3) void indexOfRefractionChanged(float indexOfRefraction);
396 Q_REVISION(6, 8) void fresnelScaleBiasEnabledChanged(bool fresnelScaleBiasEnabled);
397 Q_REVISION(6, 8) void fresnelScaleChanged(float fresnelScale);
398 Q_REVISION(6, 8) void fresnelBiasChanged(float fresnelBias);
399 Q_REVISION(6, 8) void fresnelPowerChanged(float fresnelPower);
401 Q_REVISION(6, 8) void clearcoatFresnelScaleBiasEnabledChanged(bool clearcoatFresnelScaleBiasEnabled);
402 Q_REVISION(6, 8) void clearcoatFresnelScaleChanged(float clearcoatFresnelScale);
403 Q_REVISION(6, 8) void clearcoatFresnelBiasChanged(float clearcoatFresnelBias);
404 Q_REVISION(6, 8) void clearcoatFresnelPowerChanged(float clearcoatFresnelPower);
406 Q_REVISION(6, 5) void vertexColorsEnabledChanged(bool vertexColorsEnabled);
407
408 Q_REVISION(6, 8) void vertexColorsMaskEnabledChanged();
409 Q_REVISION(6, 8) void vertexColorRedMaskChanged();
410 Q_REVISION(6, 8) void vertexColorGreenMaskChanged();
411 Q_REVISION(6, 8) void vertexColorBlueMaskChanged();
412 Q_REVISION(6, 8) void vertexColorAlphaMaskChanged();
413
414protected:
415 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
416 void markAllDirty() override;
417 void itemChange(ItemChange, const ItemChangeData &) override;
418private:
419 enum DirtyType {
420 LightingModeDirty = 0x00000001,
421 BlendModeDirty = 0x00000002,
422 BaseColorDirty = 0x00000004,
423 EmissiveDirty = 0x00000008,
424 SpecularDirty = 0x00000010,
425 OpacityDirty = 0x00000020,
426 NormalDirty = 0x00000040,
427 MetalnessDirty = 0x00000080,
428 RoughnessDirty = 0x00000100,
429 OcclusionDirty = 0x00000200,
430 AlphaModeDirty = 0x00000400,
431 PointSizeDirty = 0x00000800,
432 LineWidthDirty = 0x00001000,
433 HeightDirty = 0x00002000,
434 ClearcoatDirty = 0x00004000,
435 TransmissionDirty = 0x00008000,
436 VolumeDirty = 0x00010000,
437 VertexColorsDirty = 0x00020000
438 };
439
440 void updateSceneManager(QQuick3DSceneManager *window);
441
442 // Note: The default values for properties that are also present in
443 // QSSGShaderCustomMaterialAdapter must match the values there, because a
444 // PrincipledMaterial { } and CustomMaterial { } must be identical. Same
445 // goes for the custom shader defaults in generateFragmentShader(), keep
446 // them in sync.
447
448 Lighting m_lighting = FragmentLighting;
449 BlendMode m_blendMode = SourceOver;
450 AlphaMode m_alphaMode = Default;
451 QColor m_baseColor = Qt::white;
452 QQuick3DTexture *m_baseColorMap = nullptr;
453 bool m_baseColorSingleChannelEnabled = false;
454 TextureChannelMapping m_baseColorChannel = QQuick3DMaterial::R;
455 bool m_specularSingleChannelEnabled = false;
456 TextureChannelMapping m_specularChannel = QQuick3DMaterial::R;
457 TextureChannelMapping m_emissiveChannel = QQuick3DMaterial::R;
458 bool m_emissiveSingleChannelEnabled = false;
459 QVector3D m_emissiveFactor;
460 QQuick3DTexture *m_emissiveMap = nullptr;
461
462 QQuick3DTexture *m_specularReflectionMap = nullptr;
463 QQuick3DTexture *m_specularMap = nullptr;
464 QQuick3DTexture *m_roughnessMap = nullptr;
465 QQuick3DTexture *m_opacityMap = nullptr;
466 QQuick3DTexture *m_normalMap = nullptr;
467 QQuick3DTexture *m_metalnessMap = nullptr;
468 QQuick3DTexture *m_occlusionMap = nullptr;
469 float m_specularTint = 0.0f;
470 float m_specularAmount = 1.0f;
471 float m_roughness = 0.0f;
472 bool m_invertOpacityMapValue = false;
473 float m_opacity = 1.0f;
474 float m_metalnessAmount = 0.0f;
475 float m_normalStrength = 1.0f;
476 float m_occlusionAmount = 1.0f;
477 float m_alphaCutoff = 0.5f;
478 TextureChannelMapping m_metalnessChannel = QQuick3DMaterial::B;
479 TextureChannelMapping m_roughnessChannel = QQuick3DMaterial::G;
480 TextureChannelMapping m_opacityChannel = QQuick3DMaterial::A;
481 TextureChannelMapping m_occlusionChannel = QQuick3DMaterial::R;
482 float m_pointSize = 1.0f;
483 float m_lineWidth = 1.0f;
484 QQuick3DTexture *m_heightMap = nullptr;
485 TextureChannelMapping m_heightChannel = QQuick3DMaterial::R;
486 float m_heightAmount = 0.0f;
487 int m_minHeightMapSamples = 8;
488 int m_maxHeightMapSamples = 32;
489 float m_clearcoatAmount = 0.0f;
490 QQuick3DTexture *m_clearcoatMap = nullptr;
491 TextureChannelMapping m_clearcoatChannel = QQuick3DMaterial::R;
492 float m_clearcoatRoughnessAmount = 0.0f;
493 float m_clearcoatNormalStrength = 1.0f;
494 TextureChannelMapping m_clearcoatRoughnessChannel = QQuick3DMaterial::G;
495 QQuick3DTexture *m_clearcoatRoughnessMap = nullptr;
496 QQuick3DTexture *m_clearcoatNormalMap = nullptr;
497 float m_transmissionFactor = 0.0f;
498 QQuick3DTexture *m_transmissionMap = nullptr;
499 TextureChannelMapping m_transmissionChannel = QQuick3DMaterial::R;
500 float m_thicknessFactor = 0.0f;
501 QQuick3DTexture *m_thicknessMap = nullptr;
502 TextureChannelMapping m_thicknessChannel = QQuick3DMaterial::G;
503 float m_attenuationDistance = std::numeric_limits<float>::infinity();
504 QColor m_attenuationColor = Qt::white;
505 float m_indexOfRefraction = 1.5f;
506 bool m_fresnelScaleBiasEnabled = false;
507 float m_fresnelScale = 1.0f;
508 float m_fresnelBias = 0.0f;
509 float m_fresnelPower = 5.0f;
510 bool m_clearcoatFresnelScaleBiasEnabled = false;
511 float m_clearcoatFresnelScale = 1.0f;
512 float m_clearcoatFresnelBias = 0.0f;
513 float m_clearcoatFresnelPower = 5.0f;
514 bool m_vertexColorsEnabled = true;
515
516 bool m_vertexColorsMaskEnabled = false;
517 VertexColorMaskFlags m_vertexColorRedMask = NoMask;
518 VertexColorMaskFlags m_vertexColorGreenMask = NoMask;
519 VertexColorMaskFlags m_vertexColorBlueMask = NoMask;
520 VertexColorMaskFlags m_vertexColorAlphaMask = NoMask;
521
522 quint32 m_dirtyAttributes = 0xffffffff; // all dirty by default
523 void markDirty(DirtyType type);
524
525 static constexpr float ensureNormalized(float val) { return qBound(0.0f, val, 1.0f); }
526};
527
528QT_END_NAMESPACE
529
530#endif // QSSGPRINCIPLEDMATERIAL_H
Combined button and popup list for selecting options.