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.cpp
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
8
9#include <QtQuick3DRuntimeRender/private/qssgrenderdefaultmaterial_p.h>
10#include <QtQuick3DUtils/private/qssgutils_p.h>
11
13
14/*!
15 \qmltype PrincipledMaterial
16 \inherits Material
17 \inqmlmodule QtQuick3D
18 \brief Lets you define a material for 3D items using the metal/roughness workflow.
19
20 Before a Model can be rendered in a scene, it must have at least one material attached
21 to it that describes how the mesh should be shaded. The PrincipledMaterial is a PBR
22 metal/roughness material that aims at being an easy to use material with a minimal
23 set of parameters.
24 In addition to having few parameters, all input values are strictly normalized
25 between 0 and 1 and have sensible defaults, meaning even without changing any values,
26 the material can be used to shader a model. For an introduction on how the
27 different properties of the principled material affects how a model is shaded,
28 see the \l{Qt Quick 3D - Principled Material Example}{Principled Material example}.
29
30 \section1 Metal/Roughness workflow
31
32 The Principled material is what's known as a metal/roughness material, in essence
33 that means the main characteristics of the material is controlled through
34 the \l {PrincipledMaterial::metalnessMap} {metallness}, \l {PrincipledMaterial::roughnessMap} {roughness},
35 and the \l {PrincipledMaterial::baseColorMap} {base color} property.
36
37 \section2 Metalness
38
39 Real world materials are put into two main categories, metals and dielectrics (non-metals).
40 In the Principled material, the category a material belongs to is decided by the
41 \c metalness value. Setting the \c metalness value to 0, means the material is a dialectric,
42 while everything above 0 is a considered to be a metal. In reality metals will have
43 a \c metalness value of 1, but values between 0 and 1 are possible, and usually used
44 for metals with reduced reflectance. For example, to render corrosion, or similar,
45 on a material, the \c metalness of the material should be reduced to give the output
46 properties more similar to a dielectric material.
47 Since the \c metalness value affects the reflectance of the material it might be tempting to
48 use the metalness to adjust glossiness, but consider what type of material you want
49 to describe first. Increasing the \c metalness value to give a dielectric material
50 a more polished look, will introduce properties that are not accurate for a dielectric
51 material, so consider if it would be more appropriate to adjust, for example,
52 the \c roughness value instead.
53
54 \section2 Roughness
55
56 The \c roughness of a material describes the condition of an object's surface.
57 A low \c roughness value means the object has a smooth surface and therefore be more
58 reflective then a material with a higher \c roughness value.
59
60 \section2 Base color
61
62 The \l {PrincipledMaterial::baseColorMap} {base color} of a metal/roughness material
63 contains both the diffuse and the specular data, how much the base color is interpreted
64 as one or the other is primarily dictated by the \c metalness value. For example,
65 a material with a metalness value of 1, will have most of its base color interpreted
66 as specular color, while the diffuse color would be a black tint. The opposite would
67 happen for a material with a metalness value of 0. This is of course a bit simplified,
68 but gives a rough idea how the \l {PrincipledMaterial::baseColor} {base color} and
69 \c metalness value interacts. For those more familiar with a Specular/Glossiness workflow,
70 there's a clear difference here which is worth noting, namely that the color data of the
71 two materials are not directly compatible, since in a Specular/Glossiness
72 \l {DefaultMaterial} {material}, the diffuse and specular color comes from separate inputs.
73*/
74
75/*!
76 \qmlproperty enumeration PrincipledMaterial::lighting
77
78 This property defines which lighting method is used when generating this
79 material.
80
81 The default value is \c PrincipledMaterial.FragmentLighting
82
83 When using \c PrincipledMaterial.FragmentLighting, diffuse and specular lighting is
84 calculated for each rendered pixel. Certain effects (such as a Fresnel or normal map) require
85 \c PrincipledMaterial.FragmentLighting to work.
86
87 When using \c PrincipledMaterial.NoLighting no lighting is calculated. This
88 mode is (predictably) very fast, and is quite effective when image maps are
89 used that you do not need to be shaded by lighting. All other shading
90 properties except baseColor values, alpha values, and vertex colors will be
91 ignored.
92
93 \value PrincipledMaterial.NoLighting
94 \value PrincipledMaterial.FragmentLighting
95*/
96
97/*!
98 \qmlproperty enumeration PrincipledMaterial::blendMode
99
100 This property determines how the colors of the model rendered blends with
101 those behind it.
102
103 \value PrincipledMaterial.SourceOver Default blend mode. Opaque objects
104 occlude objects behind them. This default mode does not guarantee alpha
105 blending in the rendering pipeline on its own for models that use this
106 material, but rather makes the decision dependent on a number of factors:
107 if the object's and material's total opacity is \c{1.0}, there is no
108 opacity map in the material, and \l alphaMode is not set to a value that
109 enforces alpha blending, then the model is treated as opaque, meaning it is
110 rendered with depth testing and depth write enabled, together with other
111 opaque objects, with blending disabled. Otherwise the model is treated as
112 semi-transparent, and is rendered after the opaque objects, together with
113 other semi-transparent objects in a back-to-front order based on their
114 center's distance from the camera, with alpha blending enabled.
115
116 \value PrincipledMaterial.Screen Colors are blended using an inverted
117 multiply, producing a lighter result. This blend mode is order-independent;
118 if you are using semi-opaque objects and experiencing 'popping' as faces or
119 models sort differently, using Screen blending is one way to produce
120 results without popping.
121
122 \value PrincipledMaterial.Multiply Colors are blended using a multiply,
123 producing a darker result. This blend mode is also order-independent.
124
125 \sa alphaMode, {Qt Quick 3D Architecture}
126*/
127
128/*!
129 \qmlproperty color PrincipledMaterial::baseColor
130
131 This property sets the base color for the material. Depending on the type
132 of material specified (metal or dielectric) the diffuse and specular channels will be
133 set appropriately. For example, a dielectric material will have a diffuse color equal to
134 the base color, while it's specular color, depending on the specular amount, will have a
135 bright specular color. For metals the diffuse and specular channels will be mixed from
136 the base color and have a dark diffuse channel and a specular channel close to the base color.
137
138 \sa baseColorMap, alphaMode
139*/
140
141/*!
142 \qmlproperty Texture PrincipledMaterial::baseColorMap
143
144 This property defines the texture used to set the base color of the material.
145
146 \sa baseColor, alphaMode
147*/
148
149/*!
150 \qmlproperty bool PrincipledMaterial::baseColorSingleChannelEnabled
151 \since 6.8
152
153 When this property is enabled, the material will use the single value of the baseColorChannel from
154 the baseColorMap as RGB value and use 1.0 as alpha value.
155 The default value is false.
156*/
157
158/*!
159 \qmlproperty enumeration PrincipledMaterial::baseColorChannel
160 \since 6.8
161
162 This property defines the texture channel used to read the baseColor value from baseColorMap.
163 In order to use a single texture channel as color you have to enable the baseColorSingleChannelEnabled
164 The default value is \c Material.R.
165
166 \value Material.R Read value from texture R channel.
167 \value Material.G Read value from texture G channel.
168 \value Material.B Read value from texture B channel.
169 \value Material.A Read value from texture A channel.
170*/
171
172/*!
173 \qmlproperty real PrincipledMaterial::metalness
174
175 The metalness property defines the \e metalness of the the material. The value
176 is normalized, where 0.0 means the material is a \e dielectric (non-metallic) material and
177 a value of 1.0 means the material is a metal.
178
179 \note In principle, materials are either dielectrics with a metalness of 0, or metals with a
180 metalness of 1. Metalness values between 0 and 1 are still allowed and will give a material that
181 is a blend between the different models.
182
183 The range is [0.0, 1.0]. The default value is 0.
184*/
185
186/*!
187 \qmlproperty Texture PrincipledMaterial::metalnessMap
188
189 This property sets a Texture to be used to set the metalness amount for the
190 different parts of the material.
191*/
192
193/*!
194 \qmlproperty enumeration PrincipledMaterial::metalnessChannel
195
196 This property defines the texture channel used to read the metalness value from metalnessMap.
197 The default value is \c Material.B.
198
199 \value Material.R Read value from texture R channel.
200 \value Material.G Read value from texture G channel.
201 \value Material.B Read value from texture B channel.
202 \value Material.A Read value from texture A channel.
203*/
204
205/*!
206 \qmlproperty bool PrincipledMaterial::emissiveSingleChannelEnabled
207 \since 6.8
208
209 When this property is enabled, the material will use the single value of the emissiveChannel from
210 the emissiveMap as RGB value.
211 The default value is false.
212*/
213
214/*!
215 \qmlproperty enumeration PrincipledMaterial::emissiveChannel
216 \since 6.8
217
218 This property defines the texture channel used to read the emissive value from emissiveMap.
219 In order to use a single texture channel as color you have to enable the emissiveSingleChannelEnabled
220 The default value is \c Material.R.
221
222 \value Material.R Read value from texture R channel.
223 \value Material.G Read value from texture G channel.
224 \value Material.B Read value from texture B channel.
225 \value Material.A Read value from texture A channel.
226*/
227
228/*!
229 \qmlproperty Texture PrincipledMaterial::emissiveMap
230
231 This property sets a RGB Texture to be used to specify the intensity of the
232 emissive color.
233*/
234
235/*!
236 \qmlproperty vector3d PrincipledMaterial::emissiveFactor
237
238 This property determines the color of self-illumination for this material.
239 If an emissive map is set, the x, y, and z components are used as factors
240 (multipliers) for the R, G and B channels of the texture, respectively.
241 The default value is (0, 0, 0) and it means no emissive contribution at all.
242
243 \note Setting the lightingMode to DefaultMaterial.NoLighting means emissive
244 Factor does not have an effect on the scene.
245*/
246
247/*!
248 \qmlproperty Texture PrincipledMaterial::specularReflectionMap
249
250 This property sets a Texture used for specular highlights on the material.
251
252 This is typically used to perform environment mapping: as the model is
253 rotated, the map will appear as though it is reflecting from the
254 environment. For this to work as expected, the Texture's
255 \l{Texture::mappingMode}{mappingMode} needs to be set to
256 Texture.Environment. Specular reflection maps are an easy way to add a
257 high-quality look with a relatively low cost.
258
259 \note Associating a \l{SceneEnvironment::lightProbe}{light probe} with the
260 \l SceneEnvironment, and thus relying on image-based lighting, can achieve
261 similar environmental reflection effects. Light probes are however a
262 conceptually different, and when it comes to performance, potentially more
263 expensive solution. Each approaches have their own specific uses, and the
264 one to use needs to be decided on a case by case basis. When it comes to
265 the Texture set to the property, specularReflectionMap has an advantage,
266 because it presents no limitations and supports all types of textures,
267 including ones that source their data from a Qt Quick sub-scene via
268 \l{Texture::sourceItem}{sourceItem}.
269
270 \note Crisp images cause your material to look very glossy; the more you
271 blur your image the softer your material will appear.
272
273 \sa Texture::mappingMode
274*/
275
276/*!
277 \qmlproperty Texture PrincipledMaterial::specularMap
278
279 The property defines a RGB Texture to modulate the amount and the color of
280 specularity across the surface of the material. These values are multiplied
281 by the specularAmount.
282
283 \note The specular map will be ignored unless the material is dielectric.
284*/
285
286/*!
287 \qmlproperty bool PrincipledMaterial::specularSingleChannelEnabled
288 \since 6.8
289
290 When this property is enabled, the material will use the single value of the specularChannel from
291 the specularMap as RGB value.
292 The default value is false.
293*/
294
295/*!
296 \qmlproperty enumeration PrincipledMaterial::specularChannel
297 \since 6.8
298
299 This property defines the texture channel used to read the specular color value from specularMap.
300 In order to use a single texture channel as color you have to enable the specularSingleChannelEnabled
301 The default value is \c Material.R.
302
303 \value Material.R Read value from texture R channel.
304 \value Material.G Read value from texture G channel.
305 \value Material.B Read value from texture B channel.
306 \value Material.A Read value from texture A channel.
307*/
308
309/*!
310 \qmlproperty real PrincipledMaterial::specularTint
311
312 This property defines how much of the base color contributes to the specular reflections.
313
314 \note This property does only apply to dielectric materials.
315*/
316
317/*!
318 \qmlproperty real PrincipledMaterial::specularAmount
319
320 This property controls the strength of specularity (highlights and
321 reflections).
322
323 The range is [0.0, 1.0]. The default value is \c 1.0.
324
325 \note For non-dielectrics (metals) this property has no effect.
326
327 \note This property does not affect the specularReflectionMap, but does affect the amount of
328 reflections from a scenes SceneEnvironment::lightProbe.
329*/
330
331/*!
332 \qmlproperty real PrincipledMaterial::roughness
333
334 This property controls the size of the specular highlight generated from
335 lights, and the clarity of reflections in general. Larger values increase
336 the roughness, softening specular highlights and blurring reflections.
337 The range is [0.0, 1.0]. The default value is 0.
338*/
339
340/*!
341 \qmlproperty Texture PrincipledMaterial::roughnessMap
342
343 This property defines a Texture to control the specular roughness of the
344 material.
345*/
346
347/*!
348 \qmlproperty enumeration PrincipledMaterial::roughnessChannel
349
350 This property defines the texture channel used to read the roughness value from roughnessMap.
351 The default value is \c Material.G.
352
353 \value Material.R Read value from texture R channel.
354 \value Material.G Read value from texture G channel.
355 \value Material.B Read value from texture B channel.
356 \value Material.A Read value from texture A channel.
357*/
358
359/*!
360 \qmlproperty real PrincipledMaterial::opacity
361
362 This property drops the opacity of just this material, separate from the
363 model.
364*/
365
366/*!
367 \qmlproperty Texture PrincipledMaterial::opacityMap
368
369 This property defines a Texture used to control the opacity differently for
370 different parts of the material.
371*/
372
373/*!
374 \qmlproperty real PrincipledMaterial::invertOpacityMapValue
375 \since 6.8
376
377 This property inverts the opacity value of the opacityMap.
378 The default value is \c false.
379*/
380
381/*!
382 \qmlproperty enumeration PrincipledMaterial::opacityChannel
383
384 This property defines the texture channel used to read the opacity value from opacityMap.
385 The default value is \c Material.A.
386
387 \value Material.R Read value from texture R channel.
388 \value Material.G Read value from texture G channel.
389 \value Material.B Read value from texture B channel.
390 \value Material.A Read value from texture A channel.
391*/
392
393/*!
394 \qmlproperty Texture PrincipledMaterial::normalMap
395
396 This property defines an RGB image used to simulate fine geometry
397 displacement across the surface of the material. The RGB channels indicate
398 XYZ normal deviations.
399
400 \note Normal maps will not affect the silhouette of a model.
401*/
402
403/*!
404 \qmlproperty real PrincipledMaterial::normalStrength
405
406 This property controls the amount of simulated displacement for the normalMap.
407*/
408
409/*!
410 \qmlproperty real PrincipledMaterial::occlusionAmount
411
412 This property contains the factor used to modify the values from the \l occlusionMap texture.
413 The value should be between 0.0 to 1.0. The default is 1.0
414*/
415
416/*!
417 \qmlproperty Texture PrincipledMaterial::occlusionMap
418
419 This property defines a texture used to determine how much light the
420 different areas of the material should receive. Values are expected to be
421 linear from 0.0 to 1.0, where 0.0 means no lighting and 1.0 means the
422 effect of the lighting is left unchanged.
423
424 \sa occlusionAmount
425*/
426
427/*!
428 \qmlproperty enumeration PrincipledMaterial::occlusionChannel
429
430 This property defines the texture channel used to read the occlusion value from occlusionMap.
431 The default value is \c Material.R.
432
433 \value Material.R Read value from texture R channel.
434 \value Material.G Read value from texture G channel.
435 \value Material.B Read value from texture B channel.
436 \value Material.A Read value from texture A channel.
437*/
438
439/*!
440 \qmlproperty enumeration PrincipledMaterial::alphaMode
441
442 This property specifies how the alpha color value from \l baseColor and the
443 alpha channel of a \l{baseColorMap}{base color map} are used.
444
445 \note The alpha cutoff test only considers the base color alpha. \l opacity
446 and \l [QtQuick3D] {Node::opacity} are not taken into account there.
447
448 \note When sampling a base color map, the effective alpha value is the
449 sampled alpha multiplied by the \l baseColor alpha.
450
451 \value PrincipledMaterial.Default No test is applied, the effective alpha
452 value is passed on as-is. Note that a \l baseColor or \l baseColorMap alpha
453 less than \c 1.0 does not automatically imply alpha blending, the object
454 with the material may still be treated as opaque, if no other relevant
455 properties (such as, an opacity less than 1, the presence of an opacity
456 map, or a non-default \l blendMode value) trigger treating the object as
457 semi-transparent. To ensure alpha blending happens regardless of any other
458 object or material property, set \c Blend instead.
459
460 \value PrincipledMaterial.Blend No cutoff test is applied, but guarantees
461 that alpha blending happens. The object with this material will therefore
462 never be treated as opaque by the renderer.
463
464 \value PrincipledMaterial.Opaque No cutoff test is applied and the rendered
465 object is assumed to be fully opaque, meaning the alpha values in the
466 vertex color, base color, and base color map are ignored and a value of 1.0
467 is substituted instead. This mode does not guarantee alpha blending does
468 not happen. If relevant properties (such as, an opacity less than 1, an
469 opacity map, or a non-default \l blendMode) say so, then the object will
470 still be treated as semi-transparent by the rendering pipeline, just like
471 with the \c Default alphaMode.
472
473 \value PrincipledMaterial.Mask A test based on \l alphaCutoff is applied.
474 If the effective alpha value falls below \l alphaCutoff, the fragment is
475 changed to fully transparent and is discarded (with all implications of
476 discarding: the depth buffer is not written for that fragment). Otherwise
477 the alpha is changed to 1.0, so that the fragment will become fully opaque.
478 When it comes to alpha blending, the behavior of this mode is identical to
479 \c Opaque, regardless of the cutoff test's result. This means that the
480 \l{https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#alpha-coverage}{glTF
481 2 spec's alpha coverage} Implementation Notes are fulfilled. Objects with
482 alpha cutoff tests can also cast shadows since they behave like opaque
483 objects by default, unless the relevant properties (such as, an opacity
484 less than 1, an opacity map, or a non-default \l blendMode) imply otherwise
485 (in which case casting shadows will not be possible).
486
487 \sa alphaCutoff, blendMode
488*/
489
490/*!
491 \qmlproperty real PrincipledMaterial::alphaCutoff
492
493 The alphaCutoff property can be used to specify the cutoff value when using
494 the \l{alphaMode}{Mask alphaMode}. Fragments where the alpha value falls
495 below the threshold will be rendered fully transparent (\c{0.0} for all
496 color channels). When the alpha value is equal or greater than the cutoff
497 value, the color will not be affected in any way.
498
499 The default value is 0.5.
500
501 \sa alphaMode
502*/
503
504/*!
505 \qmlproperty real PrincipledMaterial::pointSize
506
507 This property determines the size of the points rendered, when the geometry
508 is using a primitive type of points. The default value is 1.0. This
509 property is not relevant when rendering other types of geometry, such as,
510 triangle meshes.
511
512 \warning Point sizes other than 1 may not be supported at run time,
513 depending on the underyling graphics API. For example, setting a size other
514 than 1 has no effect with Direct 3D.
515*/
516
517/*!
518 \qmlproperty real PrincipledMaterial::lineWidth
519
520 This property determines the width of the lines rendered, when the geometry
521 is using a primitive type of lines or line strips. The default value is
522 1.0. This property is not relevant when rendering other types of geometry,
523 such as, triangle meshes.
524
525 \warning Line widths other than 1 may not be suported at run time,
526 depending on the underlying graphics API. When that is the case, the
527 request to change the width is ignored. For example, none of the following
528 can be expected to support wide lines: Direct3D, Metal, OpenGL with core
529 profile contexts.
530*/
531
532/*!
533 \qmlproperty Texture PrincipledMaterial::heightMap
534
535 This property defines a texture used to determine the height the texture
536 will be displaced when rendered through the use of Parallax Mapping. Values
537 are expected to be linear from 0.0 to 1.0, where 0.0 means no displacement
538 and 1.0 means means maximum displacement.
539
540*/
541
542/*!
543 \qmlproperty enumeration PrincipledMaterial::heightChannel
544
545 This property defines the texture channel used to read the height value
546 from heightMap. The default value is \c Material.R.
547
548 \value Material.R Read value from texture R channel.
549 \value Material.G Read value from texture G channel.
550 \value Material.B Read value from texture B channel.
551 \value Material.A Read value from texture A channel.
552
553*/
554
555/*!
556 \qmlproperty real PrincipledMaterial::heightAmount
557
558 This property contains the factor used to modify the values from the
559 \l heightMap texture. The value should be between 0.0 to 1.0. The default
560 value is 0.0 which means that height displacement will be disabled, even
561 if a height map set.
562*/
563
564/*!
565 \qmlproperty int PrincipledMaterial::minHeightMapSamples
566
567 This property defines the minimum number of samples used for performing
568 Parallex Occlusion Mapping using the \l heightMap. The minHeightMapSamples
569 value is the number of samples of the heightMap are used when looking directly
570 at a surface (when the camera view is perpendicular to the fragment).
571 The default value is 8.
572
573 The actual number of samples used for each fragment will be between
574 \l minHeightMapSamples and \l maxHeightMapSamples depending on the angle of
575 the camera relative to the surface being rendered.
576
577 \note This value should only be adjusted to fine tune materials using a
578 \l heightMap in the case undesired artifacts are present.
579*/
580
581/*!
582 \qmlproperty int PrincipledMaterial::maxHeightMapSamples
583
584 This property defines the maximum number of samples used for performing
585 Parallex Occlusion Mapping using the \l heightMap. The maxHeightMapSamples
586 value is the number of samples of the heightMap are used when looking
587 parallel to a surface.
588 The default value is 32.
589
590 The actual number of samples used for each fragment will be between
591 \l minHeightMapSamples and \l maxHeightMapSamples depending on the angle of
592 the camera relative to the surface being rendered.
593
594 \note This value should only be adjusted to fine tune materials using a
595 \l heightMap in the case undesired artifacts are present.
596*/
597
598/*!
599 \qmlproperty real PrincipledMaterial::clearcoatAmount
600
601 This property defines the intensity of the clearcoat layer.
602
603 The default value is \c 0.0
604*/
605
606/*!
607 \qmlproperty Texture PrincipledMaterial::clearcoatMap
608
609 This property defines a texture used to determine the intensity of the
610 clearcoat layer. The value of\l clearcoatAmount will be multiplied by
611 the value read from this texture.
612
613*/
614
615/*!
616 \qmlproperty enumeration PrincipledMaterial::clearcoatChannel
617
618 This property defines the texture channel used to read the clearcoat amount
619 value from \l clearcoatMap. The default value is \c Material.R.
620
621 \value Material.R Read value from texture R channel.
622 \value Material.G Read value from texture G channel.
623 \value Material.B Read value from texture B channel.
624 \value Material.A Read value from texture A channel.
625
626*/
627
628/*!
629 \qmlproperty real PrincipledMaterial::clearcoatRoughnessAmount
630
631 This property defines the roughness of the clearcoat layer.
632 The default value is \c 0.0
633*/
634
635/*!
636 \qmlproperty Texture PrincipledMaterial::clearcoatRoughnessMap
637
638 This property defines a texture used to determine the roughness of the
639 clearcoat layer. The value of\l clearcoatRoughnessAmount will be
640 multiplied by the value read from this texture.
641
642*/
643
644/*!
645 \qmlproperty enumeration PrincipledMaterial::clearcoatRoughnessChannel
646
647 This property defines the texture channel used to read the clearcoat
648 roughness amount from \l clearcoatRoughnessMap.
649 The default value is \c Material.G.
650
651 \value Material.R Read value from texture R channel.
652 \value Material.G Read value from texture G channel.
653 \value Material.B Read value from texture B channel.
654 \value Material.A Read value from texture A channel.
655
656*/
657
658/*!
659 \qmlproperty Texture PrincipledMaterial::clearcoatNormalMap
660
661 This property defines a texture used to determine the normal mapping
662 applied to the clearcoat layer.
663
664*/
665
666
667/*!
668 \qmlproperty real PrincipledMaterial::clearcoatNormalStrength
669
670 This property controls the amount of simulated displacement for the clearcoatNormalMap.
671*/
672
673/*!
674 \qmlproperty color PrincipledMaterial::sheenColor
675 \since 6.13
676
677 This property defines the color and intensity of the sheen layer, a soft
678 retroreflective highlight at grazing angles that is characteristic of
679 cloth and fabric.
680
681 The sheen layer is disabled while this color is black, so setting a color
682 is what enables sheen. Note that \l sheenColorMap is multiplied with this
683 value, which means the map has no effect while the color is black.
684
685 The sheen layer is applied underneath the clearcoat layer and reduces the
686 energy of the layers below it, so enabling sheen darkens the base
687 material slightly.
688
689 The default value is \c "black", which disables sheen.
690
691 \sa sheenColorMap, sheenRoughness
692*/
693
694/*!
695 \qmlproperty Texture PrincipledMaterial::sheenColorMap
696 \since 6.13
697
698 This property defines a texture used to set the color of the sheen layer
699 per fragment. The RGB channels of the texture are multiplied with
700 \l sheenColor, so a \l sheenColor must be set for this map to have any
701 effect.
702
703 \note Texture maps are optional. Materials that use a large number of
704 maps at the same time can exceed the number of texture samplers
705 available to a fragment shader on some graphics APIs.
706
707 \sa sheenColor
708*/
709
710/*!
711 \qmlproperty real PrincipledMaterial::sheenRoughness
712 \since 6.13
713
714 This property defines how soft and spread out the sheen highlight is.
715 Lower values give a tight highlight close to the silhouette, higher
716 values spread the sheen across the whole surface.
717
718 The value is in the range \c 0.0 to \c 1.0. The default value is \c 0.0.
719
720 \sa sheenRoughnessMap, sheenColor
721*/
722
723/*!
724 \qmlproperty Texture PrincipledMaterial::sheenRoughnessMap
725 \since 6.13
726
727 This property defines a texture used to set the sheen roughness per
728 fragment. The value read from the texture is multiplied with
729 \l sheenRoughness.
730
731 \sa sheenRoughness, sheenRoughnessChannel
732*/
733
734/*!
735 \qmlproperty enumeration PrincipledMaterial::sheenRoughnessChannel
736 \since 6.13
737
738 This property defines the texture channel used to read the sheen
739 roughness value from \l sheenRoughnessMap. The default value is
740 \c Material.A, which is the channel the glTF
741 \c KHR_materials_sheen extension packs sheen roughness into.
742
743 \value Material.R Read value from texture R channel.
744 \value Material.G Read value from texture G channel.
745 \value Material.B Read value from texture B channel.
746 \value Material.A Read value from texture A channel.
747
748 \sa sheenRoughnessMap
749*/
750
751/*!
752 \qmlproperty real PrincipledMaterial::anisotropyStrength
753 \since 6.13
754
755 This property defines how strongly the specular highlight is stretched
756 along one direction of the surface, which is what gives brushed metal,
757 hair and vinyl their characteristic streaked reflections.
758
759 A value of \c 0.0, the default, means the highlight is round and the
760 material behaves exactly as before. Increasing the value stretches the
761 highlight perpendicular to the anisotropy direction, up to \c 1.0.
762
763 For anisotropy to be oriented meaningfully the mesh should provide tangent
764 data, or the material should use a \l normalMap, since both establish a
765 tangent frame. If neither is available a stable tangent frame is derived
766 from the surface normal instead, in which case the highlight still stretches
767 but its direction across the surface is arbitrary.
768
769 \sa anisotropyRotation, anisotropyMap
770*/
771
772/*!
773 \qmlproperty real PrincipledMaterial::anisotropyRotation
774 \since 6.13
775
776 This property rotates the anisotropy direction within the tangent plane of
777 the surface, in degrees. The default value is \c 0, which aligns the
778 direction with the tangent of the mesh.
779
780 \note The glTF \c KHR_materials_anisotropy extension expresses this angle
781 in radians. This property is in degrees, matching the other angles in the
782 Qt Quick 3D API, and the asset importer converts on import.
783
784 \sa anisotropyStrength, anisotropyMap
785*/
786
787/*!
788 \qmlproperty Texture PrincipledMaterial::anisotropyMap
789 \since 6.13
790
791 This property defines a texture used to vary the anisotropy across the
792 surface. Unlike the other maps this one has a fixed channel layout, so
793 there is no channel property to go with it:
794
795 \list
796 \li The red and green channels hold the anisotropy direction in tangent
797 space, encoded so that \c 0.0 to \c 1.0 maps to \c -1.0 to \c 1.0.
798 The direction is then rotated by \l anisotropyRotation.
799 \li The blue channel is multiplied with \l anisotropyStrength.
800 \endlist
801
802 Since the blue channel scales the strength, this map has no effect while
803 \l anisotropyStrength is \c 0.0.
804
805 \note Texture maps are optional. Materials that use a large number of
806 maps at the same time can exceed the number of texture samplers
807 available to a fragment shader on some graphics APIs.
808
809 \sa anisotropyStrength, anisotropyRotation
810*/
811
812/*!
813 \qmlproperty real PrincipledMaterial::iridescenceFactor
814 \since 6.13
815
816 This property defines the strength of a thin film of material over the
817 surface, which produces the shifting colors of a soap bubble, an oil slick
818 or a beetle shell. Light reflecting off the two faces of the film
819 interferes with itself, and which wavelengths cancel out depends on the
820 thickness of the film and the angle it is viewed from, so the hue changes
821 as the surface curves away.
822
823 The value is in the range \c 0.0 to \c 1.0 and blends between the
824 material without and with the film. The default value is \c 0.0, which
825 disables iridescence.
826
827 \sa iridescenceMap, iridescenceIndexOfRefraction, iridescenceThicknessMaximum
828*/
829
830/*!
831 \qmlproperty Texture PrincipledMaterial::iridescenceMap
832 \since 6.13
833
834 This property defines a texture used to vary the strength of the
835 iridescence across the surface. The value read from the texture is
836 multiplied with \l iridescenceFactor, so a non-zero
837 \l iridescenceFactor is needed for this map to have any effect.
838
839 \note Texture maps are optional. Materials that use a large number of
840 maps at the same time can exceed the number of texture samplers
841 available to a fragment shader on some graphics APIs.
842
843 \sa iridescenceFactor, iridescenceChannel
844*/
845
846/*!
847 \qmlproperty enumeration PrincipledMaterial::iridescenceChannel
848 \since 6.13
849
850 This property defines the texture channel used to read the iridescence
851 strength from \l iridescenceMap. The default value is \c Material.R.
852
853 \value Material.R Read value from texture R channel.
854 \value Material.G Read value from texture G channel.
855 \value Material.B Read value from texture B channel.
856 \value Material.A Read value from texture A channel.
857
858 \sa iridescenceMap
859*/
860
861/*!
862 \qmlproperty real PrincipledMaterial::iridescenceIndexOfRefraction
863 \since 6.13
864
865 This property defines the index of refraction of the thin film itself,
866 which together with the thickness decides which colors the film produces.
867 The default value is \c 1.3, which is roughly that of a soap film.
868
869 Note that this is the index of refraction of the film, not of the material
870 underneath it. The latter is \l indexOfRefraction.
871
872 \sa iridescenceFactor, indexOfRefraction
873*/
874
875/*!
876 \qmlproperty real PrincipledMaterial::iridescenceThicknessMinimum
877 \since 6.13
878
879 This property defines the thickness of the thin film in nanometers where
880 \l iridescenceThicknessMap reads \c 0.0. The default value is \c 100.
881
882 It has no effect unless an \l iridescenceThicknessMap is set, since
883 without one the film is uniformly
884 \l iridescenceThicknessMaximum thick.
885
886 \sa iridescenceThicknessMaximum, iridescenceThicknessMap
887*/
888
889/*!
890 \qmlproperty real PrincipledMaterial::iridescenceThicknessMaximum
891 \since 6.13
892
893 This property defines the thickness of the thin film in nanometers where
894 \l iridescenceThicknessMap reads \c 1.0, and the thickness of the whole
895 film when no thickness map is set. The default value is \c 400.
896
897 Thickness is what selects the hue, so varying this across the range of
898 visible light, roughly \c 200 to \c 800 nanometers, sweeps through the
899 colors the film can produce.
900
901 \sa iridescenceThicknessMinimum, iridescenceThicknessMap
902*/
903
904/*!
905 \qmlproperty Texture PrincipledMaterial::iridescenceThicknessMap
906 \since 6.13
907
908 This property defines a texture used to vary the thickness of the thin
909 film across the surface, and with it the color. The value read from the
910 texture interpolates between \l iridescenceThicknessMinimum and
911 \l iridescenceThicknessMaximum.
912
913 When no map is set the film is uniformly
914 \l iridescenceThicknessMaximum thick.
915
916 \sa iridescenceThicknessMinimum, iridescenceThicknessMaximum, iridescenceThicknessChannel
917*/
918
919/*!
920 \qmlproperty enumeration PrincipledMaterial::iridescenceThicknessChannel
921 \since 6.13
922
923 This property defines the texture channel used to read the film thickness
924 from \l iridescenceThicknessMap. The default value is \c Material.G,
925 which is the channel the glTF \c KHR_materials_iridescence extension
926 packs the thickness into.
927
928 \value Material.R Read value from texture R channel.
929 \value Material.G Read value from texture G channel.
930 \value Material.B Read value from texture B channel.
931 \value Material.A Read value from texture A channel.
932
933 \sa iridescenceThicknessMap
934*/
935
936/*!
937 \qmlproperty real PrincipledMaterial::dispersion
938 \since 6.13
939
940 This property defines how much the index of refraction varies across
941 wavelengths, which splits light refracted through the material into color
942 fringes, as a prism does.
943
944 Dispersion only affects light refracted through the volume of the material,
945 so it has no effect unless \l transmissionFactor and \l thicknessFactor
946 are set. It does not affect the reflected specular highlight.
947
948 Following the glTF \c KHR_materials_dispersion extension the value is
949 given as 20 divided by the Abbe number of the material, so \c 1.0
950 corresponds to an Abbe number of 20, about as dispersive as ordinary
951 materials get. Window glass is roughly \c 0.3, and a lead crystal or a
952 diamond closer to \c 1.0. The default value is \c 0.0, which disables
953 dispersion.
954
955 \note Each of the three color channels is refracted separately, so
956 enabling dispersion triples the cost of the refraction lookup.
957
958 \sa transmissionFactor, thicknessFactor, indexOfRefraction
959*/
960
961/*!
962 \qmlproperty real PrincipledMaterial::transmissionFactor
963
964 This property defines the percentage of light that is transmitted through
965 the material's surface.
966 The default value is \c 0.0
967*/
968
969/*!
970 \qmlproperty Texture PrincipledMaterial::transmissionMap
971
972 This property defines a texture used to determine percentage of light that
973 is transmitted through the surface.. The value of
974 \l transmissionFactor will be multiplied by the value read from this
975 texture.
976
977*/
978
979/*!
980 \qmlproperty enumeration PrincipledMaterial::transmissionChannel
981
982 This property defines the texture channel used to read the transmission
983 percentage from \l transmissionMap.
984 The default value is \c Material.R.
985
986 \value Material.R Read value from texture R channel.
987 \value Material.G Read value from texture G channel.
988 \value Material.B Read value from texture B channel.
989 \value Material.A Read value from texture A channel.
990
991*/
992
993/*!
994 \qmlproperty real PrincipledMaterial::thicknessFactor
995
996 This property defines the thickness of the volume beneath the surface.
997 Unlike many other properties of PrincipledMaterial, the value in defined
998 in thicknessFactor is a value from 0.0 to +infinity for thickness in the
999 models coordinate space. A value of 0.0 means that the material is
1000 thin-walled.
1001 The default value is \c 0.0
1002*/
1003
1004/*!
1005 \qmlproperty Texture PrincipledMaterial::thicknessMap
1006
1007 This property defines a texture used to define the thickness of a
1008 material volume. The value of \l thicknessFactor will be multiplied by the
1009 value read from this texture.
1010
1011*/
1012
1013/*!
1014 \qmlproperty enumeration PrincipledMaterial::thicknessChannel
1015
1016 This property defines the texture channel used to read the thickness
1017 amount from \l transmissionMap.
1018 The default value is \c Material.G.
1019
1020 \value Material.R Read value from texture R channel.
1021 \value Material.G Read value from texture G channel.
1022 \value Material.B Read value from texture B channel.
1023 \value Material.A Read value from texture A channel.
1024
1025*/
1026
1027/*!
1028 \qmlproperty real PrincipledMaterial::attenuationDistance
1029
1030 This property defines the Density of the medium given as the average
1031 distance that light travels in the medium before interacting with a
1032 particle. The value is given in world space.
1033 The default value is \c +infinity.
1034*/
1035
1036/*!
1037 \qmlproperty color PrincipledMaterial::attenuationColor
1038
1039 This property defines the color that white lights turns into due to
1040 absorption when reaching the attenuation distance.
1041 The default value is \c Qt.White
1042
1043*/
1044
1045/*!
1046 \qmlproperty real PrincipledMaterial::indexOfRefraction
1047
1048 This property defines the index of refraction of the material. The default
1049 value of \c 1.5 will be the ideal value for materials like plastics or glass
1050 but other materials like water, asphalt, sapphire, or diamond would require
1051 and adjusted value to look more realistic. For realistic materials the
1052 indexOfRefraction should usually be between \c 1.0 and \c 3.0
1053
1054 Some examples of common materials' index of refractions are:
1055
1056 \table
1057 \header
1058 \li Material
1059 \li Index of Refraction
1060 \row
1061 \li Air
1062 \li 1.0
1063 \row
1064 \li Water
1065 \li 1.33
1066 \row
1067 \li Glass
1068 \li 1.55
1069 \row
1070 \li Sapphire
1071 \li 1.76
1072 \row
1073 \li Diamond
1074 \li 2.42
1075 \endtable
1076
1077 \note No known material in the world have ior much greater than \c 3.0.
1078*/
1079
1080/*!
1081 \qmlproperty real PrincipledMaterial::fresnelScaleBiasEnabled
1082
1083 By Setting the value to true the material will take Fresnel Scale and Fresnel Bias into account.
1084 The default value is \c false.
1085*/
1086
1087/*!
1088 \qmlproperty real PrincipledMaterial::fresnelScale
1089
1090 This property scale head-on reflections (looking directly at the
1091 surface) while maintaining reflections seen at grazing angles.
1092 In order to affect changes to the material you have to enable fresnelScaleBiasEnabled.
1093 The default value is \c 1.0.
1094*/
1095
1096/*!
1097 \qmlproperty real PrincipledMaterial::fresnelBias
1098
1099 This property push forward head-on reflections (looking directly at the
1100 surface) while maintaining reflections seen at grazing angles.
1101 In order to affect changes to the material you have to enable fresnelScaleBiasEnabled.
1102 The default value is \c 0.0.
1103*/
1104
1105/*!
1106 \qmlproperty real PrincipledMaterial::fresnelPower
1107
1108 This property decreases head-on reflections (looking directly at the
1109 surface) while maintaining reflections seen at grazing angles.
1110 The default value is \c 5.0.
1111*/
1112
1113/*!
1114 \qmlproperty real PrincipledMaterial::clearcoatFresnelScaleBiasEnabled
1115
1116 By Setting the value to true the material will take Clearcoat Fresnel Scale and Clearcoat Fresnel Bias into account.
1117 The default value is \c false.
1118*/
1119
1120/*!
1121 \qmlproperty real PrincipledMaterial::clearcoatFresnelScale
1122
1123 This property scale head-on reflections (looking directly at the
1124 surface) while maintaining reflections seen at grazing angles.
1125 In order to affect changes to the material you have to enable clearcoatFresnelScaleBiasEnabled.
1126 The default value is \c 1.0.
1127*/
1128
1129/*!
1130 \qmlproperty real PrincipledMaterial::clearcoatFresnelBias
1131
1132 This property push forward head-on reflections (looking directly at the
1133 surface) while maintaining reflections seen at grazing angles.
1134 In order to affect changes to the material you have to enable clearcoatFresnelScaleBiasEnabled.
1135 The default value is \c 0.0.
1136*/
1137
1138/*!
1139 \qmlproperty real PrincipledMaterial::clearcoatFresnelPower
1140
1141 This property decreases head-on reflections (looking directly at the
1142 surface) while maintaining reflections seen at grazing angles.
1143 The default value is \c 5.0.
1144*/
1145
1146/*!
1147 \qmlproperty bool PrincipledMaterial::vertexColorsEnabled
1148 \since 6.5
1149
1150 When this property is enabled, the material will use vertex colors from the
1151 mesh. These will be multiplied by any other colors specified for the
1152 material. The default value is true.
1153*/
1154
1155/*!
1156 \qmlproperty bool PrincipledMaterial::vertexColorsMaskEnabled
1157 \since 6.8
1158
1159 When this property is enabled, the material will use vertex colors from the
1160 mesh as mask of various properties e.g RoughnessAmount, SpecularAmount, ... .
1161 The default value is false.
1162*/
1163
1164/*!
1165 \qmlproperty enumeration PrincipledMaterial::vertexColorRedMask
1166 \since 6.8
1167
1168 This property defines the vertex color red channel used as the specifies mask.
1169 The value is a bit-wise combination of flags.
1170 The default value is \c PrincipledMaterial.NoMask.
1171
1172 \value PrincipledMaterial.NoMask.
1173 \value PrincipledMaterial.ClearcoatAmountMask.
1174 \value PrincipledMaterial.ClearcoatRoughnessAmountMask.
1175 \value PrincipledMaterial.ClearcoatNormalStrengthMask.
1176 \value PrincipledMaterial.HeightAmountMask.
1177 \value PrincipledMaterial.MetalnessMask.
1178 \value PrincipledMaterial.RoughnessMask.
1179 \value PrincipledMaterial.NormalStrengthMask.
1180 \value PrincipledMaterial.OcclusionAmountMask.
1181 \value PrincipledMaterial.SpecularAmountMask.
1182 \value PrincipledMaterial.ThicknessFactorMask.
1183 \value PrincipledMaterial.TransmissionFactorMask.
1184 */
1185
1186/*!
1187 \qmlproperty enumeration PrincipledMaterial::vertexColorGreenMask
1188 \since 6.8
1189
1190 This property defines the vertex color green channel used as the specifies mask.
1191 The value is a bit-wise combination of flags.
1192 The default value is \c PrincipledMaterial.NoMask.
1193
1194 \value PrincipledMaterial.NoMask.
1195 \value PrincipledMaterial.ClearcoatAmountMask.
1196 \value PrincipledMaterial.ClearcoatRoughnessAmountMask.
1197 \value PrincipledMaterial.ClearcoatNormalStrengthMask.
1198 \value PrincipledMaterial.HeightAmountMask.
1199 \value PrincipledMaterial.MetalnessMask.
1200 \value PrincipledMaterial.RoughnessMask.
1201 \value PrincipledMaterial.NormalStrengthMask.
1202 \value PrincipledMaterial.OcclusionAmountMask.
1203 \value PrincipledMaterial.SpecularAmountMask.
1204 \value PrincipledMaterial.ThicknessFactorMask.
1205 \value PrincipledMaterial.TransmissionFactorMask.
1206*/
1207
1208/*!
1209 \qmlproperty enumeration PrincipledMaterial::vertexColorBlueMask
1210 \since 6.8
1211
1212 This property defines the vertex color blue channel used as the specifies mask.
1213 The value is a bit-wise combination of flags.
1214 The default value is \c PrincipledMaterial.NoMask.
1215
1216 \value PrincipledMaterial.NoMask.
1217 \value PrincipledMaterial.ClearcoatAmountMask.
1218 \value PrincipledMaterial.ClearcoatRoughnessAmountMask.
1219 \value PrincipledMaterial.ClearcoatNormalStrengthMask.
1220 \value PrincipledMaterial.HeightAmountMask.
1221 \value PrincipledMaterial.MetalnessMask.
1222 \value PrincipledMaterial.RoughnessMask.
1223 \value PrincipledMaterial.NormalStrengthMask.
1224 \value PrincipledMaterial.OcclusionAmountMask.
1225 \value PrincipledMaterial.SpecularAmountMask.
1226 \value PrincipledMaterial.ThicknessFactorMask.
1227 \value PrincipledMaterial.TransmissionFactorMask.
1228*/
1229
1230/*!
1231 \qmlproperty enumeration PrincipledMaterial::vertexColorAlphaMask
1232 \since 6.8
1233
1234 This property defines the vertex color alpha channel used as the specifies mask.
1235 The value is a bit-wise combination of flags.
1236 The default value is \c PrincipledMaterial.NoMask.
1237
1238 \value PrincipledMaterial.NoMask.
1239 \value PrincipledMaterial.ClearcoatAmountMask.
1240 \value PrincipledMaterial.ClearcoatRoughnessAmountMask.
1241 \value PrincipledMaterial.ClearcoatNormalStrengthMask.
1242 \value PrincipledMaterial.HeightAmountMask.
1243 \value PrincipledMaterial.MetalnessMask.
1244 \value PrincipledMaterial.RoughnessMask.
1245 \value PrincipledMaterial.NormalStrengthMask.
1246 \value PrincipledMaterial.OcclusionAmountMask.
1247 \value PrincipledMaterial.SpecularAmountMask.
1248 \value PrincipledMaterial.ThicknessFactorMask.
1249 \value PrincipledMaterial.TransmissionFactorMask.
1250*/
1251
1252QQuick3DPrincipledMaterial::QQuick3DPrincipledMaterial(QQuick3DObject *parent)
1253 : QQuick3DMaterial(*(new QQuick3DObjectPrivate(QQuick3DObjectPrivate::Type::PrincipledMaterial)), parent)
1254{}
1255
1256QQuick3DPrincipledMaterial::~QQuick3DPrincipledMaterial()
1257{
1258}
1259
1260QQuick3DPrincipledMaterial::Lighting QQuick3DPrincipledMaterial::lighting() const
1261{
1262 return m_lighting;
1263}
1264
1265QQuick3DPrincipledMaterial::BlendMode QQuick3DPrincipledMaterial::blendMode() const
1266{
1267 return m_blendMode;
1268}
1269
1270QColor QQuick3DPrincipledMaterial::baseColor() const
1271{
1272 return m_baseColor;
1273}
1274
1275QQuick3DTexture *QQuick3DPrincipledMaterial::baseColorMap() const
1276{
1277 return m_baseColorMap;
1278}
1279
1280bool QQuick3DPrincipledMaterial::baseColorSingleChannelEnabled() const
1281{
1282 return m_baseColorSingleChannelEnabled;
1283}
1284
1285QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::baseColorChannel() const
1286{
1287 return m_baseColorChannel;
1288}
1289
1290bool QQuick3DPrincipledMaterial::specularSingleChannelEnabled() const
1291{
1292 return m_specularSingleChannelEnabled;
1293}
1294
1295QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::specularChannel() const
1296{
1297 return m_specularChannel;
1298}
1299
1300bool QQuick3DPrincipledMaterial::emissiveSingleChannelEnabled() const
1301{
1302 return m_emissiveSingleChannelEnabled;
1303}
1304
1305QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::emissiveChannel() const
1306{
1307 return m_emissiveChannel;
1308}
1309
1310QQuick3DTexture *QQuick3DPrincipledMaterial::emissiveMap() const
1311{
1312 return m_emissiveMap;
1313}
1314
1315QVector3D QQuick3DPrincipledMaterial::emissiveFactor() const
1316{
1317 return m_emissiveFactor;
1318}
1319
1320QQuick3DTexture *QQuick3DPrincipledMaterial::specularReflectionMap() const
1321{
1322 return m_specularReflectionMap;
1323}
1324
1325QQuick3DTexture *QQuick3DPrincipledMaterial::specularMap() const
1326{
1327 return m_specularMap;
1328}
1329
1330float QQuick3DPrincipledMaterial::specularTint() const
1331{
1332 return m_specularTint;
1333}
1334
1335float QQuick3DPrincipledMaterial::specularAmount() const
1336{
1337 return m_specularAmount;
1338}
1339
1340float QQuick3DPrincipledMaterial::roughness() const
1341{
1342 return m_roughness;
1343}
1344
1345QQuick3DTexture *QQuick3DPrincipledMaterial::roughnessMap() const
1346{
1347 return m_roughnessMap;
1348}
1349
1350bool QQuick3DPrincipledMaterial::invertOpacityMapValue() const
1351{
1352 return m_invertOpacityMapValue;
1353}
1354
1355float QQuick3DPrincipledMaterial::opacity() const
1356{
1357 return m_opacity;
1358}
1359
1360QQuick3DTexture *QQuick3DPrincipledMaterial::opacityMap() const
1361{
1362 return m_opacityMap;
1363}
1364
1365QQuick3DTexture *QQuick3DPrincipledMaterial::normalMap() const
1366{
1367 return m_normalMap;
1368}
1369
1370float QQuick3DPrincipledMaterial::metalness() const
1371{
1372 return m_metalnessAmount;
1373}
1374
1375QQuick3DTexture *QQuick3DPrincipledMaterial::metalnessMap() const
1376{
1377 return m_metalnessMap;
1378}
1379
1380float QQuick3DPrincipledMaterial::normalStrength() const
1381{
1382 return m_normalStrength;
1383}
1384
1385QQuick3DTexture *QQuick3DPrincipledMaterial::occlusionMap() const
1386{
1387 return m_occlusionMap;
1388}
1389
1390float QQuick3DPrincipledMaterial::occlusionAmount() const
1391{
1392 return m_occlusionAmount;
1393}
1394
1395QQuick3DPrincipledMaterial::AlphaMode QQuick3DPrincipledMaterial::alphaMode() const
1396{
1397 return m_alphaMode;
1398}
1399
1400float QQuick3DPrincipledMaterial::alphaCutoff() const
1401{
1402 return m_alphaCutoff;
1403}
1404
1405QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::roughnessChannel() const
1406{
1407 return m_roughnessChannel;
1408}
1409
1410QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::opacityChannel() const
1411{
1412 return m_opacityChannel;
1413}
1414
1415QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::metalnessChannel() const
1416{
1417 return m_metalnessChannel;
1418}
1419
1420QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::occlusionChannel() const
1421{
1422 return m_occlusionChannel;
1423}
1424
1425float QQuick3DPrincipledMaterial::pointSize() const
1426{
1427 return m_pointSize;
1428}
1429
1430float QQuick3DPrincipledMaterial::lineWidth() const
1431{
1432 return m_lineWidth;
1433}
1434
1435QQuick3DTexture *QQuick3DPrincipledMaterial::heightMap() const
1436{
1437 return m_heightMap;
1438}
1439
1440QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::heightChannel() const
1441{
1442 return m_heightChannel;
1443}
1444
1445float QQuick3DPrincipledMaterial::heightAmount() const
1446{
1447 return m_heightAmount;
1448}
1449
1450int QQuick3DPrincipledMaterial::minHeightMapSamples() const
1451{
1452 return m_minHeightMapSamples;
1453}
1454
1455int QQuick3DPrincipledMaterial::maxHeightMapSamples() const
1456{
1457 return m_maxHeightMapSamples;
1458}
1459
1460void QQuick3DPrincipledMaterial::markAllDirty()
1461{
1462 m_dirtyAttributes = 0xffffffff;
1463 QQuick3DMaterial::markAllDirty();
1464}
1465
1466void QQuick3DPrincipledMaterial::setLighting(QQuick3DPrincipledMaterial::Lighting lighting)
1467{
1468 if (m_lighting == lighting)
1469 return;
1470
1471 m_lighting = lighting;
1472 emit lightingChanged(m_lighting);
1473 markDirty(LightingModeDirty);
1474}
1475
1476void QQuick3DPrincipledMaterial::setBlendMode(QQuick3DPrincipledMaterial::BlendMode blendMode)
1477{
1478 if (m_blendMode == blendMode)
1479 return;
1480
1481 m_blendMode = blendMode;
1482 emit blendModeChanged(m_blendMode);
1483 markDirty(BlendModeDirty);
1484}
1485
1486void QQuick3DPrincipledMaterial::setBaseColor(QColor diffuseColor)
1487{
1488 if (m_baseColor == diffuseColor)
1489 return;
1490
1491 m_baseColor = diffuseColor;
1492 emit baseColorChanged(m_baseColor);
1493 markDirty(BaseColorDirty);
1494}
1495
1496void QQuick3DPrincipledMaterial::setBaseColorMap(QQuick3DTexture *baseColorMap)
1497{
1498 if (m_baseColorMap == baseColorMap)
1499 return;
1500
1501 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setBaseColorMap, baseColorMap, m_baseColorMap);
1502
1503 m_baseColorMap = baseColorMap;
1504 emit baseColorMapChanged(m_baseColorMap);
1505 markDirty(BaseColorDirty);
1506}
1507
1508void QQuick3DPrincipledMaterial::setBaseColorSingleChannelEnabled(bool baseColorSingleChannelEnabled)
1509{
1510 if (m_baseColorSingleChannelEnabled == baseColorSingleChannelEnabled)
1511 return;
1512
1513 m_baseColorSingleChannelEnabled = baseColorSingleChannelEnabled;
1514 emit baseColorSingleChannelEnabledChanged(baseColorSingleChannelEnabled);
1515 markDirty(BaseColorDirty);
1516}
1517
1518void QQuick3DPrincipledMaterial::setBaseColorChannel(TextureChannelMapping channel)
1519{
1520 if (m_baseColorChannel == channel)
1521 return;
1522
1523 m_baseColorChannel = channel;
1524 emit baseColorChannelChanged(channel);
1525 markDirty(BaseColorDirty);
1526}
1527
1528void QQuick3DPrincipledMaterial::setSpecularSingleChannelEnabled(bool specularSingleChannelEnabled)
1529{
1530 if (m_specularSingleChannelEnabled == specularSingleChannelEnabled)
1531 return;
1532
1533 m_specularSingleChannelEnabled = specularSingleChannelEnabled;
1534 emit specularSingleChannelEnabledChanged(specularSingleChannelEnabled);
1535 markDirty(SpecularDirty);
1536}
1537
1538void QQuick3DPrincipledMaterial::setSpecularChannel(TextureChannelMapping channel)
1539{
1540 if (m_specularChannel == channel)
1541 return;
1542
1543 m_specularChannel = channel;
1544 emit specularChannelChanged(channel);
1545 markDirty(SpecularDirty);
1546}
1547
1548void QQuick3DPrincipledMaterial::setEmissiveSingleChannelEnabled(bool emissiveSingleChannelEnabled)
1549{
1550 if (m_emissiveSingleChannelEnabled == emissiveSingleChannelEnabled)
1551 return;
1552
1553 m_emissiveSingleChannelEnabled = emissiveSingleChannelEnabled;
1554 emit emissiveSingleChannelEnabledChanged(emissiveSingleChannelEnabled);
1555 markDirty(EmissiveDirty);
1556}
1557
1558void QQuick3DPrincipledMaterial::setEmissiveChannel(TextureChannelMapping channel)
1559{
1560 if (m_emissiveChannel == channel)
1561 return;
1562
1563 m_emissiveChannel = channel;
1564 emit emissiveChannelChanged(channel);
1565 markDirty(EmissiveDirty);
1566}
1567
1568void QQuick3DPrincipledMaterial::setEmissiveMap(QQuick3DTexture *emissiveMap)
1569{
1570 if (m_emissiveMap == emissiveMap)
1571 return;
1572
1573 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setEmissiveMap, emissiveMap, m_emissiveMap);
1574
1575 m_emissiveMap = emissiveMap;
1576 emit emissiveMapChanged(m_emissiveMap);
1577 markDirty(EmissiveDirty);
1578}
1579
1580void QQuick3DPrincipledMaterial::setEmissiveFactor(QVector3D emissiveFactor)
1581{
1582 if (m_emissiveFactor == emissiveFactor)
1583 return;
1584
1585 m_emissiveFactor = emissiveFactor;
1586 emit emissiveFactorChanged(m_emissiveFactor);
1587 markDirty(EmissiveDirty);
1588}
1589
1590void QQuick3DPrincipledMaterial::setSpecularReflectionMap(QQuick3DTexture *specularReflectionMap)
1591{
1592 if (m_specularReflectionMap == specularReflectionMap)
1593 return;
1594
1595 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setSpecularReflectionMap, specularReflectionMap, m_specularReflectionMap);
1596
1597 m_specularReflectionMap = specularReflectionMap;
1598 emit specularReflectionMapChanged(m_specularReflectionMap);
1599 markDirty(SpecularDirty);
1600}
1601
1602void QQuick3DPrincipledMaterial::setSpecularMap(QQuick3DTexture *specularMap)
1603{
1604 if (m_specularMap == specularMap)
1605 return;
1606
1607 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setSpecularMap, specularMap, m_specularMap);
1608
1609 m_specularMap = specularMap;
1610 emit specularMapChanged(m_specularMap);
1611 markDirty(SpecularDirty);
1612}
1613
1614void QQuick3DPrincipledMaterial::setSpecularTint(float specularTint)
1615{
1616 specularTint = ensureNormalized(specularTint);
1617 if (qFuzzyCompare(m_specularTint, specularTint))
1618 return;
1619
1620 m_specularTint = specularTint;
1621 emit specularTintChanged(m_specularTint);
1622 markDirty(SpecularDirty);
1623}
1624
1625void QQuick3DPrincipledMaterial::setSpecularAmount(float specularAmount)
1626{
1627 specularAmount = ensureNormalized(specularAmount);
1628 if (qFuzzyCompare(m_specularAmount, specularAmount))
1629 return;
1630
1631 m_specularAmount = specularAmount;
1632 emit specularAmountChanged(m_specularAmount);
1633 markDirty(SpecularDirty);
1634}
1635
1636void QQuick3DPrincipledMaterial::setRoughness(float roughness)
1637{
1638 roughness = ensureNormalized(roughness);
1639 if (qFuzzyCompare(m_roughness, roughness))
1640 return;
1641
1642 m_roughness = roughness;
1643 emit roughnessChanged(m_roughness);
1644 markDirty(RoughnessDirty);
1645}
1646
1647void QQuick3DPrincipledMaterial::setRoughnessMap(QQuick3DTexture *roughnessMap)
1648{
1649 if (m_roughnessMap == roughnessMap)
1650 return;
1651
1652 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setRoughnessMap, roughnessMap, m_roughnessMap);
1653
1654 m_roughnessMap = roughnessMap;
1655 emit roughnessMapChanged(m_roughnessMap);
1656 markDirty(RoughnessDirty);
1657}
1658
1659void QQuick3DPrincipledMaterial::setInvertOpacityMapValue(bool invertOpacityMapValue)
1660{
1661 if (invertOpacityMapValue == m_invertOpacityMapValue)
1662 return;
1663
1664 m_invertOpacityMapValue = invertOpacityMapValue;
1665 emit invertOpacityMapValueChanged(m_invertOpacityMapValue);
1666 markDirty(OpacityDirty);
1667}
1668
1669void QQuick3DPrincipledMaterial::setOpacity(float opacity)
1670{
1671 opacity = ensureNormalized(opacity);
1672 if (qFuzzyCompare(m_opacity, opacity))
1673 return;
1674
1675 m_opacity = opacity;
1676 emit opacityChanged(m_opacity);
1677 markDirty(OpacityDirty);
1678}
1679
1680void QQuick3DPrincipledMaterial::setOpacityMap(QQuick3DTexture *opacityMap)
1681{
1682 if (m_opacityMap == opacityMap)
1683 return;
1684
1685 QQuick3DObjectPrivate::attachWatcher(this, &::QQuick3DPrincipledMaterial::setOpacityMap, opacityMap, m_opacityMap);
1686
1687 m_opacityMap = opacityMap;
1688 emit opacityMapChanged(m_opacityMap);
1689 markDirty(OpacityDirty);
1690}
1691
1692void QQuick3DPrincipledMaterial::setNormalMap(QQuick3DTexture *normalMap)
1693{
1694 if (m_normalMap == normalMap)
1695 return;
1696
1697 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setNormalMap, normalMap, m_normalMap);
1698
1699 m_normalMap = normalMap;
1700 emit normalMapChanged(m_normalMap);
1701 markDirty(NormalDirty);
1702}
1703
1704void QQuick3DPrincipledMaterial::setMetalness(float metalnessAmount)
1705{
1706 metalnessAmount = ensureNormalized(metalnessAmount);
1707 if (qFuzzyCompare(m_metalnessAmount, metalnessAmount))
1708 return;
1709
1710 m_metalnessAmount = metalnessAmount;
1711 emit metalnessChanged(m_metalnessAmount);
1712 markDirty(MetalnessDirty);
1713}
1714
1715void QQuick3DPrincipledMaterial::setMetalnessMap(QQuick3DTexture *metallicMap)
1716{
1717 if (m_metalnessMap == metallicMap)
1718 return;
1719
1720 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setMetalnessMap, metallicMap, m_metalnessMap);
1721
1722 m_metalnessMap = metallicMap;
1723 emit metalnessMapChanged(m_metalnessMap);
1724 markDirty(MetalnessDirty);
1725}
1726
1727void QQuick3DPrincipledMaterial::setNormalStrength(float factor)
1728{
1729 factor = ensureNormalized(factor);
1730 if (qFuzzyCompare(m_normalStrength, factor))
1731 return;
1732
1733 m_normalStrength = factor;
1734 emit normalStrengthChanged(m_normalStrength);
1735 markDirty(NormalDirty);
1736}
1737
1738void QQuick3DPrincipledMaterial::setOcclusionMap(QQuick3DTexture *occlusionMap)
1739{
1740 if (m_occlusionMap == occlusionMap)
1741 return;
1742
1743 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setOcclusionMap, occlusionMap, m_occlusionMap);
1744
1745 m_occlusionMap = occlusionMap;
1746 emit occlusionMapChanged(m_occlusionMap);
1747 markDirty(OcclusionDirty);
1748}
1749
1750void QQuick3DPrincipledMaterial::setOcclusionAmount(float occlusionAmount)
1751{
1752 if (qFuzzyCompare(m_occlusionAmount, occlusionAmount))
1753 return;
1754
1755 m_occlusionAmount = occlusionAmount;
1756 emit occlusionAmountChanged(m_occlusionAmount);
1757 markDirty(OcclusionDirty);
1758}
1759
1760void QQuick3DPrincipledMaterial::setAlphaMode(QQuick3DPrincipledMaterial::AlphaMode alphaMode)
1761{
1762 if (m_alphaMode == alphaMode)
1763 return;
1764
1765 m_alphaMode = alphaMode;
1766 emit alphaModeChanged(m_alphaMode);
1767 markDirty(AlphaModeDirty);
1768}
1769
1770void QQuick3DPrincipledMaterial::setAlphaCutoff(float alphaCutoff)
1771{
1772 if (qFuzzyCompare(m_alphaCutoff, alphaCutoff))
1773 return;
1774
1775 m_alphaCutoff = alphaCutoff;
1776 emit alphaCutoffChanged(m_alphaCutoff);
1777 markDirty(AlphaModeDirty);
1778}
1779
1780void QQuick3DPrincipledMaterial::setMetalnessChannel(TextureChannelMapping channel)
1781{
1782 if (m_metalnessChannel == channel)
1783 return;
1784
1785 m_metalnessChannel = channel;
1786 emit metalnessChannelChanged(channel);
1787 markDirty(MetalnessDirty);
1788}
1789
1790void QQuick3DPrincipledMaterial::setRoughnessChannel(TextureChannelMapping channel)
1791{
1792 if (m_roughnessChannel == channel)
1793 return;
1794
1795 m_roughnessChannel = channel;
1796 emit roughnessChannelChanged(channel);
1797 markDirty(RoughnessDirty);
1798}
1799
1800void QQuick3DPrincipledMaterial::setOpacityChannel(TextureChannelMapping channel)
1801{
1802 if (m_opacityChannel == channel)
1803 return;
1804
1805 m_opacityChannel = channel;
1806 emit opacityChannelChanged(channel);
1807 markDirty(OpacityDirty);
1808}
1809
1810void QQuick3DPrincipledMaterial::setOcclusionChannel(TextureChannelMapping channel)
1811{
1812 if (m_occlusionChannel == channel)
1813 return;
1814
1815 m_occlusionChannel = channel;
1816 emit occlusionChannelChanged(channel);
1817 markDirty(OcclusionDirty);
1818}
1819
1820void QQuick3DPrincipledMaterial::setPointSize(float size)
1821{
1822 if (qFuzzyCompare(m_pointSize, size))
1823 return;
1824 m_pointSize = size;
1825 emit pointSizeChanged();
1826 markDirty(PointSizeDirty);
1827}
1828
1829void QQuick3DPrincipledMaterial::setLineWidth(float width)
1830{
1831 if (qFuzzyCompare(m_lineWidth, width))
1832 return;
1833 m_lineWidth = width;
1834 emit lineWidthChanged();
1835 markDirty(LineWidthDirty);
1836}
1837
1838void QQuick3DPrincipledMaterial::setHeightMap(QQuick3DTexture *heightMap)
1839{
1840 if (m_heightMap == heightMap)
1841 return;
1842
1843 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setHeightMap, heightMap, m_heightMap);
1844
1845 m_heightMap = heightMap;
1846 emit heightMapChanged(m_heightMap);
1847 markDirty(HeightDirty);
1848}
1849
1850void QQuick3DPrincipledMaterial::setHeightChannel(QQuick3DMaterial::TextureChannelMapping channel)
1851{
1852 if (m_heightChannel == channel)
1853 return;
1854
1855 m_heightChannel = channel;
1856 emit heightChannelChanged(m_heightChannel);
1857 markDirty(HeightDirty);
1858}
1859
1860void QQuick3DPrincipledMaterial::setHeightAmount(float heightAmount)
1861{
1862 if (m_heightAmount == heightAmount)
1863 return;
1864
1865 m_heightAmount = heightAmount;
1866 emit heightAmountChanged(m_heightAmount);
1867 markDirty(HeightDirty);
1868}
1869
1870void QQuick3DPrincipledMaterial::setMinHeightMapSamples(int samples)
1871{
1872 if (m_minHeightMapSamples == samples)
1873 return;
1874
1875 m_minHeightMapSamples = samples;
1876 emit minHeightMapSamplesChanged(samples);
1877 markDirty(HeightDirty);
1878}
1879
1880void QQuick3DPrincipledMaterial::setMaxHeightMapSamples(int samples)
1881{
1882 if (m_maxHeightMapSamples == samples)
1883 return;
1884
1885 m_maxHeightMapSamples = samples;
1886 emit maxHeightMapSamplesChanged(samples);
1887 markDirty(HeightDirty);
1888}
1889
1890QSSGRenderGraphObject *QQuick3DPrincipledMaterial::updateSpatialNode(QSSGRenderGraphObject *node)
1891{
1892 static const auto channelMapping = [](TextureChannelMapping mapping) {
1893 return QSSGRenderDefaultMaterial::TextureChannelMapping(mapping);
1894 };
1895
1896 if (!node) {
1897 markAllDirty();
1898 node = new QSSGRenderDefaultMaterial(QSSGRenderGraphObject::Type::PrincipledMaterial);
1899 }
1900
1901 // Set common material properties
1902 QQuick3DMaterial::updateSpatialNode(node);
1903
1904 QSSGRenderDefaultMaterial *material = static_cast<QSSGRenderDefaultMaterial *>(node);
1905
1906 material->specularModel = QSSGRenderDefaultMaterial::MaterialSpecularModel::SchlickGGX;
1907
1908 if (m_dirtyAttributes & LightingModeDirty)
1909 material->lighting = QSSGRenderDefaultMaterial::MaterialLighting(m_lighting);
1910
1911 if (m_dirtyAttributes & BlendModeDirty)
1912 material->blendMode = QSSGRenderDefaultMaterial::MaterialBlendMode(m_blendMode);
1913
1914 if (m_dirtyAttributes & BaseColorDirty) {
1915 if (!m_baseColorMap)
1916 material->colorMap = nullptr;
1917 else
1918 material->colorMap = m_baseColorMap->getRenderImage();
1919
1920 material->color = QSSGUtils::color::sRGBToLinear(m_baseColor);
1921 material->baseColorSingleChannelEnabled = m_baseColorSingleChannelEnabled;
1922 material->baseColorChannel = channelMapping(m_baseColorChannel);
1923 }
1924
1925 if (m_dirtyAttributes & EmissiveDirty) {
1926 if (!m_emissiveMap)
1927 material->emissiveMap = nullptr;
1928 else
1929 material->emissiveMap = m_emissiveMap->getRenderImage();
1930
1931 material->emissiveColor = m_emissiveFactor;
1932 material->emissiveSingleChannelEnabled = m_emissiveSingleChannelEnabled;
1933 material->emissiveChannel = channelMapping(m_emissiveChannel);
1934 }
1935
1936 if (m_dirtyAttributes & RoughnessDirty) {
1937 if (!m_roughnessMap)
1938 material->roughnessMap = nullptr;
1939 else
1940 material->roughnessMap = m_roughnessMap->getRenderImage();
1941
1942 material->specularRoughness = m_roughness;
1943 material->roughnessChannel = channelMapping(m_roughnessChannel);
1944 }
1945
1946 if (m_dirtyAttributes & MetalnessDirty) {
1947 if (!m_metalnessMap)
1948 material->metalnessMap = nullptr;
1949 else
1950 material->metalnessMap = m_metalnessMap->getRenderImage();
1951
1952 material->metalnessAmount = m_metalnessAmount;
1953 material->metalnessChannel = channelMapping(m_metalnessChannel);
1954
1955 }
1956
1957 if (m_dirtyAttributes & SpecularDirty) {
1958 if (!m_specularReflectionMap)
1959 material->specularReflection = nullptr;
1960 else
1961 material->specularReflection = m_specularReflectionMap->getRenderImage();
1962
1963 if (!m_specularMap) {
1964 material->specularMap = nullptr;
1965 } else {
1966 material->specularMap = m_specularMap->getRenderImage();
1967 }
1968
1969 material->specularAmount = m_specularAmount;
1970 material->specularTint = QVector3D(m_specularTint, m_specularTint, m_specularTint);
1971 material->ior = m_indexOfRefraction;
1972 material->fresnelScaleBiasEnabled = m_fresnelScaleBiasEnabled;
1973 material->fresnelScale = m_fresnelScale;
1974 material->fresnelBias = m_fresnelBias;
1975 material->fresnelPower = m_fresnelPower;
1976 material->specularAmountSingleChannelEnabled = m_specularSingleChannelEnabled;
1977 material->specularAmountChannel = channelMapping(m_specularChannel);
1978 }
1979
1980 if (m_dirtyAttributes & OpacityDirty) {
1981 material->opacity = m_opacity;
1982 if (!m_opacityMap)
1983 material->opacityMap = nullptr;
1984 else
1985 material->opacityMap = m_opacityMap->getRenderImage();
1986
1987 material->invertOpacityMapValue = m_invertOpacityMapValue;
1988 material->opacity = m_opacity;
1989 material->opacityChannel = channelMapping(m_opacityChannel);
1990 }
1991
1992 if (m_dirtyAttributes & NormalDirty) {
1993 if (!m_normalMap)
1994 material->normalMap = nullptr;
1995 else
1996 material->normalMap = m_normalMap->getRenderImage();
1997
1998 material->bumpAmount = m_normalStrength;
1999 }
2000
2001 if (m_dirtyAttributes & OcclusionDirty) {
2002 if (!m_occlusionMap)
2003 material->occlusionMap = nullptr;
2004 else
2005 material->occlusionMap = m_occlusionMap->getRenderImage();
2006 material->occlusionAmount = m_occlusionAmount;
2007 material->occlusionChannel = channelMapping(m_occlusionChannel);
2008 }
2009
2010 if (m_dirtyAttributes & AlphaModeDirty) {
2011 material->alphaMode = QSSGRenderDefaultMaterial::MaterialAlphaMode(m_alphaMode);
2012 material->alphaCutoff = m_alphaCutoff;
2013 }
2014
2015 if (m_dirtyAttributes & PointSizeDirty)
2016 material->pointSize = m_pointSize;
2017
2018 if (m_dirtyAttributes & LineWidthDirty)
2019 material->lineWidth = m_lineWidth;
2020
2021 if (m_dirtyAttributes & HeightDirty) {
2022 if (!m_heightMap)
2023 material->heightMap = nullptr;
2024 else
2025 material->heightMap = m_heightMap->getRenderImage();
2026 material->heightAmount = m_heightAmount;
2027 material->minHeightSamples = m_minHeightMapSamples;
2028 material->maxHeightSamples = m_maxHeightMapSamples;
2029 material->heightChannel = channelMapping(m_heightChannel);
2030 }
2031
2032 if (m_dirtyAttributes & ClearcoatDirty) {
2033 material->clearcoatAmount = m_clearcoatAmount;
2034 if (!m_clearcoatMap)
2035 material->clearcoatMap = nullptr;
2036 else
2037 material->clearcoatMap = m_clearcoatMap->getRenderImage();
2038 material->clearcoatChannel = channelMapping(m_clearcoatChannel);
2039 material->clearcoatRoughnessAmount = m_clearcoatRoughnessAmount;
2040 if (!m_clearcoatRoughnessMap)
2041 material->clearcoatRoughnessMap = nullptr;
2042 else
2043 material->clearcoatRoughnessMap = m_clearcoatRoughnessMap->getRenderImage();
2044 material->clearcoatRoughnessChannel = channelMapping(m_clearcoatRoughnessChannel);
2045 if (!m_clearcoatNormalMap)
2046 material->clearcoatNormalMap = nullptr;
2047 else
2048 material->clearcoatNormalMap = m_clearcoatNormalMap->getRenderImage();
2049 material->clearcoatNormalStrength = m_clearcoatNormalStrength;
2050 material->clearcoatFresnelScaleBiasEnabled = m_clearcoatFresnelScaleBiasEnabled;
2051 material->clearcoatFresnelScale = m_clearcoatFresnelScale;
2052 material->clearcoatFresnelBias = m_clearcoatFresnelBias;
2053 material->clearcoatFresnelPower = m_clearcoatFresnelPower;
2054 }
2055
2056 if (m_dirtyAttributes & SheenDirty) {
2057 material->sheenColor = QSSGUtils::color::sRGBToLinear(m_sheenColor).toVector3D();
2058 if (!m_sheenColorMap)
2059 material->sheenColorMap = nullptr;
2060 else
2061 material->sheenColorMap = m_sheenColorMap->getRenderImage();
2062 material->sheenRoughness = m_sheenRoughness;
2063 if (!m_sheenRoughnessMap)
2064 material->sheenRoughnessMap = nullptr;
2065 else
2066 material->sheenRoughnessMap = m_sheenRoughnessMap->getRenderImage();
2067 material->sheenRoughnessChannel = channelMapping(m_sheenRoughnessChannel);
2068 }
2069
2070 if (m_dirtyAttributes & AnisotropyDirty) {
2071 material->anisotropyStrength = m_anisotropyStrength;
2072 // The shader works in radians; degrees is only the QML facing unit
2073 material->anisotropyRotation = qDegreesToRadians(m_anisotropyRotation);
2074 if (!m_anisotropyMap)
2075 material->anisotropyMap = nullptr;
2076 else
2077 material->anisotropyMap = m_anisotropyMap->getRenderImage();
2078 }
2079
2080 if (m_dirtyAttributes & IridescenceDirty) {
2081 material->iridescenceFactor = m_iridescenceFactor;
2082 if (!m_iridescenceMap)
2083 material->iridescenceMap = nullptr;
2084 else
2085 material->iridescenceMap = m_iridescenceMap->getRenderImage();
2086 material->iridescenceChannel = channelMapping(m_iridescenceChannel);
2087 material->iridescenceIndexOfRefraction = m_iridescenceIndexOfRefraction;
2088 material->iridescenceThicknessMinimum = m_iridescenceThicknessMinimum;
2089 material->iridescenceThicknessMaximum = m_iridescenceThicknessMaximum;
2090 if (!m_iridescenceThicknessMap)
2091 material->iridescenceThicknessMap = nullptr;
2092 else
2093 material->iridescenceThicknessMap = m_iridescenceThicknessMap->getRenderImage();
2094 material->iridescenceThicknessChannel = channelMapping(m_iridescenceThicknessChannel);
2095 }
2096
2097 if (m_dirtyAttributes & DispersionDirty)
2098 material->dispersion = m_dispersion;
2099
2100 if (m_dirtyAttributes & TransmissionDirty) {
2101 material->transmissionFactor = m_transmissionFactor;
2102 if (!m_transmissionMap)
2103 material->transmissionMap = nullptr;
2104 else
2105 material->transmissionMap = m_transmissionMap->getRenderImage();
2106 material->transmissionChannel = channelMapping(m_transmissionChannel);
2107 }
2108
2109 if (m_dirtyAttributes & VolumeDirty) {
2110 material->thicknessFactor = m_thicknessFactor;
2111 if (!m_thicknessMap)
2112 material->thicknessMap = nullptr;
2113 else
2114 material->thicknessMap = m_thicknessMap->getRenderImage();
2115 material->thicknessChannel = channelMapping(m_thicknessChannel);
2116
2117 material->attenuationDistance = m_attenuationDistance;
2118 material->attenuationColor = QSSGUtils::color::sRGBToLinear(m_attenuationColor).toVector3D();
2119 }
2120
2121 if (m_dirtyAttributes & VertexColorsDirty) {
2122 material->vertexColorsEnabled = m_vertexColorsEnabled;
2123 material->vertexColorsMaskEnabled = m_vertexColorsMaskEnabled;
2124 material->vertexColorRedMask = QSSGRenderDefaultMaterial::VertexColorMaskFlags::fromInt(m_vertexColorRedMask);
2125 material->vertexColorGreenMask = QSSGRenderDefaultMaterial::VertexColorMaskFlags::fromInt(m_vertexColorGreenMask);
2126 material->vertexColorBlueMask = QSSGRenderDefaultMaterial::VertexColorMaskFlags::fromInt(m_vertexColorBlueMask);
2127 material->vertexColorAlphaMask = QSSGRenderDefaultMaterial::VertexColorMaskFlags::fromInt(m_vertexColorAlphaMask);
2128 }
2129
2130 m_dirtyAttributes = 0;
2131
2132 return node;
2133}
2134
2135void QQuick3DPrincipledMaterial::itemChange(QQuick3DObject::ItemChange change, const QQuick3DObject::ItemChangeData &value)
2136{
2137 if (change == QQuick3DObject::ItemSceneChange)
2138 updateSceneManager(value.sceneManager);
2139}
2140
2141void QQuick3DPrincipledMaterial::updateSceneManager(QQuick3DSceneManager *sceneManager)
2142{
2143 // Check all the resource value's scene manager, and update as necessary.
2144 if (sceneManager) {
2145 QQuick3DObjectPrivate::refSceneManager(m_baseColorMap, *sceneManager);
2146 QQuick3DObjectPrivate::refSceneManager(m_emissiveMap, *sceneManager);
2147 QQuick3DObjectPrivate::refSceneManager(m_specularReflectionMap, *sceneManager);
2148 QQuick3DObjectPrivate::refSceneManager(m_specularMap, *sceneManager);
2149 QQuick3DObjectPrivate::refSceneManager(m_roughnessMap, *sceneManager);
2150 QQuick3DObjectPrivate::refSceneManager(m_opacityMap, *sceneManager);
2151 QQuick3DObjectPrivate::refSceneManager(m_normalMap, *sceneManager);
2152 QQuick3DObjectPrivate::refSceneManager(m_metalnessMap, *sceneManager);
2153 QQuick3DObjectPrivate::refSceneManager(m_occlusionMap, *sceneManager);
2154 QQuick3DObjectPrivate::refSceneManager(m_heightMap, *sceneManager);
2155 QQuick3DObjectPrivate::refSceneManager(m_clearcoatMap, *sceneManager);
2156 QQuick3DObjectPrivate::refSceneManager(m_clearcoatRoughnessMap, *sceneManager);
2157 QQuick3DObjectPrivate::refSceneManager(m_clearcoatNormalMap, *sceneManager);
2158 QQuick3DObjectPrivate::refSceneManager(m_sheenColorMap, *sceneManager);
2159 QQuick3DObjectPrivate::refSceneManager(m_sheenRoughnessMap, *sceneManager);
2160 QQuick3DObjectPrivate::refSceneManager(m_anisotropyMap, *sceneManager);
2161 QQuick3DObjectPrivate::refSceneManager(m_iridescenceMap, *sceneManager);
2162 QQuick3DObjectPrivate::refSceneManager(m_iridescenceThicknessMap, *sceneManager);
2163 QQuick3DObjectPrivate::refSceneManager(m_transmissionMap, *sceneManager);
2164 QQuick3DObjectPrivate::refSceneManager(m_thicknessMap, *sceneManager);
2165 } else {
2166 QQuick3DObjectPrivate::derefSceneManager(m_baseColorMap);
2167 QQuick3DObjectPrivate::derefSceneManager(m_emissiveMap);
2168 QQuick3DObjectPrivate::derefSceneManager(m_specularReflectionMap);
2169 QQuick3DObjectPrivate::derefSceneManager(m_specularMap);
2170 QQuick3DObjectPrivate::derefSceneManager(m_roughnessMap);
2171 QQuick3DObjectPrivate::derefSceneManager(m_opacityMap);
2172 QQuick3DObjectPrivate::derefSceneManager(m_normalMap);
2173 QQuick3DObjectPrivate::derefSceneManager(m_metalnessMap);
2174 QQuick3DObjectPrivate::derefSceneManager(m_occlusionMap);
2175 QQuick3DObjectPrivate::derefSceneManager(m_heightMap);
2176 QQuick3DObjectPrivate::derefSceneManager(m_clearcoatMap);
2177 QQuick3DObjectPrivate::derefSceneManager(m_clearcoatRoughnessMap);
2178 QQuick3DObjectPrivate::derefSceneManager(m_clearcoatNormalMap);
2179 QQuick3DObjectPrivate::derefSceneManager(m_sheenColorMap);
2180 QQuick3DObjectPrivate::derefSceneManager(m_sheenRoughnessMap);
2181 QQuick3DObjectPrivate::derefSceneManager(m_anisotropyMap);
2182 QQuick3DObjectPrivate::derefSceneManager(m_iridescenceMap);
2183 QQuick3DObjectPrivate::derefSceneManager(m_iridescenceThicknessMap);
2184 QQuick3DObjectPrivate::derefSceneManager(m_transmissionMap);
2185 QQuick3DObjectPrivate::derefSceneManager(m_thicknessMap);
2186 }
2187}
2188
2189void QQuick3DPrincipledMaterial::markDirty(QQuick3DPrincipledMaterial::DirtyType type)
2190{
2191 if (!(m_dirtyAttributes & quint32(type))) {
2192 m_dirtyAttributes |= quint32(type);
2193 update();
2194 }
2195}
2196
2197float QQuick3DPrincipledMaterial::clearcoatAmount() const
2198{
2199 return m_clearcoatAmount;
2200}
2201
2202void QQuick3DPrincipledMaterial::setClearcoatAmount(float newClearcoatAmount)
2203{
2204 if (qFuzzyCompare(m_clearcoatAmount, newClearcoatAmount))
2205 return;
2206 m_clearcoatAmount = newClearcoatAmount;
2207 emit clearcoatAmountChanged(m_clearcoatAmount);
2208 markDirty(ClearcoatDirty);
2209}
2210
2211QQuick3DTexture *QQuick3DPrincipledMaterial::clearcoatMap() const
2212{
2213 return m_clearcoatMap;
2214}
2215
2216void QQuick3DPrincipledMaterial::setClearcoatMap(QQuick3DTexture *newClearcoatMap)
2217{
2218 if (m_clearcoatMap == newClearcoatMap)
2219 return;
2220
2221 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setClearcoatMap, newClearcoatMap, m_clearcoatMap);
2222
2223 m_clearcoatMap = newClearcoatMap;
2224 emit clearcoatMapChanged(m_clearcoatMap);
2225 markDirty(ClearcoatDirty);
2226}
2227
2228QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::clearcoatChannel() const
2229{
2230 return m_clearcoatChannel;
2231}
2232
2233void QQuick3DPrincipledMaterial::setClearcoatChannel(QQuick3DMaterial::TextureChannelMapping newClearcoatChannel)
2234{
2235 if (m_clearcoatChannel == newClearcoatChannel)
2236 return;
2237 m_clearcoatChannel = newClearcoatChannel;
2238 emit clearcoatChannelChanged(m_clearcoatChannel);
2239 markDirty(ClearcoatDirty);
2240}
2241
2242float QQuick3DPrincipledMaterial::clearcoatRoughnessAmount() const
2243{
2244 return m_clearcoatRoughnessAmount;
2245}
2246
2247void QQuick3DPrincipledMaterial::setClearcoatRoughnessAmount(float newClearcoatRoughnessAmount)
2248{
2249 if (qFuzzyCompare(m_clearcoatRoughnessAmount, newClearcoatRoughnessAmount))
2250 return;
2251 m_clearcoatRoughnessAmount = newClearcoatRoughnessAmount;
2252 emit clearcoatRoughnessAmountChanged(m_clearcoatRoughnessAmount);
2253 markDirty(ClearcoatDirty);
2254}
2255
2256QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::clearcoatRoughnessChannel() const
2257{
2258 return m_clearcoatRoughnessChannel;
2259}
2260
2261void QQuick3DPrincipledMaterial::setClearcoatRoughnessChannel(QQuick3DMaterial::TextureChannelMapping newClearcoatRoughnessChannel)
2262{
2263 if (m_clearcoatRoughnessChannel == newClearcoatRoughnessChannel)
2264 return;
2265 m_clearcoatRoughnessChannel = newClearcoatRoughnessChannel;
2266 emit clearcoatRoughnessChannelChanged(m_clearcoatRoughnessChannel);
2267 markDirty(ClearcoatDirty);
2268}
2269
2270QQuick3DTexture *QQuick3DPrincipledMaterial::clearcoatRoughnessMap() const
2271{
2272 return m_clearcoatRoughnessMap;
2273}
2274
2275void QQuick3DPrincipledMaterial::setClearcoatRoughnessMap(QQuick3DTexture *newClearcoatRoughnessMap)
2276{
2277 if (m_clearcoatRoughnessMap == newClearcoatRoughnessMap)
2278 return;
2279
2280 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setClearcoatRoughnessMap, newClearcoatRoughnessMap, m_clearcoatRoughnessMap);
2281
2282 m_clearcoatRoughnessMap = newClearcoatRoughnessMap;
2283 emit clearcoatRoughnessMapChanged(m_clearcoatRoughnessMap);
2284 markDirty(ClearcoatDirty);
2285}
2286
2287QQuick3DTexture *QQuick3DPrincipledMaterial::clearcoatNormalMap() const
2288{
2289 return m_clearcoatNormalMap;
2290}
2291
2292void QQuick3DPrincipledMaterial::setClearcoatNormalMap(QQuick3DTexture *newClearcoatNormalMap)
2293{
2294 if (m_clearcoatNormalMap == newClearcoatNormalMap)
2295 return;
2296
2297 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setClearcoatNormalMap, newClearcoatNormalMap, m_clearcoatNormalMap);
2298
2299 m_clearcoatNormalMap = newClearcoatNormalMap;
2300 emit clearcoatNormalMapChanged(m_clearcoatNormalMap);
2301 markDirty(ClearcoatDirty);
2302}
2303
2304
2305float QQuick3DPrincipledMaterial::clearcoatNormalStrength() const
2306{
2307 return m_clearcoatNormalStrength;
2308}
2309
2310void QQuick3DPrincipledMaterial::setClearcoatNormalStrength(float newClearcoatNormalStrength)
2311{
2312 if (qFuzzyCompare(m_clearcoatNormalStrength, newClearcoatNormalStrength))
2313 return;
2314
2315 m_clearcoatNormalStrength = newClearcoatNormalStrength;
2316 emit clearcoatNormalStrengthChanged(m_clearcoatNormalStrength);
2317 markDirty(ClearcoatDirty);
2318}
2319
2320const QColor &QQuick3DPrincipledMaterial::sheenColor() const
2321{
2322 return m_sheenColor;
2323}
2324
2325void QQuick3DPrincipledMaterial::setSheenColor(const QColor &newSheenColor)
2326{
2327 if (m_sheenColor == newSheenColor)
2328 return;
2329
2330 m_sheenColor = newSheenColor;
2331 emit sheenColorChanged(m_sheenColor);
2332 markDirty(SheenDirty);
2333}
2334
2335QQuick3DTexture *QQuick3DPrincipledMaterial::sheenColorMap() const
2336{
2337 return m_sheenColorMap;
2338}
2339
2340void QQuick3DPrincipledMaterial::setSheenColorMap(QQuick3DTexture *newSheenColorMap)
2341{
2342 if (m_sheenColorMap == newSheenColorMap)
2343 return;
2344
2345 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setSheenColorMap, newSheenColorMap, m_sheenColorMap);
2346
2347 m_sheenColorMap = newSheenColorMap;
2348 emit sheenColorMapChanged(m_sheenColorMap);
2349 markDirty(SheenDirty);
2350}
2351
2352float QQuick3DPrincipledMaterial::sheenRoughness() const
2353{
2354 return m_sheenRoughness;
2355}
2356
2357void QQuick3DPrincipledMaterial::setSheenRoughness(float newSheenRoughness)
2358{
2359 newSheenRoughness = ensureNormalized(newSheenRoughness);
2360 if (qFuzzyCompare(m_sheenRoughness, newSheenRoughness))
2361 return;
2362
2363 m_sheenRoughness = newSheenRoughness;
2364 emit sheenRoughnessChanged(m_sheenRoughness);
2365 markDirty(SheenDirty);
2366}
2367
2368QQuick3DTexture *QQuick3DPrincipledMaterial::sheenRoughnessMap() const
2369{
2370 return m_sheenRoughnessMap;
2371}
2372
2373void QQuick3DPrincipledMaterial::setSheenRoughnessMap(QQuick3DTexture *newSheenRoughnessMap)
2374{
2375 if (m_sheenRoughnessMap == newSheenRoughnessMap)
2376 return;
2377
2378 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setSheenRoughnessMap, newSheenRoughnessMap, m_sheenRoughnessMap);
2379
2380 m_sheenRoughnessMap = newSheenRoughnessMap;
2381 emit sheenRoughnessMapChanged(m_sheenRoughnessMap);
2382 markDirty(SheenDirty);
2383}
2384
2385QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::sheenRoughnessChannel() const
2386{
2387 return m_sheenRoughnessChannel;
2388}
2389
2390void QQuick3DPrincipledMaterial::setSheenRoughnessChannel(QQuick3DMaterial::TextureChannelMapping newSheenRoughnessChannel)
2391{
2392 if (m_sheenRoughnessChannel == newSheenRoughnessChannel)
2393 return;
2394
2395 m_sheenRoughnessChannel = newSheenRoughnessChannel;
2396 emit sheenRoughnessChannelChanged(m_sheenRoughnessChannel);
2397 markDirty(SheenDirty);
2398}
2399
2400float QQuick3DPrincipledMaterial::anisotropyStrength() const
2401{
2402 return m_anisotropyStrength;
2403}
2404
2405void QQuick3DPrincipledMaterial::setAnisotropyStrength(float newAnisotropyStrength)
2406{
2407 newAnisotropyStrength = ensureNormalized(newAnisotropyStrength);
2408 if (qFuzzyCompare(m_anisotropyStrength, newAnisotropyStrength))
2409 return;
2410
2411 m_anisotropyStrength = newAnisotropyStrength;
2412 emit anisotropyStrengthChanged(m_anisotropyStrength);
2413 markDirty(AnisotropyDirty);
2414}
2415
2416float QQuick3DPrincipledMaterial::anisotropyRotation() const
2417{
2418 return m_anisotropyRotation;
2419}
2420
2421void QQuick3DPrincipledMaterial::setAnisotropyRotation(float newAnisotropyRotation)
2422{
2423 if (qFuzzyCompare(m_anisotropyRotation, newAnisotropyRotation))
2424 return;
2425
2426 // Not clamped: the rotation is periodic, so any angle is meaningful
2427 m_anisotropyRotation = newAnisotropyRotation;
2428 emit anisotropyRotationChanged(m_anisotropyRotation);
2429 markDirty(AnisotropyDirty);
2430}
2431
2432QQuick3DTexture *QQuick3DPrincipledMaterial::anisotropyMap() const
2433{
2434 return m_anisotropyMap;
2435}
2436
2437void QQuick3DPrincipledMaterial::setAnisotropyMap(QQuick3DTexture *newAnisotropyMap)
2438{
2439 if (m_anisotropyMap == newAnisotropyMap)
2440 return;
2441
2442 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setAnisotropyMap, newAnisotropyMap, m_anisotropyMap);
2443
2444 m_anisotropyMap = newAnisotropyMap;
2445 emit anisotropyMapChanged(m_anisotropyMap);
2446 markDirty(AnisotropyDirty);
2447}
2448
2449float QQuick3DPrincipledMaterial::iridescenceFactor() const
2450{
2451 return m_iridescenceFactor;
2452}
2453
2454void QQuick3DPrincipledMaterial::setIridescenceFactor(float newIridescenceFactor)
2455{
2456 newIridescenceFactor = ensureNormalized(newIridescenceFactor);
2457 if (qFuzzyCompare(m_iridescenceFactor, newIridescenceFactor))
2458 return;
2459
2460 m_iridescenceFactor = newIridescenceFactor;
2461 emit iridescenceFactorChanged(m_iridescenceFactor);
2462 markDirty(IridescenceDirty);
2463}
2464
2465QQuick3DTexture *QQuick3DPrincipledMaterial::iridescenceMap() const
2466{
2467 return m_iridescenceMap;
2468}
2469
2470void QQuick3DPrincipledMaterial::setIridescenceMap(QQuick3DTexture *newIridescenceMap)
2471{
2472 if (m_iridescenceMap == newIridescenceMap)
2473 return;
2474
2475 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setIridescenceMap, newIridescenceMap, m_iridescenceMap);
2476
2477 m_iridescenceMap = newIridescenceMap;
2478 emit iridescenceMapChanged(m_iridescenceMap);
2479 markDirty(IridescenceDirty);
2480}
2481
2482QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::iridescenceChannel() const
2483{
2484 return m_iridescenceChannel;
2485}
2486
2487void QQuick3DPrincipledMaterial::setIridescenceChannel(QQuick3DMaterial::TextureChannelMapping newIridescenceChannel)
2488{
2489 if (m_iridescenceChannel == newIridescenceChannel)
2490 return;
2491
2492 m_iridescenceChannel = newIridescenceChannel;
2493 emit iridescenceChannelChanged(m_iridescenceChannel);
2494 markDirty(IridescenceDirty);
2495}
2496
2497float QQuick3DPrincipledMaterial::iridescenceIndexOfRefraction() const
2498{
2499 return m_iridescenceIndexOfRefraction;
2500}
2501
2502void QQuick3DPrincipledMaterial::setIridescenceIndexOfRefraction(float newIridescenceIndexOfRefraction)
2503{
2504 if (qFuzzyCompare(m_iridescenceIndexOfRefraction, newIridescenceIndexOfRefraction))
2505 return;
2506
2507 m_iridescenceIndexOfRefraction = newIridescenceIndexOfRefraction;
2508 emit iridescenceIndexOfRefractionChanged(m_iridescenceIndexOfRefraction);
2509 markDirty(IridescenceDirty);
2510}
2511
2512float QQuick3DPrincipledMaterial::iridescenceThicknessMinimum() const
2513{
2514 return m_iridescenceThicknessMinimum;
2515}
2516
2517void QQuick3DPrincipledMaterial::setIridescenceThicknessMinimum(float newIridescenceThicknessMinimum)
2518{
2519 if (qFuzzyCompare(m_iridescenceThicknessMinimum, newIridescenceThicknessMinimum))
2520 return;
2521
2522 m_iridescenceThicknessMinimum = newIridescenceThicknessMinimum;
2523 emit iridescenceThicknessMinimumChanged(m_iridescenceThicknessMinimum);
2524 markDirty(IridescenceDirty);
2525}
2526
2527float QQuick3DPrincipledMaterial::iridescenceThicknessMaximum() const
2528{
2529 return m_iridescenceThicknessMaximum;
2530}
2531
2532void QQuick3DPrincipledMaterial::setIridescenceThicknessMaximum(float newIridescenceThicknessMaximum)
2533{
2534 if (qFuzzyCompare(m_iridescenceThicknessMaximum, newIridescenceThicknessMaximum))
2535 return;
2536
2537 m_iridescenceThicknessMaximum = newIridescenceThicknessMaximum;
2538 emit iridescenceThicknessMaximumChanged(m_iridescenceThicknessMaximum);
2539 markDirty(IridescenceDirty);
2540}
2541
2542QQuick3DTexture *QQuick3DPrincipledMaterial::iridescenceThicknessMap() const
2543{
2544 return m_iridescenceThicknessMap;
2545}
2546
2547void QQuick3DPrincipledMaterial::setIridescenceThicknessMap(QQuick3DTexture *newIridescenceThicknessMap)
2548{
2549 if (m_iridescenceThicknessMap == newIridescenceThicknessMap)
2550 return;
2551
2552 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setIridescenceThicknessMap, newIridescenceThicknessMap, m_iridescenceThicknessMap);
2553
2554 m_iridescenceThicknessMap = newIridescenceThicknessMap;
2555 emit iridescenceThicknessMapChanged(m_iridescenceThicknessMap);
2556 markDirty(IridescenceDirty);
2557}
2558
2559QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::iridescenceThicknessChannel() const
2560{
2561 return m_iridescenceThicknessChannel;
2562}
2563
2564void QQuick3DPrincipledMaterial::setIridescenceThicknessChannel(QQuick3DMaterial::TextureChannelMapping newIridescenceThicknessChannel)
2565{
2566 if (m_iridescenceThicknessChannel == newIridescenceThicknessChannel)
2567 return;
2568
2569 m_iridescenceThicknessChannel = newIridescenceThicknessChannel;
2570 emit iridescenceThicknessChannelChanged(m_iridescenceThicknessChannel);
2571 markDirty(IridescenceDirty);
2572}
2573
2574float QQuick3DPrincipledMaterial::dispersion() const
2575{
2576 return m_dispersion;
2577}
2578
2579void QQuick3DPrincipledMaterial::setDispersion(float newDispersion)
2580{
2581 // 20 / Abbe number, which has no upper bound
2582 newDispersion = qMax(0.0f, newDispersion);
2583 if (qFuzzyCompare(m_dispersion, newDispersion))
2584 return;
2585
2586 m_dispersion = newDispersion;
2587 emit dispersionChanged(m_dispersion);
2588 markDirty(DispersionDirty);
2589}
2590
2591float QQuick3DPrincipledMaterial::transmissionFactor() const
2592{
2593 return m_transmissionFactor;
2594}
2595
2596void QQuick3DPrincipledMaterial::setTransmissionFactor(float newTransmissionFactor)
2597{
2598 if (qFuzzyCompare(m_transmissionFactor, newTransmissionFactor))
2599 return;
2600 m_transmissionFactor = newTransmissionFactor;
2601 emit transmissionFactorChanged(m_transmissionFactor);
2602 markDirty(TransmissionDirty);
2603}
2604
2605QQuick3DTexture *QQuick3DPrincipledMaterial::transmissionMap() const
2606{
2607 return m_transmissionMap;
2608}
2609
2610void QQuick3DPrincipledMaterial::setTransmissionMap(QQuick3DTexture *newTransmissionMap)
2611{
2612 if (m_transmissionMap == newTransmissionMap)
2613 return;
2614
2615 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setTransmissionMap, newTransmissionMap, m_transmissionMap);
2616
2617 m_transmissionMap = newTransmissionMap;
2618 emit transmissionMapChanged(m_transmissionMap);
2619 markDirty(TransmissionDirty);
2620}
2621
2622QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::transmissionChannel() const
2623{
2624 return m_transmissionChannel;
2625}
2626
2627float QQuick3DPrincipledMaterial::indexOfRefraction() const
2628{
2629 return m_indexOfRefraction;
2630}
2631
2632bool QQuick3DPrincipledMaterial::fresnelScaleBiasEnabled() const
2633{
2634 return m_fresnelScaleBiasEnabled;
2635}
2636
2637float QQuick3DPrincipledMaterial::fresnelScale() const
2638{
2639 return m_fresnelScale;
2640}
2641
2642float QQuick3DPrincipledMaterial::fresnelBias() const
2643{
2644 return m_fresnelBias;
2645}
2646
2647float QQuick3DPrincipledMaterial::fresnelPower() const
2648{
2649 return m_fresnelPower;
2650}
2651
2652bool QQuick3DPrincipledMaterial::clearcoatFresnelScaleBiasEnabled() const
2653{
2654 return m_clearcoatFresnelScaleBiasEnabled;
2655}
2656
2657float QQuick3DPrincipledMaterial::clearcoatFresnelScale() const
2658{
2659 return m_clearcoatFresnelScale;
2660}
2661
2662float QQuick3DPrincipledMaterial::clearcoatFresnelBias() const
2663{
2664 return m_clearcoatFresnelBias;
2665}
2666
2667float QQuick3DPrincipledMaterial::clearcoatFresnelPower() const
2668{
2669 return m_clearcoatFresnelPower;
2670}
2671
2672bool QQuick3DPrincipledMaterial::vertexColorsEnabled() const
2673{
2674 return m_vertexColorsEnabled;
2675}
2676
2677void QQuick3DPrincipledMaterial::setTransmissionChannel(QQuick3DMaterial::TextureChannelMapping newTransmissionChannel)
2678{
2679 if (m_transmissionChannel == newTransmissionChannel)
2680 return;
2681 m_transmissionChannel = newTransmissionChannel;
2682 emit transmissionChannelChanged(m_transmissionChannel);
2683 markDirty(TransmissionDirty);
2684}
2685
2686float QQuick3DPrincipledMaterial::thicknessFactor() const
2687{
2688 return m_thicknessFactor;
2689}
2690
2691void QQuick3DPrincipledMaterial::setThicknessFactor(float newThicknessFactor)
2692{
2693 if (qFuzzyCompare(m_thicknessFactor, newThicknessFactor))
2694 return;
2695 m_thicknessFactor = newThicknessFactor;
2696 emit thicknessFactorChanged(m_thicknessFactor);
2697 markDirty(VolumeDirty);
2698}
2699
2700QQuick3DTexture *QQuick3DPrincipledMaterial::thicknessMap() const
2701{
2702 return m_thicknessMap;
2703}
2704
2705void QQuick3DPrincipledMaterial::setThicknessMap(QQuick3DTexture *newThicknessMap)
2706{
2707 if (m_thicknessMap == newThicknessMap)
2708 return;
2709
2710 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setThicknessMap, newThicknessMap, m_thicknessMap);
2711
2712 m_thicknessMap = newThicknessMap;
2713 emit thicknessMapChanged(m_thicknessMap);
2714 markDirty(VolumeDirty);
2715}
2716
2717const QQuick3DMaterial::TextureChannelMapping &QQuick3DPrincipledMaterial::thicknessChannel() const
2718{
2719 return m_thicknessChannel;
2720}
2721
2722void QQuick3DPrincipledMaterial::setThicknessChannel(const QQuick3DMaterial::TextureChannelMapping &newThicknessChannel)
2723{
2724 if (m_thicknessChannel == newThicknessChannel)
2725 return;
2726 m_thicknessChannel = newThicknessChannel;
2727 emit thicknessChannelChanged(m_thicknessChannel);
2728 markDirty(VolumeDirty);
2729}
2730
2731float QQuick3DPrincipledMaterial::attenuationDistance() const
2732{
2733 return m_attenuationDistance;
2734}
2735
2736void QQuick3DPrincipledMaterial::setAttenuationDistance(float newAttenuationDistance)
2737{
2738 if (qFuzzyCompare(m_attenuationDistance, newAttenuationDistance))
2739 return;
2740 m_attenuationDistance = newAttenuationDistance;
2741 emit attenuationDistanceChanged(m_attenuationDistance);
2742 markDirty(VolumeDirty);
2743}
2744
2745const QColor &QQuick3DPrincipledMaterial::attenuationColor() const
2746{
2747 return m_attenuationColor;
2748}
2749
2750void QQuick3DPrincipledMaterial::setAttenuationColor(const QColor &newAttenuationColor)
2751{
2752 if (m_attenuationColor == newAttenuationColor)
2753 return;
2754 m_attenuationColor = newAttenuationColor;
2755 emit attenuationColorChanged(m_attenuationColor);
2756 markDirty(VolumeDirty);
2757}
2758
2759void QQuick3DPrincipledMaterial::setIndexOfRefraction(float indexOfRefraction)
2760{
2761 if (qFuzzyCompare(m_indexOfRefraction, indexOfRefraction))
2762 return;
2763
2764 m_indexOfRefraction = indexOfRefraction;
2765 emit indexOfRefractionChanged(m_indexOfRefraction);
2766 markDirty(SpecularDirty);
2767}
2768
2769void QQuick3DPrincipledMaterial::setFresnelScaleBiasEnabled(bool fresnelScaleBiasEnabled)
2770{
2771 if (m_fresnelScaleBiasEnabled == fresnelScaleBiasEnabled)
2772 return;
2773
2774 m_fresnelScaleBiasEnabled = fresnelScaleBiasEnabled;
2775 emit fresnelScaleBiasEnabledChanged(m_fresnelScaleBiasEnabled);
2776 markDirty(SpecularDirty);
2777}
2778
2779void QQuick3DPrincipledMaterial::setFresnelScale(float fresnelScale)
2780{
2781 if (qFuzzyCompare(m_fresnelScale, fresnelScale))
2782 return;
2783
2784 m_fresnelScale = fresnelScale;
2785 emit fresnelScaleChanged(m_fresnelScale);
2786 markDirty(SpecularDirty);
2787}
2788
2789void QQuick3DPrincipledMaterial::setFresnelBias(float fresnelBias)
2790{
2791 if (qFuzzyCompare(m_fresnelBias, fresnelBias))
2792 return;
2793
2794 m_fresnelBias = fresnelBias;
2795 emit fresnelBiasChanged(m_fresnelBias);
2796 markDirty(SpecularDirty);
2797}
2798
2799void QQuick3DPrincipledMaterial::setFresnelPower(float fresnelPower)
2800{
2801 if (qFuzzyCompare(m_fresnelPower, fresnelPower))
2802 return;
2803
2804 m_fresnelPower = fresnelPower;
2805 emit fresnelPowerChanged(m_fresnelPower);
2806 markDirty(SpecularDirty);
2807}
2808
2809void QQuick3DPrincipledMaterial::setClearcoatFresnelScaleBiasEnabled(bool clearcoatFresnelScaleBiasEnabled)
2810{
2811 if (m_clearcoatFresnelScaleBiasEnabled == clearcoatFresnelScaleBiasEnabled)
2812 return;
2813
2814 m_clearcoatFresnelScaleBiasEnabled = clearcoatFresnelScaleBiasEnabled;
2815 emit clearcoatFresnelScaleBiasEnabledChanged(m_clearcoatFresnelScaleBiasEnabled);
2816 markDirty(ClearcoatDirty);
2817}
2818
2819void QQuick3DPrincipledMaterial::setClearcoatFresnelScale(float clearcoatFresnelScale)
2820{
2821 if (qFuzzyCompare(m_clearcoatFresnelScale, clearcoatFresnelScale))
2822 return;
2823
2824 m_clearcoatFresnelScale = clearcoatFresnelScale;
2825 emit clearcoatFresnelScaleChanged(m_clearcoatFresnelScale);
2826 markDirty(ClearcoatDirty);
2827}
2828
2829void QQuick3DPrincipledMaterial::setClearcoatFresnelBias(float clearcoatFresnelBias)
2830{
2831 if (qFuzzyCompare(m_clearcoatFresnelBias, clearcoatFresnelBias))
2832 return;
2833
2834 m_clearcoatFresnelBias = clearcoatFresnelBias;
2835 emit clearcoatFresnelBiasChanged(m_clearcoatFresnelBias);
2836 markDirty(ClearcoatDirty);
2837}
2838
2839void QQuick3DPrincipledMaterial::setClearcoatFresnelPower(float clearcoatFresnelPower)
2840{
2841 if (qFuzzyCompare(m_clearcoatFresnelPower, clearcoatFresnelPower))
2842 return;
2843
2844 m_clearcoatFresnelPower = clearcoatFresnelPower;
2845 emit clearcoatFresnelPowerChanged(m_clearcoatFresnelPower);
2846 markDirty(ClearcoatDirty);
2847}
2848
2849void QQuick3DPrincipledMaterial::setVertexColorsEnabled(bool vertexColors)
2850{
2851 if (m_vertexColorsEnabled == vertexColors)
2852 return;
2853
2854 m_vertexColorsEnabled = vertexColors;
2855 emit vertexColorsEnabledChanged(m_vertexColorsEnabled);
2856 markDirty(VertexColorsDirty);
2857}
2858
2859bool QQuick3DPrincipledMaterial::vertexColorsMaskEnabled() const
2860{
2861 return m_vertexColorsMaskEnabled;
2862}
2863
2864void QQuick3DPrincipledMaterial::setVertexColorsMaskEnabled(bool vertexColorsMaskEnabled)
2865{
2866 if (m_vertexColorsMaskEnabled == vertexColorsMaskEnabled)
2867 return;
2868 m_vertexColorsMaskEnabled = vertexColorsMaskEnabled;
2869 emit vertexColorsMaskEnabledChanged();
2870 markDirty(VertexColorsDirty);
2871}
2872
2873QQuick3DPrincipledMaterial::VertexColorMaskFlags QQuick3DPrincipledMaterial::vertexColorRedMask() const
2874{
2875 return m_vertexColorRedMask;
2876}
2877
2878void QQuick3DPrincipledMaterial::setVertexColorRedMask(QQuick3DPrincipledMaterial::VertexColorMaskFlags vertexColorRedMask)
2879{
2880 if (m_vertexColorRedMask == vertexColorRedMask)
2881 return;
2882 m_vertexColorRedMask = vertexColorRedMask;
2883 emit vertexColorRedMaskChanged();
2884 markDirty(VertexColorsDirty);
2885}
2886
2887QQuick3DPrincipledMaterial::VertexColorMaskFlags QQuick3DPrincipledMaterial::vertexColorGreenMask() const
2888{
2889 return m_vertexColorGreenMask;
2890}
2891
2892void QQuick3DPrincipledMaterial::setVertexColorGreenMask(QQuick3DPrincipledMaterial::VertexColorMaskFlags vertexColorGreenMask)
2893{
2894 if (m_vertexColorGreenMask == vertexColorGreenMask)
2895 return;
2896 m_vertexColorGreenMask = vertexColorGreenMask;
2897 emit vertexColorGreenMaskChanged();
2898 markDirty(VertexColorsDirty);
2899}
2900
2901QQuick3DPrincipledMaterial::VertexColorMaskFlags QQuick3DPrincipledMaterial::vertexColorBlueMask() const
2902{
2903 return m_vertexColorBlueMask;
2904}
2905
2906void QQuick3DPrincipledMaterial::setVertexColorBlueMask(QQuick3DPrincipledMaterial::VertexColorMaskFlags vertexColorBlueMask)
2907{
2908 if (m_vertexColorBlueMask == vertexColorBlueMask)
2909 return;
2910 m_vertexColorBlueMask = vertexColorBlueMask;
2911 emit vertexColorBlueMaskChanged();
2912 markDirty(VertexColorsDirty);
2913}
2914
2915QQuick3DPrincipledMaterial::VertexColorMaskFlags QQuick3DPrincipledMaterial::vertexColorAlphaMask() const
2916{
2917 return m_vertexColorAlphaMask;
2918}
2919
2920void QQuick3DPrincipledMaterial::setVertexColorAlphaMask(QQuick3DPrincipledMaterial::VertexColorMaskFlags vertexColorAlphaMask)
2921{
2922 if (m_vertexColorAlphaMask == vertexColorAlphaMask)
2923 return;
2924 m_vertexColorAlphaMask = vertexColorAlphaMask;
2925 emit vertexColorAlphaMaskChanged();
2926 markDirty(VertexColorsDirty);
2927}
2928
2929QT_END_NAMESPACE
Combined button and popup list for selecting options.