1 | // Copyright (C) 2022 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QQUICK3DSPECULARGLOSSYMATERIAL_P_H |
5 | #define QQUICK3DSPECULARGLOSSYMATERIAL_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version toSpecularGlossyMaterial |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtQuick3D/private/qquick3dmaterial_p.h> |
19 | #include <QtQuick3D/private/qquick3dtexture_p.h> |
20 | |
21 | #include <QColor> |
22 | #include <QHash> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class Q_QUICK3D_EXPORT QQuick3DSpecularGlossyMaterial : public QQuick3DMaterial |
27 | { |
28 | Q_OBJECT |
29 | Q_PROPERTY(Lighting lighting READ lighting WRITE setLighting NOTIFY lightingChanged) |
30 | Q_PROPERTY(BlendMode blendMode READ blendMode WRITE setBlendMode NOTIFY blendModeChanged) |
31 | |
32 | Q_PROPERTY(QColor albedoColor READ albedoColor WRITE setAlbedoColor NOTIFY albedoColorChanged) |
33 | Q_PROPERTY(QQuick3DTexture *albedoMap READ albedoMap WRITE setAlbedoMap NOTIFY albedoMapChanged) |
34 | Q_PROPERTY(bool albedoSingleChannelEnabled READ albedoSingleChannelEnabled WRITE setAlbedoSingleChannelEnabled NOTIFY albedoSingleChannelEnabledChanged REVISION(6, 8)) |
35 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping albedoChannel READ albedoChannel WRITE setAlbedoChannel NOTIFY albedoChannelChanged REVISION(6, 8)) |
36 | |
37 | Q_PROPERTY(QColor specularColor READ specularColor WRITE setSpecularColor NOTIFY specularColorChanged) |
38 | Q_PROPERTY(QQuick3DTexture *specularMap READ specularMap WRITE setSpecularMap NOTIFY specularMapChanged) |
39 | Q_PROPERTY(bool specularSingleChannelEnabled READ specularSingleChannelEnabled WRITE setSpecularSingleChannelEnabled NOTIFY specularSingleChannelEnabledChanged REVISION(6, 8)) |
40 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping specularChannel READ specularChannel WRITE setSpecularChannel NOTIFY specularChannelChanged REVISION(6, 8)) |
41 | |
42 | Q_PROPERTY(float glossiness READ glossiness WRITE setGlossiness NOTIFY glossinessChanged) |
43 | Q_PROPERTY(QQuick3DTexture *glossinessMap READ glossinessMap WRITE setGlossinessMap NOTIFY glossinessMapChanged) |
44 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping glossinessChannel READ glossinessChannel WRITE setGlossinessChannel NOTIFY glossinessChannelChanged) |
45 | |
46 | Q_PROPERTY(QVector3D emissiveFactor READ emissiveFactor WRITE setEmissiveFactor NOTIFY emissiveFactorChanged) |
47 | Q_PROPERTY(QQuick3DTexture *emissiveMap READ emissiveMap WRITE setEmissiveMap NOTIFY emissiveMapChanged) |
48 | Q_PROPERTY(bool emissiveSingleChannelEnabled READ emissiveSingleChannelEnabled WRITE setEmissiveSingleChannelEnabled NOTIFY emissiveSingleChannelEnabledChanged REVISION(6, 8)) |
49 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping emissiveChannel READ emissiveChannel WRITE setEmissiveChannel NOTIFY emissiveChannelChanged REVISION(6, 8)) |
50 | |
51 | Q_PROPERTY(bool invertOpacityMapValue READ invertOpacityMapValue WRITE setInvertOpacityMapValue NOTIFY invertOpacityMapValueChanged REVISION(6, 8)) |
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) |
55 | |
56 | Q_PROPERTY(QQuick3DTexture *normalMap READ normalMap WRITE setNormalMap NOTIFY normalMapChanged) |
57 | Q_PROPERTY(float normalStrength READ normalStrength WRITE setNormalStrength NOTIFY normalStrengthChanged) |
58 | |
59 | Q_PROPERTY(QQuick3DTexture *occlusionMap READ occlusionMap WRITE setOcclusionMap NOTIFY occlusionMapChanged) |
60 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping occlusionChannel READ occlusionChannel WRITE setOcclusionChannel NOTIFY occlusionChannelChanged) |
61 | Q_PROPERTY(float occlusionAmount READ occlusionAmount WRITE setOcclusionAmount NOTIFY occlusionAmountChanged) |
62 | |
63 | Q_PROPERTY(AlphaMode alphaMode READ alphaMode WRITE setAlphaMode NOTIFY alphaModeChanged) |
64 | Q_PROPERTY(float alphaCutoff READ alphaCutoff WRITE setAlphaCutoff NOTIFY alphaCutoffChanged) |
65 | |
66 | Q_PROPERTY(float pointSize READ pointSize WRITE setPointSize NOTIFY pointSizeChanged) |
67 | Q_PROPERTY(float lineWidth READ lineWidth WRITE setLineWidth NOTIFY lineWidthChanged) |
68 | |
69 | Q_PROPERTY(QQuick3DTexture *heightMap READ heightMap WRITE setHeightMap NOTIFY heightMapChanged) |
70 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping heightChannel READ heightChannel WRITE setHeightChannel NOTIFY heightChannelChanged) |
71 | Q_PROPERTY(float heightAmount READ heightAmount WRITE setHeightAmount NOTIFY heightAmountChanged) |
72 | Q_PROPERTY(int minHeightMapSamples READ minHeightMapSamples WRITE setMinHeightMapSamples NOTIFY minHeightMapSamplesChanged) |
73 | Q_PROPERTY(int maxHeightMapSamples READ maxHeightMapSamples WRITE setMaxHeightMapSamples NOTIFY maxHeightMapSamplesChanged) |
74 | |
75 | Q_PROPERTY(float clearcoatAmount READ clearcoatAmount WRITE setClearcoatAmount NOTIFY clearcoatAmountChanged) |
76 | Q_PROPERTY(QQuick3DTexture *clearcoatMap READ clearcoatMap WRITE setClearcoatMap NOTIFY clearcoatMapChanged) |
77 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping clearcoatChannel READ clearcoatChannel WRITE setClearcoatChannel NOTIFY |
78 | clearcoatChannelChanged) |
79 | Q_PROPERTY(float clearcoatRoughnessAmount READ clearcoatRoughnessAmount WRITE setClearcoatRoughnessAmount NOTIFY |
80 | clearcoatRoughnessAmountChanged) |
81 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping clearcoatRoughnessChannel READ clearcoatRoughnessChannel WRITE |
82 | setClearcoatRoughnessChannel NOTIFY clearcoatRoughnessChannelChanged) |
83 | Q_PROPERTY(QQuick3DTexture *clearcoatRoughnessMap READ clearcoatRoughnessMap WRITE setClearcoatRoughnessMap NOTIFY |
84 | clearcoatRoughnessMapChanged) |
85 | Q_PROPERTY(QQuick3DTexture *clearcoatNormalMap READ clearcoatNormalMap WRITE setClearcoatNormalMap NOTIFY |
86 | clearcoatNormalMapChanged) |
87 | Q_PROPERTY(float clearcoatNormalStrength READ clearcoatNormalStrength WRITE setClearcoatNormalStrength NOTIFY clearcoatNormalStrengthChanged REVISION(6, 8)) |
88 | |
89 | Q_PROPERTY(float transmissionFactor READ transmissionFactor WRITE setTransmissionFactor NOTIFY transmissionFactorChanged) |
90 | Q_PROPERTY(QQuick3DTexture * transmissionMap READ transmissionMap WRITE setTransmissionMap NOTIFY transmissionMapChanged) |
91 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping transmissionChannel READ transmissionChannel WRITE setTransmissionChannel NOTIFY transmissionChannelChanged) |
92 | |
93 | Q_PROPERTY(float thicknessFactor READ thicknessFactor WRITE setThicknessFactor NOTIFY thicknessFactorChanged) |
94 | Q_PROPERTY(QQuick3DTexture *thicknessMap READ thicknessMap WRITE setThicknessMap NOTIFY thicknessMapChanged) |
95 | Q_PROPERTY(QQuick3DMaterial::TextureChannelMapping thicknessChannel READ thicknessChannel WRITE setThicknessChannel NOTIFY |
96 | thicknessChannelChanged) |
97 | Q_PROPERTY(float attenuationDistance READ attenuationDistance WRITE setAttenuationDistance NOTIFY attenuationDistanceChanged) |
98 | Q_PROPERTY(QColor attenuationColor READ attenuationColor WRITE setAttenuationColor NOTIFY attenuationColorChanged) |
99 | |
100 | Q_PROPERTY(bool vertexColorsEnabled READ vertexColorsEnabled WRITE setVertexColorsEnabled NOTIFY vertexColorsEnabledChanged REVISION(6, 5)) |
101 | |
102 | Q_PROPERTY(bool fresnelScaleBiasEnabled READ fresnelScaleBiasEnabled WRITE setFresnelScaleBiasEnabled NOTIFY fresnelScaleBiasEnabledChanged REVISION(6, 8)) |
103 | Q_PROPERTY(float fresnelScale READ fresnelScale WRITE setFresnelScale NOTIFY fresnelScaleChanged REVISION(6, 8)) |
104 | Q_PROPERTY(float fresnelBias READ fresnelBias WRITE setFresnelBias NOTIFY fresnelBiasChanged REVISION(6, 8)) |
105 | Q_PROPERTY(float fresnelPower READ fresnelPower WRITE setFresnelPower NOTIFY fresnelPowerChanged REVISION(6, 8)) |
106 | |
107 | Q_PROPERTY(bool clearcoatFresnelScaleBiasEnabled READ clearcoatFresnelScaleBiasEnabled WRITE setClearcoatFresnelScaleBiasEnabled NOTIFY clearcoatFresnelScaleBiasEnabledChanged REVISION(6, 8)) |
108 | Q_PROPERTY(float clearcoatFresnelScale READ clearcoatFresnelScale WRITE setClearcoatFresnelScale NOTIFY clearcoatFresnelScaleChanged REVISION(6, 8)) |
109 | Q_PROPERTY(float clearcoatFresnelBias READ clearcoatFresnelBias WRITE setClearcoatFresnelBias NOTIFY clearcoatFresnelBiasChanged REVISION(6, 8)) |
110 | Q_PROPERTY(float clearcoatFresnelPower READ clearcoatFresnelPower WRITE setClearcoatFresnelPower NOTIFY clearcoatFresnelPowerChanged REVISION(6, 8)) |
111 | |
112 | Q_PROPERTY(bool vertexColorsMaskEnabled READ vertexColorsMaskEnabled WRITE setVertexColorsMaskEnabled NOTIFY vertexColorsMaskEnabledChanged REVISION(6, 8)) |
113 | Q_PROPERTY(VertexColorMaskFlags vertexColorRedMask READ vertexColorRedMask WRITE setVertexColorRedMask NOTIFY vertexColorRedMaskChanged REVISION(6, 8)) |
114 | Q_PROPERTY(VertexColorMaskFlags vertexColorGreenMask READ vertexColorGreenMask WRITE setVertexColorGreenMask NOTIFY vertexColorGreenMaskChanged REVISION(6, 8)) |
115 | Q_PROPERTY(VertexColorMaskFlags vertexColorBlueMask READ vertexColorBlueMask WRITE setVertexColorBlueMask NOTIFY vertexColorBlueMaskChanged REVISION(6, 8)) |
116 | Q_PROPERTY(VertexColorMaskFlags vertexColorAlphaMask READ vertexColorAlphaMask WRITE setVertexColorAlphaMask NOTIFY vertexColorAlphaMaskChanged REVISION(6, 8)) |
117 | |
118 | QML_NAMED_ELEMENT(SpecularGlossyMaterial) |
119 | QML_ADDED_IN_VERSION(6, 4) |
120 | |
121 | public: |
122 | enum Lighting { |
123 | NoLighting = 0, |
124 | FragmentLighting |
125 | }; |
126 | Q_ENUM(Lighting) |
127 | |
128 | enum BlendMode { |
129 | SourceOver = 0, |
130 | Screen, |
131 | Multiply |
132 | }; |
133 | Q_ENUM(BlendMode) |
134 | |
135 | enum AlphaMode { |
136 | Default = 0, |
137 | Mask, |
138 | Blend, |
139 | Opaque |
140 | }; |
141 | Q_ENUM(AlphaMode) |
142 | |
143 | enum VertexColorMask { |
144 | NoMask = QQuick3DMaterial::NoMask, |
145 | GlossinessMask = QQuick3DMaterial::RoughnessMask, |
146 | NormalStrengthMask = QQuick3DMaterial::NormalStrengthMask, |
147 | ClearcoatAmountMask = QQuick3DMaterial::ClearcoatAmountMask, |
148 | ClearcoatRoughnessAmountMask = QQuick3DMaterial::ClearcoatRoughnessAmountMask, |
149 | ClearcoatNormalStrengthMask = QQuick3DMaterial::NormalStrengthMask, |
150 | HeightAmountMask = QQuick3DMaterial::HeightAmountMask, |
151 | OcclusionAmountMask = QQuick3DMaterial::OcclusionAmountMask, |
152 | ThicknessFactorMask = QQuick3DMaterial::ThicknessFactorMask, |
153 | TransmissionFactorMask = QQuick3DMaterial::TransmissionFactorMask |
154 | }; |
155 | Q_ENUM(VertexColorMask) |
156 | Q_DECLARE_FLAGS(VertexColorMaskFlags, VertexColorMask) |
157 | |
158 | explicit QQuick3DSpecularGlossyMaterial(QQuick3DObject *parent = nullptr); |
159 | ~QQuick3DSpecularGlossyMaterial() override; |
160 | |
161 | Lighting lighting() const; |
162 | BlendMode blendMode() const; |
163 | QColor albedoColor() const; |
164 | QQuick3DTexture *albedoMap() const; |
165 | Q_REVISION(6, 8) bool albedoSingleChannelEnabled() const; |
166 | Q_REVISION(6, 8) TextureChannelMapping albedoChannel() const; |
167 | Q_REVISION(6, 8) bool specularSingleChannelEnabled() const; |
168 | Q_REVISION(6, 8) TextureChannelMapping specularChannel() const; |
169 | Q_REVISION(6, 8) bool emissiveSingleChannelEnabled() const; |
170 | Q_REVISION(6, 8) TextureChannelMapping emissiveChannel() const; |
171 | QQuick3DTexture *emissiveMap() const; |
172 | QVector3D emissiveFactor() const; |
173 | float glossiness() const; |
174 | QQuick3DTexture *glossinessMap() const; |
175 | Q_REVISION(6, 8) bool invertOpacityMapValue() const; |
176 | float opacity() const; |
177 | QQuick3DTexture *opacityMap() const; |
178 | QQuick3DTexture *normalMap() const; |
179 | QColor specularColor() const; |
180 | QQuick3DTexture *specularMap() const; |
181 | float normalStrength() const; |
182 | QQuick3DTexture *occlusionMap() const; |
183 | float occlusionAmount() const; |
184 | AlphaMode alphaMode() const; |
185 | float alphaCutoff() const; |
186 | TextureChannelMapping glossinessChannel() const; |
187 | TextureChannelMapping opacityChannel() const; |
188 | TextureChannelMapping occlusionChannel() const; |
189 | float pointSize() const; |
190 | float lineWidth() const; |
191 | QQuick3DTexture *heightMap() const; |
192 | TextureChannelMapping heightChannel() const; |
193 | float heightAmount() const; |
194 | int minHeightMapSamples() const; |
195 | int maxHeightMapSamples() const; |
196 | |
197 | float clearcoatAmount() const; |
198 | QQuick3DTexture *clearcoatMap() const; |
199 | TextureChannelMapping clearcoatChannel() const; |
200 | float clearcoatRoughnessAmount() const; |
201 | TextureChannelMapping clearcoatRoughnessChannel() const; |
202 | QQuick3DTexture *clearcoatRoughnessMap() const; |
203 | QQuick3DTexture *clearcoatNormalMap() const; |
204 | |
205 | float transmissionFactor() const; |
206 | QQuick3DTexture *transmissionMap() const; |
207 | TextureChannelMapping transmissionChannel() const; |
208 | |
209 | float thicknessFactor() const; |
210 | QQuick3DTexture *thicknessMap() const; |
211 | TextureChannelMapping thicknessChannel() const; |
212 | float attenuationDistance() const; |
213 | QColor attenuationColor() const; |
214 | |
215 | Q_REVISION(6, 8) bool fresnelScaleBiasEnabled() const; |
216 | Q_REVISION(6, 8) float fresnelScale() const; |
217 | Q_REVISION(6, 8) float fresnelBias() const; |
218 | Q_REVISION(6, 8) float fresnelPower() const; |
219 | |
220 | Q_REVISION(6, 8) bool clearcoatFresnelScaleBiasEnabled() const; |
221 | Q_REVISION(6, 8) float clearcoatFresnelScale() const; |
222 | Q_REVISION(6, 8) float clearcoatFresnelBias() const; |
223 | Q_REVISION(6, 8) float clearcoatFresnelPower() const; |
224 | |
225 | Q_REVISION(6, 5) bool vertexColorsEnabled() const; |
226 | Q_REVISION(6, 8) float clearcoatNormalStrength() const; |
227 | |
228 | Q_REVISION(6, 8) bool vertexColorsMaskEnabled() const; |
229 | Q_REVISION(6, 8) VertexColorMaskFlags vertexColorRedMask() const; |
230 | Q_REVISION(6, 8) VertexColorMaskFlags vertexColorGreenMask() const; |
231 | Q_REVISION(6, 8) VertexColorMaskFlags vertexColorBlueMask() const; |
232 | Q_REVISION(6, 8) VertexColorMaskFlags vertexColorAlphaMask() const; |
233 | |
234 | public Q_SLOTS: |
235 | void setLighting(QQuick3DSpecularGlossyMaterial::Lighting lighting); |
236 | void setBlendMode(QQuick3DSpecularGlossyMaterial::BlendMode blendMode); |
237 | void setAlbedoColor(const QColor &albedo); |
238 | void setAlbedoMap(QQuick3DTexture *albedoMap); |
239 | Q_REVISION(6, 8) void setAlbedoSingleChannelEnabled(bool albedoSingleChannelEnabled); |
240 | Q_REVISION(6, 8) void setAlbedoChannel(QQuick3DMaterial::TextureChannelMapping channel); |
241 | Q_REVISION(6, 8) void setSpecularSingleChannelEnabled(bool specularSingleChannelEnabled); |
242 | Q_REVISION(6, 8) void setSpecularChannel(QQuick3DMaterial::TextureChannelMapping channel); |
243 | Q_REVISION(6, 8) void setEmissiveSingleChannelEnabled(bool emissiveSingleChannelEnabled); |
244 | Q_REVISION(6, 8) void setEmissiveChannel(QQuick3DMaterial::TextureChannelMapping channel); |
245 | void setEmissiveMap(QQuick3DTexture *emissiveMap); |
246 | void setEmissiveFactor(const QVector3D &emissiveFactor); |
247 | void setGlossiness(float glossiness); |
248 | void setGlossinessMap(QQuick3DTexture *glossinessMap); |
249 | Q_REVISION(6, 8) void setInvertOpacityMapValue(bool invertOpacityMapValue); |
250 | void setOpacity(float opacity); |
251 | void setOpacityMap(QQuick3DTexture *opacityMap); |
252 | void setNormalMap(QQuick3DTexture *normalMap); |
253 | void setSpecularColor(const QColor &specular); |
254 | void setSpecularMap(QQuick3DTexture *specularMap); |
255 | void setNormalStrength(float normalStrength); |
256 | void setOcclusionMap(QQuick3DTexture *occlusionMap); |
257 | void setOcclusionAmount(float occlusionAmount); |
258 | void setAlphaMode(QQuick3DSpecularGlossyMaterial::AlphaMode alphaMode); |
259 | void setAlphaCutoff(float alphaCutoff); |
260 | void setGlossinessChannel(QQuick3DMaterial::TextureChannelMapping channel); |
261 | void setOpacityChannel(QQuick3DMaterial::TextureChannelMapping channel); |
262 | void setOcclusionChannel(QQuick3DMaterial::TextureChannelMapping channel); |
263 | void setPointSize(float size); |
264 | void setLineWidth(float width); |
265 | void setHeightMap(QQuick3DTexture *heightMap); |
266 | void setHeightChannel(QQuick3DMaterial::TextureChannelMapping channel); |
267 | void setHeightAmount(float heightAmount); |
268 | void setMinHeightMapSamples(int samples); |
269 | void setMaxHeightMapSamples(int samples); |
270 | |
271 | void setClearcoatAmount(float newClearcoatAmount); |
272 | void setClearcoatMap(QQuick3DTexture *newClearcoatMap); |
273 | void setClearcoatChannel(QQuick3DMaterial::TextureChannelMapping newClearcoatChannel); |
274 | void setClearcoatRoughnessAmount(float newClearcoatRoughnessAmount); |
275 | void setClearcoatRoughnessChannel(QQuick3DMaterial::TextureChannelMapping newClearcoatRoughnessChannel); |
276 | void setClearcoatRoughnessMap(QQuick3DTexture *newClearcoatRoughnessMap); |
277 | void setClearcoatNormalMap(QQuick3DTexture *newClearcoatNormalMap); |
278 | Q_REVISION(6, 8) void setClearcoatNormalStrength( float newClearcoatNormalStrength ); |
279 | |
280 | void setTransmissionFactor(float newTransmissionFactor); |
281 | void setTransmissionMap(QQuick3DTexture *newTransmissionMap); |
282 | void setTransmissionChannel(QQuick3DMaterial::TextureChannelMapping newTransmissionChannel); |
283 | |
284 | void setThicknessFactor(float newThicknessFactor); |
285 | void setThicknessMap(QQuick3DTexture *newThicknessMap); |
286 | void setThicknessChannel(QQuick3DMaterial::TextureChannelMapping newThicknessChannel); |
287 | void setAttenuationDistance(float newAttenuationDistance); |
288 | void setAttenuationColor(const QColor &newAttenuationColor); |
289 | |
290 | Q_REVISION(6, 8) void setFresnelScaleBiasEnabled(bool fresnelScaleBias); |
291 | Q_REVISION(6, 8) void setFresnelScale(float fresnelScale); |
292 | Q_REVISION(6, 8) void setFresnelBias(float fresnelBias); |
293 | Q_REVISION(6, 8) void setFresnelPower(float fresnelPower); |
294 | |
295 | Q_REVISION(6, 8) void setClearcoatFresnelScaleBiasEnabled(bool clearcoatFresnelScaleBias); |
296 | Q_REVISION(6, 8) void setClearcoatFresnelScale(float clearcoatFresnelScale); |
297 | Q_REVISION(6, 8) void setClearcoatFresnelBias(float clearcoatFresnelBias); |
298 | Q_REVISION(6, 8) void setClearcoatFresnelPower(float clearcoatFresnelPower); |
299 | |
300 | Q_REVISION(6, 5) void setVertexColorsEnabled(bool vertexColorsEnabled); |
301 | |
302 | Q_REVISION(6, 8) void setVertexColorsMaskEnabled(bool vertexColorsMaskEnabled); |
303 | Q_REVISION(6, 8) void setVertexColorRedMask(VertexColorMaskFlags vertexColorRedMask); |
304 | Q_REVISION(6, 8) void setVertexColorGreenMask(VertexColorMaskFlags vertexColorGreenMask); |
305 | Q_REVISION(6, 8) void setVertexColorBlueMask(VertexColorMaskFlags vertexColorBlueMask); |
306 | Q_REVISION(6, 8) void setVertexColorAlphaMask(VertexColorMaskFlags vertexColorAlphaMask); |
307 | |
308 | Q_SIGNALS: |
309 | void lightingChanged(); |
310 | void blendModeChanged(); |
311 | void albedoColorChanged(); |
312 | void albedoMapChanged(); |
313 | Q_REVISION(6, 8) void albedoSingleChannelEnabledChanged(); |
314 | Q_REVISION(6, 8) void albedoChannelChanged(); |
315 | Q_REVISION(6, 8) void specularSingleChannelEnabledChanged(); |
316 | Q_REVISION(6, 8) void specularChannelChanged(); |
317 | Q_REVISION(6, 8) void emissiveSingleChannelEnabledChanged(); |
318 | Q_REVISION(6, 8) void emissiveChannelChanged(); |
319 | void emissiveMapChanged(); |
320 | void emissiveFactorChanged(); |
321 | void glossinessChanged(); |
322 | void glossinessMapChanged(); |
323 | Q_REVISION(6, 8) void invertOpacityMapValueChanged(); |
324 | void opacityChanged(); |
325 | void opacityMapChanged(); |
326 | void normalMapChanged(); |
327 | void specularColorChanged(); |
328 | void specularMapChanged(); |
329 | void normalStrengthChanged(); |
330 | void occlusionMapChanged(); |
331 | void occlusionAmountChanged(); |
332 | void alphaModeChanged(); |
333 | void alphaCutoffChanged(); |
334 | void glossinessChannelChanged(); |
335 | void opacityChannelChanged(); |
336 | void occlusionChannelChanged(); |
337 | void pointSizeChanged(); |
338 | void lineWidthChanged(); |
339 | void heightMapChanged(); |
340 | void heightChannelChanged(); |
341 | void heightAmountChanged(); |
342 | void minHeightMapSamplesChanged(); |
343 | void maxHeightMapSamplesChanged(); |
344 | |
345 | void clearcoatAmountChanged(); |
346 | void clearcoatMapChanged(); |
347 | void clearcoatChannelChanged(); |
348 | void clearcoatRoughnessAmountChanged(); |
349 | void clearcoatRoughnessChannelChanged(); |
350 | void clearcoatRoughnessMapChanged(); |
351 | void clearcoatNormalMapChanged(); |
352 | void clearcoatNormalStrengthChanged(); |
353 | |
354 | void transmissionFactorChanged(); |
355 | void transmissionMapChanged(); |
356 | void transmissionChannelChanged(); |
357 | |
358 | void thicknessFactorChanged(); |
359 | void thicknessMapChanged(); |
360 | void thicknessChannelChanged(); |
361 | void attenuationDistanceChanged(); |
362 | void attenuationColorChanged(); |
363 | |
364 | Q_REVISION(6, 5) void vertexColorsEnabledChanged(bool vertexColorsEnabled); |
365 | |
366 | Q_REVISION(6, 8) void fresnelScaleBiasEnabledChanged(bool fresnelScaleBiasEnabled); |
367 | Q_REVISION(6, 8) void fresnelScaleChanged(float fresnelScale); |
368 | Q_REVISION(6, 8) void fresnelBiasChanged(float fresnelBias); |
369 | Q_REVISION(6, 8) void fresnelPowerChanged(float fresnelPower); |
370 | |
371 | Q_REVISION(6, 8) void clearcoatFresnelScaleBiasEnabledChanged(bool clearcoatFresnelScaleBiasEnabled); |
372 | Q_REVISION(6, 8) void clearcoatFresnelScaleChanged(float clearcoatFresnelScale); |
373 | Q_REVISION(6, 8) void clearcoatFresnelBiasChanged(float clearcoatFresnelBias); |
374 | Q_REVISION(6, 8) void clearcoatFresnelPowerChanged(float clearcoatFresnelPower); |
375 | |
376 | Q_REVISION(6, 8) void vertexColorsMaskEnabledChanged(); |
377 | Q_REVISION(6, 8) void vertexColorRedMaskChanged(); |
378 | Q_REVISION(6, 8) void vertexColorGreenMaskChanged(); |
379 | Q_REVISION(6, 8) void vertexColorBlueMaskChanged(); |
380 | Q_REVISION(6, 8) void vertexColorAlphaMaskChanged(); |
381 | |
382 | protected: |
383 | QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override; |
384 | void markAllDirty() override; |
385 | void itemChange(ItemChange, const ItemChangeData &) override; |
386 | private: |
387 | |
388 | enum DirtyType { |
389 | LightingModeDirty = 0x00000001, |
390 | BlendModeDirty = 0x00000002, |
391 | AlbedoDirty = 0x00000004, |
392 | EmissiveDirty = 0x00000008, |
393 | SpecularDirty = 0x00000010, |
394 | OpacityDirty = 0x00000020, |
395 | NormalDirty = 0x00000040, |
396 | GlossyDirty = 0x00000080, |
397 | OcclusionDirty = 0x00000100, |
398 | AlphaModeDirty = 0x00000200, |
399 | PointSizeDirty = 0x00000400, |
400 | LineWidthDirty = 0x00000800, |
401 | HeightDirty = 0x00001000, |
402 | ClearcoatDirty = 0x00002000, |
403 | TransmissionDirty = 0x00004000, |
404 | VolumeDirty = 0x00008000, |
405 | VertexColorsDirty = 0x00001000 |
406 | }; |
407 | |
408 | void updateSceneManager(QQuick3DSceneManager *window); |
409 | |
410 | Lighting m_lighting = FragmentLighting; |
411 | BlendMode m_blendMode = SourceOver; |
412 | AlphaMode m_alphaMode = Default; |
413 | QColor m_albedo = Qt::white; |
414 | QQuick3DTexture *m_albedoMap = nullptr; |
415 | bool m_albedoSingleChannelEnabled = false; |
416 | TextureChannelMapping m_albedoChannel = QQuick3DMaterial::R; |
417 | bool m_specularSingleChannelEnabled = false; |
418 | TextureChannelMapping m_specularChannel = QQuick3DMaterial::R; |
419 | bool m_emissiveSingleChannelEnabled = false; |
420 | TextureChannelMapping m_emissiveChannel = QQuick3DMaterial::R; |
421 | QVector3D m_emissiveFactor; |
422 | QQuick3DTexture *m_emissiveMap = nullptr; |
423 | QQuick3DTexture *m_glossinessMap = nullptr; |
424 | QQuick3DTexture *m_opacityMap = nullptr; |
425 | QQuick3DTexture *m_normalMap = nullptr; |
426 | QQuick3DTexture *m_specularMap = nullptr; |
427 | QQuick3DTexture *m_occlusionMap = nullptr; |
428 | float m_glossiness = 1.0f; |
429 | bool m_invertOpacityMapValue = false; |
430 | float m_opacity = 1.0f; |
431 | QColor m_specular = Qt::white; |
432 | float m_normalStrength = 1.0f; |
433 | float m_occlusionAmount = 1.0f; |
434 | float m_alphaCutoff = 0.5f; |
435 | TextureChannelMapping m_glossinessChannel = QQuick3DMaterial::A; |
436 | TextureChannelMapping m_opacityChannel = QQuick3DMaterial::A; |
437 | TextureChannelMapping m_occlusionChannel = QQuick3DMaterial::R; |
438 | float m_pointSize = 1.0f; |
439 | float m_lineWidth = 1.0f; |
440 | QQuick3DTexture *m_heightMap = nullptr; |
441 | TextureChannelMapping m_heightChannel = QQuick3DMaterial::R; |
442 | float m_heightAmount = 0.0f; |
443 | int m_minHeightMapSamples = 8; |
444 | int m_maxHeightMapSamples = 32; |
445 | float m_clearcoatAmount = 0.0f; |
446 | QQuick3DTexture *m_clearcoatMap = nullptr; |
447 | TextureChannelMapping m_clearcoatChannel = QQuick3DMaterial::R; |
448 | float m_clearcoatRoughnessAmount = 0.0f; |
449 | TextureChannelMapping m_clearcoatRoughnessChannel = QQuick3DMaterial::G; |
450 | QQuick3DTexture *m_clearcoatRoughnessMap = nullptr; |
451 | QQuick3DTexture *m_clearcoatNormalMap = nullptr; |
452 | float m_clearcoatNormalStrength = 1.0f; |
453 | float m_transmissionFactor = 0.0f; |
454 | QQuick3DTexture *m_transmissionMap = nullptr; |
455 | TextureChannelMapping m_transmissionChannel = QQuick3DMaterial::R; |
456 | float m_thicknessFactor = 0.0f; |
457 | QQuick3DTexture *m_thicknessMap = nullptr; |
458 | TextureChannelMapping m_thicknessChannel = QQuick3DMaterial::G; |
459 | float m_attenuationDistance = std::numeric_limits<float>::infinity(); |
460 | QColor m_attenuationColor = Qt::white; |
461 | bool m_fresnelScaleBiasEnabled = false; |
462 | float m_fresnelScale = 1.0f; |
463 | float m_fresnelBias = 0.0f; |
464 | float m_fresnelPower = 5.0f; |
465 | bool m_clearcoatFresnelScaleBiasEnabled = false; |
466 | float m_clearcoatFresnelScale = 1.0f; |
467 | float m_clearcoatFresnelBias = 0.0f; |
468 | float m_clearcoatFresnelPower = 5.0f; |
469 | bool m_vertexColorsEnabled = true; |
470 | bool m_vertexColorsMaskEnabled = false; |
471 | VertexColorMaskFlags m_vertexColorRedMask = NoMask; |
472 | VertexColorMaskFlags m_vertexColorGreenMask = NoMask; |
473 | VertexColorMaskFlags m_vertexColorBlueMask = NoMask; |
474 | VertexColorMaskFlags m_vertexColorAlphaMask = NoMask; |
475 | |
476 | quint32 m_dirtyAttributes = 0xffffffff; // all dirty by default |
477 | void markDirty(DirtyType type); |
478 | |
479 | static constexpr float ensureNormalized(float val) { return qBound(min: 0.0f, val, max: 1.0f); } |
480 | }; |
481 | |
482 | QT_END_NAMESPACE |
483 | |
484 | #endif // QQUICK3DSPECULARGLOSSYMATERIAL_P_H |
485 | |