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 real PrincipledMaterial::transmissionFactor
675
676 This property defines the percentage of light that is transmitted through
677 the material's surface.
678 The default value is \c 0.0
679*/
680
681/*!
682 \qmlproperty Texture PrincipledMaterial::transmissionMap
683
684 This property defines a texture used to determine percentage of light that
685 is transmitted through the surface.. The value of
686 \l transmissionFactor will be multiplied by the value read from this
687 texture.
688
689*/
690
691/*!
692 \qmlproperty enumeration PrincipledMaterial::transmissionChannel
693
694 This property defines the texture channel used to read the transmission
695 percentage from \l transmissionMap.
696 The default value is \c Material.R.
697
698 \value Material.R Read value from texture R channel.
699 \value Material.G Read value from texture G channel.
700 \value Material.B Read value from texture B channel.
701 \value Material.A Read value from texture A channel.
702
703*/
704
705/*!
706 \qmlproperty real PrincipledMaterial::thicknessFactor
707
708 This property defines the thickness of the volume beneath the surface.
709 Unlike many other properties of PrincipledMaterial, the value in defined
710 in thicknessFactor is a value from 0.0 to +infinity for thickness in the
711 models coordinate space. A value of 0.0 means that the material is
712 thin-walled.
713 The default value is \c 0.0
714*/
715
716/*!
717 \qmlproperty Texture PrincipledMaterial::thicknessMap
718
719 This property defines a texture used to define the thickness of a
720 material volume. The value of \l thicknessFactor will be multiplied by the
721 value read from this texture.
722
723*/
724
725/*!
726 \qmlproperty enumeration PrincipledMaterial::thicknessChannel
727
728 This property defines the texture channel used to read the thickness
729 amount from \l transmissionMap.
730 The default value is \c Material.G.
731
732 \value Material.R Read value from texture R channel.
733 \value Material.G Read value from texture G channel.
734 \value Material.B Read value from texture B channel.
735 \value Material.A Read value from texture A channel.
736
737*/
738
739/*!
740 \qmlproperty real PrincipledMaterial::attenuationDistance
741
742 This property defines the Density of the medium given as the average
743 distance that light travels in the medium before interacting with a
744 particle. The value is given in world space.
745 The default value is \c +infinity.
746*/
747
748/*!
749 \qmlproperty color PrincipledMaterial::attenuationColor
750
751 This property defines the color that white lights turns into due to
752 absorption when reaching the attenuation distance.
753 The default value is \c Qt.White
754
755*/
756
757/*!
758 \qmlproperty real PrincipledMaterial::indexOfRefraction
759
760 This property defines the index of refraction of the material. The default
761 value of \c 1.5 will be the ideal value for materials like plastics or glass
762 but other materials like water, asphalt, sapphire, or diamond would require
763 and adjusted value to look more realistic. For realistic materials the
764 indexOfRefraction should usually be between \c 1.0 and \c 3.0
765
766 Some examples of common materials' index of refractions are:
767
768 \table
769 \header
770 \li Material
771 \li Index of Refraction
772 \row
773 \li Air
774 \li 1.0
775 \row
776 \li Water
777 \li 1.33
778 \row
779 \li Glass
780 \li 1.55
781 \row
782 \li Sapphire
783 \li 1.76
784 \row
785 \li Diamond
786 \li 2.42
787 \endtable
788
789 \note No known material in the world have ior much greater than \c 3.0.
790*/
791
792/*!
793 \qmlproperty real PrincipledMaterial::fresnelScaleBiasEnabled
794
795 By Setting the value to true the material will take Fresnel Scale and Fresnel Bias into account.
796 The default value is \c false.
797*/
798
799/*!
800 \qmlproperty real PrincipledMaterial::fresnelScale
801
802 This property scale head-on reflections (looking directly at the
803 surface) while maintaining reflections seen at grazing angles.
804 In order to affect changes to the material you have to enable fresnelScaleBiasEnabled.
805 The default value is \c 1.0.
806*/
807
808/*!
809 \qmlproperty real PrincipledMaterial::fresnelBias
810
811 This property push forward head-on reflections (looking directly at the
812 surface) while maintaining reflections seen at grazing angles.
813 In order to affect changes to the material you have to enable fresnelScaleBiasEnabled.
814 The default value is \c 0.0.
815*/
816
817/*!
818 \qmlproperty real PrincipledMaterial::fresnelPower
819
820 This property decreases head-on reflections (looking directly at the
821 surface) while maintaining reflections seen at grazing angles.
822 The default value is \c 5.0.
823*/
824
825/*!
826 \qmlproperty real PrincipledMaterial::clearcoatFresnelScaleBiasEnabled
827
828 By Setting the value to true the material will take Clearcoat Fresnel Scale and Clearcoat Fresnel Bias into account.
829 The default value is \c false.
830*/
831
832/*!
833 \qmlproperty real PrincipledMaterial::clearcoatFresnelScale
834
835 This property scale head-on reflections (looking directly at the
836 surface) while maintaining reflections seen at grazing angles.
837 In order to affect changes to the material you have to enable clearcoatFresnelScaleBiasEnabled.
838 The default value is \c 1.0.
839*/
840
841/*!
842 \qmlproperty real PrincipledMaterial::clearcoatFresnelBias
843
844 This property push forward head-on reflections (looking directly at the
845 surface) while maintaining reflections seen at grazing angles.
846 In order to affect changes to the material you have to enable clearcoatFresnelScaleBiasEnabled.
847 The default value is \c 0.0.
848*/
849
850/*!
851 \qmlproperty real PrincipledMaterial::clearcoatFresnelPower
852
853 This property decreases head-on reflections (looking directly at the
854 surface) while maintaining reflections seen at grazing angles.
855 The default value is \c 5.0.
856*/
857
858/*!
859 \qmlproperty bool PrincipledMaterial::vertexColorsEnabled
860 \since 6.5
861
862 When this property is enabled, the material will use vertex colors from the
863 mesh. These will be multiplied by any other colors specified for the
864 material. The default value is true.
865*/
866
867/*!
868 \qmlproperty bool PrincipledMaterial::vertexColorsMaskEnabled
869 \since 6.8
870
871 When this property is enabled, the material will use vertex colors from the
872 mesh as mask of various properties e.g RoughnessAmount, SpecularAmount, ... .
873 The default value is false.
874*/
875
876/*!
877 \qmlproperty enumeration PrincipledMaterial::vertexColorRedMask
878 \since 6.8
879
880 This property defines the vertex color red channel used as the specifies mask.
881 The value is a bit-wise combination of flags.
882 The default value is \c PrincipledMaterial.NoMask.
883
884 \value PrincipledMaterial.NoMask.
885 \value PrincipledMaterial.ClearcoatAmountMask.
886 \value PrincipledMaterial.ClearcoatRoughnessAmountMask.
887 \value PrincipledMaterial.ClearcoatNormalStrengthMask.
888 \value PrincipledMaterial.HeightAmountMask.
889 \value PrincipledMaterial.MetalnessMask.
890 \value PrincipledMaterial.RoughnessMask.
891 \value PrincipledMaterial.NormalStrengthMask.
892 \value PrincipledMaterial.OcclusionAmountMask.
893 \value PrincipledMaterial.SpecularAmountMask.
894 \value PrincipledMaterial.ThicknessFactorMask.
895 \value PrincipledMaterial.TransmissionFactorMask.
896 */
897
898/*!
899 \qmlproperty enumeration PrincipledMaterial::vertexColorGreenMask
900 \since 6.8
901
902 This property defines the vertex color green channel used as the specifies mask.
903 The value is a bit-wise combination of flags.
904 The default value is \c PrincipledMaterial.NoMask.
905
906 \value PrincipledMaterial.NoMask.
907 \value PrincipledMaterial.ClearcoatAmountMask.
908 \value PrincipledMaterial.ClearcoatRoughnessAmountMask.
909 \value PrincipledMaterial.ClearcoatNormalStrengthMask.
910 \value PrincipledMaterial.HeightAmountMask.
911 \value PrincipledMaterial.MetalnessMask.
912 \value PrincipledMaterial.RoughnessMask.
913 \value PrincipledMaterial.NormalStrengthMask.
914 \value PrincipledMaterial.OcclusionAmountMask.
915 \value PrincipledMaterial.SpecularAmountMask.
916 \value PrincipledMaterial.ThicknessFactorMask.
917 \value PrincipledMaterial.TransmissionFactorMask.
918*/
919
920/*!
921 \qmlproperty enumeration PrincipledMaterial::vertexColorBlueMask
922 \since 6.8
923
924 This property defines the vertex color blue channel used as the specifies mask.
925 The value is a bit-wise combination of flags.
926 The default value is \c PrincipledMaterial.NoMask.
927
928 \value PrincipledMaterial.NoMask.
929 \value PrincipledMaterial.ClearcoatAmountMask.
930 \value PrincipledMaterial.ClearcoatRoughnessAmountMask.
931 \value PrincipledMaterial.ClearcoatNormalStrengthMask.
932 \value PrincipledMaterial.HeightAmountMask.
933 \value PrincipledMaterial.MetalnessMask.
934 \value PrincipledMaterial.RoughnessMask.
935 \value PrincipledMaterial.NormalStrengthMask.
936 \value PrincipledMaterial.OcclusionAmountMask.
937 \value PrincipledMaterial.SpecularAmountMask.
938 \value PrincipledMaterial.ThicknessFactorMask.
939 \value PrincipledMaterial.TransmissionFactorMask.
940*/
941
942/*!
943 \qmlproperty enumeration PrincipledMaterial::vertexColorAlphaMask
944 \since 6.8
945
946 This property defines the vertex color alpha channel used as the specifies mask.
947 The value is a bit-wise combination of flags.
948 The default value is \c PrincipledMaterial.NoMask.
949
950 \value PrincipledMaterial.NoMask.
951 \value PrincipledMaterial.ClearcoatAmountMask.
952 \value PrincipledMaterial.ClearcoatRoughnessAmountMask.
953 \value PrincipledMaterial.ClearcoatNormalStrengthMask.
954 \value PrincipledMaterial.HeightAmountMask.
955 \value PrincipledMaterial.MetalnessMask.
956 \value PrincipledMaterial.RoughnessMask.
957 \value PrincipledMaterial.NormalStrengthMask.
958 \value PrincipledMaterial.OcclusionAmountMask.
959 \value PrincipledMaterial.SpecularAmountMask.
960 \value PrincipledMaterial.ThicknessFactorMask.
961 \value PrincipledMaterial.TransmissionFactorMask.
962*/
963
964QQuick3DPrincipledMaterial::QQuick3DPrincipledMaterial(QQuick3DObject *parent)
965 : QQuick3DMaterial(*(new QQuick3DObjectPrivate(QQuick3DObjectPrivate::Type::PrincipledMaterial)), parent)
966{}
967
968QQuick3DPrincipledMaterial::~QQuick3DPrincipledMaterial()
969{
970}
971
972QQuick3DPrincipledMaterial::Lighting QQuick3DPrincipledMaterial::lighting() const
973{
974 return m_lighting;
975}
976
977QQuick3DPrincipledMaterial::BlendMode QQuick3DPrincipledMaterial::blendMode() const
978{
979 return m_blendMode;
980}
981
982QColor QQuick3DPrincipledMaterial::baseColor() const
983{
984 return m_baseColor;
985}
986
987QQuick3DTexture *QQuick3DPrincipledMaterial::baseColorMap() const
988{
989 return m_baseColorMap;
990}
991
992bool QQuick3DPrincipledMaterial::baseColorSingleChannelEnabled() const
993{
994 return m_baseColorSingleChannelEnabled;
995}
996
997QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::baseColorChannel() const
998{
999 return m_baseColorChannel;
1000}
1001
1002bool QQuick3DPrincipledMaterial::specularSingleChannelEnabled() const
1003{
1004 return m_specularSingleChannelEnabled;
1005}
1006
1007QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::specularChannel() const
1008{
1009 return m_specularChannel;
1010}
1011
1012bool QQuick3DPrincipledMaterial::emissiveSingleChannelEnabled() const
1013{
1014 return m_emissiveSingleChannelEnabled;
1015}
1016
1017QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::emissiveChannel() const
1018{
1019 return m_emissiveChannel;
1020}
1021
1022QQuick3DTexture *QQuick3DPrincipledMaterial::emissiveMap() const
1023{
1024 return m_emissiveMap;
1025}
1026
1027QVector3D QQuick3DPrincipledMaterial::emissiveFactor() const
1028{
1029 return m_emissiveFactor;
1030}
1031
1032QQuick3DTexture *QQuick3DPrincipledMaterial::specularReflectionMap() const
1033{
1034 return m_specularReflectionMap;
1035}
1036
1037QQuick3DTexture *QQuick3DPrincipledMaterial::specularMap() const
1038{
1039 return m_specularMap;
1040}
1041
1042float QQuick3DPrincipledMaterial::specularTint() const
1043{
1044 return m_specularTint;
1045}
1046
1047float QQuick3DPrincipledMaterial::specularAmount() const
1048{
1049 return m_specularAmount;
1050}
1051
1052float QQuick3DPrincipledMaterial::roughness() const
1053{
1054 return m_roughness;
1055}
1056
1057QQuick3DTexture *QQuick3DPrincipledMaterial::roughnessMap() const
1058{
1059 return m_roughnessMap;
1060}
1061
1062bool QQuick3DPrincipledMaterial::invertOpacityMapValue() const
1063{
1064 return m_invertOpacityMapValue;
1065}
1066
1067float QQuick3DPrincipledMaterial::opacity() const
1068{
1069 return m_opacity;
1070}
1071
1072QQuick3DTexture *QQuick3DPrincipledMaterial::opacityMap() const
1073{
1074 return m_opacityMap;
1075}
1076
1077QQuick3DTexture *QQuick3DPrincipledMaterial::normalMap() const
1078{
1079 return m_normalMap;
1080}
1081
1082float QQuick3DPrincipledMaterial::metalness() const
1083{
1084 return m_metalnessAmount;
1085}
1086
1087QQuick3DTexture *QQuick3DPrincipledMaterial::metalnessMap() const
1088{
1089 return m_metalnessMap;
1090}
1091
1092float QQuick3DPrincipledMaterial::normalStrength() const
1093{
1094 return m_normalStrength;
1095}
1096
1097QQuick3DTexture *QQuick3DPrincipledMaterial::occlusionMap() const
1098{
1099 return m_occlusionMap;
1100}
1101
1102float QQuick3DPrincipledMaterial::occlusionAmount() const
1103{
1104 return m_occlusionAmount;
1105}
1106
1107QQuick3DPrincipledMaterial::AlphaMode QQuick3DPrincipledMaterial::alphaMode() const
1108{
1109 return m_alphaMode;
1110}
1111
1112float QQuick3DPrincipledMaterial::alphaCutoff() const
1113{
1114 return m_alphaCutoff;
1115}
1116
1117QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::roughnessChannel() const
1118{
1119 return m_roughnessChannel;
1120}
1121
1122QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::opacityChannel() const
1123{
1124 return m_opacityChannel;
1125}
1126
1127QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::metalnessChannel() const
1128{
1129 return m_metalnessChannel;
1130}
1131
1132QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::occlusionChannel() const
1133{
1134 return m_occlusionChannel;
1135}
1136
1137float QQuick3DPrincipledMaterial::pointSize() const
1138{
1139 return m_pointSize;
1140}
1141
1142float QQuick3DPrincipledMaterial::lineWidth() const
1143{
1144 return m_lineWidth;
1145}
1146
1147QQuick3DTexture *QQuick3DPrincipledMaterial::heightMap() const
1148{
1149 return m_heightMap;
1150}
1151
1152QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::heightChannel() const
1153{
1154 return m_heightChannel;
1155}
1156
1157float QQuick3DPrincipledMaterial::heightAmount() const
1158{
1159 return m_heightAmount;
1160}
1161
1162int QQuick3DPrincipledMaterial::minHeightMapSamples() const
1163{
1164 return m_minHeightMapSamples;
1165}
1166
1167int QQuick3DPrincipledMaterial::maxHeightMapSamples() const
1168{
1169 return m_maxHeightMapSamples;
1170}
1171
1172void QQuick3DPrincipledMaterial::markAllDirty()
1173{
1174 m_dirtyAttributes = 0xffffffff;
1175 QQuick3DMaterial::markAllDirty();
1176}
1177
1178void QQuick3DPrincipledMaterial::setLighting(QQuick3DPrincipledMaterial::Lighting lighting)
1179{
1180 if (m_lighting == lighting)
1181 return;
1182
1183 m_lighting = lighting;
1184 emit lightingChanged(m_lighting);
1185 markDirty(LightingModeDirty);
1186}
1187
1188void QQuick3DPrincipledMaterial::setBlendMode(QQuick3DPrincipledMaterial::BlendMode blendMode)
1189{
1190 if (m_blendMode == blendMode)
1191 return;
1192
1193 m_blendMode = blendMode;
1194 emit blendModeChanged(m_blendMode);
1195 markDirty(BlendModeDirty);
1196}
1197
1198void QQuick3DPrincipledMaterial::setBaseColor(QColor diffuseColor)
1199{
1200 if (m_baseColor == diffuseColor)
1201 return;
1202
1203 m_baseColor = diffuseColor;
1204 emit baseColorChanged(m_baseColor);
1205 markDirty(BaseColorDirty);
1206}
1207
1208void QQuick3DPrincipledMaterial::setBaseColorMap(QQuick3DTexture *baseColorMap)
1209{
1210 if (m_baseColorMap == baseColorMap)
1211 return;
1212
1213 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setBaseColorMap, baseColorMap, m_baseColorMap);
1214
1215 m_baseColorMap = baseColorMap;
1216 emit baseColorMapChanged(m_baseColorMap);
1217 markDirty(BaseColorDirty);
1218}
1219
1220void QQuick3DPrincipledMaterial::setBaseColorSingleChannelEnabled(bool baseColorSingleChannelEnabled)
1221{
1222 if (m_baseColorSingleChannelEnabled == baseColorSingleChannelEnabled)
1223 return;
1224
1225 m_baseColorSingleChannelEnabled = baseColorSingleChannelEnabled;
1226 emit baseColorSingleChannelEnabledChanged(baseColorSingleChannelEnabled);
1227 markDirty(BaseColorDirty);
1228}
1229
1230void QQuick3DPrincipledMaterial::setBaseColorChannel(TextureChannelMapping channel)
1231{
1232 if (m_baseColorChannel == channel)
1233 return;
1234
1235 m_baseColorChannel = channel;
1236 emit baseColorChannelChanged(channel);
1237 markDirty(BaseColorDirty);
1238}
1239
1240void QQuick3DPrincipledMaterial::setSpecularSingleChannelEnabled(bool specularSingleChannelEnabled)
1241{
1242 if (m_specularSingleChannelEnabled == specularSingleChannelEnabled)
1243 return;
1244
1245 m_specularSingleChannelEnabled = specularSingleChannelEnabled;
1246 emit specularSingleChannelEnabledChanged(specularSingleChannelEnabled);
1247 markDirty(SpecularDirty);
1248}
1249
1250void QQuick3DPrincipledMaterial::setSpecularChannel(TextureChannelMapping channel)
1251{
1252 if (m_specularChannel == channel)
1253 return;
1254
1255 m_specularChannel = channel;
1256 emit specularChannelChanged(channel);
1257 markDirty(SpecularDirty);
1258}
1259
1260void QQuick3DPrincipledMaterial::setEmissiveSingleChannelEnabled(bool emissiveSingleChannelEnabled)
1261{
1262 if (m_emissiveSingleChannelEnabled == emissiveSingleChannelEnabled)
1263 return;
1264
1265 m_emissiveSingleChannelEnabled = emissiveSingleChannelEnabled;
1266 emit emissiveSingleChannelEnabledChanged(emissiveSingleChannelEnabled);
1267 markDirty(EmissiveDirty);
1268}
1269
1270void QQuick3DPrincipledMaterial::setEmissiveChannel(TextureChannelMapping channel)
1271{
1272 if (m_emissiveChannel == channel)
1273 return;
1274
1275 m_emissiveChannel = channel;
1276 emit emissiveChannelChanged(channel);
1277 markDirty(EmissiveDirty);
1278}
1279
1280void QQuick3DPrincipledMaterial::setEmissiveMap(QQuick3DTexture *emissiveMap)
1281{
1282 if (m_emissiveMap == emissiveMap)
1283 return;
1284
1285 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setEmissiveMap, emissiveMap, m_emissiveMap);
1286
1287 m_emissiveMap = emissiveMap;
1288 emit emissiveMapChanged(m_emissiveMap);
1289 markDirty(EmissiveDirty);
1290}
1291
1292void QQuick3DPrincipledMaterial::setEmissiveFactor(QVector3D emissiveFactor)
1293{
1294 if (m_emissiveFactor == emissiveFactor)
1295 return;
1296
1297 m_emissiveFactor = emissiveFactor;
1298 emit emissiveFactorChanged(m_emissiveFactor);
1299 markDirty(EmissiveDirty);
1300}
1301
1302void QQuick3DPrincipledMaterial::setSpecularReflectionMap(QQuick3DTexture *specularReflectionMap)
1303{
1304 if (m_specularReflectionMap == specularReflectionMap)
1305 return;
1306
1307 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setSpecularReflectionMap, specularReflectionMap, m_specularReflectionMap);
1308
1309 m_specularReflectionMap = specularReflectionMap;
1310 emit specularReflectionMapChanged(m_specularReflectionMap);
1311 markDirty(SpecularDirty);
1312}
1313
1314void QQuick3DPrincipledMaterial::setSpecularMap(QQuick3DTexture *specularMap)
1315{
1316 if (m_specularMap == specularMap)
1317 return;
1318
1319 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setSpecularMap, specularMap, m_specularMap);
1320
1321 m_specularMap = specularMap;
1322 emit specularMapChanged(m_specularMap);
1323 markDirty(SpecularDirty);
1324}
1325
1326void QQuick3DPrincipledMaterial::setSpecularTint(float specularTint)
1327{
1328 specularTint = ensureNormalized(specularTint);
1329 if (qFuzzyCompare(m_specularTint, specularTint))
1330 return;
1331
1332 m_specularTint = specularTint;
1333 emit specularTintChanged(m_specularTint);
1334 markDirty(SpecularDirty);
1335}
1336
1337void QQuick3DPrincipledMaterial::setSpecularAmount(float specularAmount)
1338{
1339 specularAmount = ensureNormalized(specularAmount);
1340 if (qFuzzyCompare(m_specularAmount, specularAmount))
1341 return;
1342
1343 m_specularAmount = specularAmount;
1344 emit specularAmountChanged(m_specularAmount);
1345 markDirty(SpecularDirty);
1346}
1347
1348void QQuick3DPrincipledMaterial::setRoughness(float roughness)
1349{
1350 roughness = ensureNormalized(roughness);
1351 if (qFuzzyCompare(m_roughness, roughness))
1352 return;
1353
1354 m_roughness = roughness;
1355 emit roughnessChanged(m_roughness);
1356 markDirty(RoughnessDirty);
1357}
1358
1359void QQuick3DPrincipledMaterial::setRoughnessMap(QQuick3DTexture *roughnessMap)
1360{
1361 if (m_roughnessMap == roughnessMap)
1362 return;
1363
1364 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setRoughnessMap, roughnessMap, m_roughnessMap);
1365
1366 m_roughnessMap = roughnessMap;
1367 emit roughnessMapChanged(m_roughnessMap);
1368 markDirty(RoughnessDirty);
1369}
1370
1371void QQuick3DPrincipledMaterial::setInvertOpacityMapValue(bool invertOpacityMapValue)
1372{
1373 if (invertOpacityMapValue == m_invertOpacityMapValue)
1374 return;
1375
1376 m_invertOpacityMapValue = invertOpacityMapValue;
1377 emit invertOpacityMapValueChanged(m_invertOpacityMapValue);
1378 markDirty(OpacityDirty);
1379}
1380
1381void QQuick3DPrincipledMaterial::setOpacity(float opacity)
1382{
1383 opacity = ensureNormalized(opacity);
1384 if (qFuzzyCompare(m_opacity, opacity))
1385 return;
1386
1387 m_opacity = opacity;
1388 emit opacityChanged(m_opacity);
1389 markDirty(OpacityDirty);
1390}
1391
1392void QQuick3DPrincipledMaterial::setOpacityMap(QQuick3DTexture *opacityMap)
1393{
1394 if (m_opacityMap == opacityMap)
1395 return;
1396
1397 QQuick3DObjectPrivate::attachWatcher(this, &::QQuick3DPrincipledMaterial::setOpacityMap, opacityMap, m_opacityMap);
1398
1399 m_opacityMap = opacityMap;
1400 emit opacityMapChanged(m_opacityMap);
1401 markDirty(OpacityDirty);
1402}
1403
1404void QQuick3DPrincipledMaterial::setNormalMap(QQuick3DTexture *normalMap)
1405{
1406 if (m_normalMap == normalMap)
1407 return;
1408
1409 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setNormalMap, normalMap, m_normalMap);
1410
1411 m_normalMap = normalMap;
1412 emit normalMapChanged(m_normalMap);
1413 markDirty(NormalDirty);
1414}
1415
1416void QQuick3DPrincipledMaterial::setMetalness(float metalnessAmount)
1417{
1418 metalnessAmount = ensureNormalized(metalnessAmount);
1419 if (qFuzzyCompare(m_metalnessAmount, metalnessAmount))
1420 return;
1421
1422 m_metalnessAmount = metalnessAmount;
1423 emit metalnessChanged(m_metalnessAmount);
1424 markDirty(MetalnessDirty);
1425}
1426
1427void QQuick3DPrincipledMaterial::setMetalnessMap(QQuick3DTexture *metallicMap)
1428{
1429 if (m_metalnessMap == metallicMap)
1430 return;
1431
1432 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setMetalnessMap, metallicMap, m_metalnessMap);
1433
1434 m_metalnessMap = metallicMap;
1435 emit metalnessMapChanged(m_metalnessMap);
1436 markDirty(MetalnessDirty);
1437}
1438
1439void QQuick3DPrincipledMaterial::setNormalStrength(float factor)
1440{
1441 factor = ensureNormalized(factor);
1442 if (qFuzzyCompare(m_normalStrength, factor))
1443 return;
1444
1445 m_normalStrength = factor;
1446 emit normalStrengthChanged(m_normalStrength);
1447 markDirty(NormalDirty);
1448}
1449
1450void QQuick3DPrincipledMaterial::setOcclusionMap(QQuick3DTexture *occlusionMap)
1451{
1452 if (m_occlusionMap == occlusionMap)
1453 return;
1454
1455 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setOcclusionMap, occlusionMap, m_occlusionMap);
1456
1457 m_occlusionMap = occlusionMap;
1458 emit occlusionMapChanged(m_occlusionMap);
1459 markDirty(OcclusionDirty);
1460}
1461
1462void QQuick3DPrincipledMaterial::setOcclusionAmount(float occlusionAmount)
1463{
1464 if (qFuzzyCompare(m_occlusionAmount, occlusionAmount))
1465 return;
1466
1467 m_occlusionAmount = occlusionAmount;
1468 emit occlusionAmountChanged(m_occlusionAmount);
1469 markDirty(OcclusionDirty);
1470}
1471
1472void QQuick3DPrincipledMaterial::setAlphaMode(QQuick3DPrincipledMaterial::AlphaMode alphaMode)
1473{
1474 if (m_alphaMode == alphaMode)
1475 return;
1476
1477 m_alphaMode = alphaMode;
1478 emit alphaModeChanged(m_alphaMode);
1479 markDirty(AlphaModeDirty);
1480}
1481
1482void QQuick3DPrincipledMaterial::setAlphaCutoff(float alphaCutoff)
1483{
1484 if (qFuzzyCompare(m_alphaCutoff, alphaCutoff))
1485 return;
1486
1487 m_alphaCutoff = alphaCutoff;
1488 emit alphaCutoffChanged(m_alphaCutoff);
1489 markDirty(AlphaModeDirty);
1490}
1491
1492void QQuick3DPrincipledMaterial::setMetalnessChannel(TextureChannelMapping channel)
1493{
1494 if (m_metalnessChannel == channel)
1495 return;
1496
1497 m_metalnessChannel = channel;
1498 emit metalnessChannelChanged(channel);
1499 markDirty(MetalnessDirty);
1500}
1501
1502void QQuick3DPrincipledMaterial::setRoughnessChannel(TextureChannelMapping channel)
1503{
1504 if (m_roughnessChannel == channel)
1505 return;
1506
1507 m_roughnessChannel = channel;
1508 emit roughnessChannelChanged(channel);
1509 markDirty(RoughnessDirty);
1510}
1511
1512void QQuick3DPrincipledMaterial::setOpacityChannel(TextureChannelMapping channel)
1513{
1514 if (m_opacityChannel == channel)
1515 return;
1516
1517 m_opacityChannel = channel;
1518 emit opacityChannelChanged(channel);
1519 markDirty(OpacityDirty);
1520}
1521
1522void QQuick3DPrincipledMaterial::setOcclusionChannel(TextureChannelMapping channel)
1523{
1524 if (m_occlusionChannel == channel)
1525 return;
1526
1527 m_occlusionChannel = channel;
1528 emit occlusionChannelChanged(channel);
1529 markDirty(OcclusionDirty);
1530}
1531
1532void QQuick3DPrincipledMaterial::setPointSize(float size)
1533{
1534 if (qFuzzyCompare(m_pointSize, size))
1535 return;
1536 m_pointSize = size;
1537 emit pointSizeChanged();
1538 markDirty(PointSizeDirty);
1539}
1540
1541void QQuick3DPrincipledMaterial::setLineWidth(float width)
1542{
1543 if (qFuzzyCompare(m_lineWidth, width))
1544 return;
1545 m_lineWidth = width;
1546 emit lineWidthChanged();
1547 markDirty(LineWidthDirty);
1548}
1549
1550void QQuick3DPrincipledMaterial::setHeightMap(QQuick3DTexture *heightMap)
1551{
1552 if (m_heightMap == heightMap)
1553 return;
1554
1555 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setHeightMap, heightMap, m_heightMap);
1556
1557 m_heightMap = heightMap;
1558 emit heightMapChanged(m_heightMap);
1559 markDirty(HeightDirty);
1560}
1561
1562void QQuick3DPrincipledMaterial::setHeightChannel(QQuick3DMaterial::TextureChannelMapping channel)
1563{
1564 if (m_heightChannel == channel)
1565 return;
1566
1567 m_heightChannel = channel;
1568 emit heightChannelChanged(m_heightChannel);
1569 markDirty(HeightDirty);
1570}
1571
1572void QQuick3DPrincipledMaterial::setHeightAmount(float heightAmount)
1573{
1574 if (m_heightAmount == heightAmount)
1575 return;
1576
1577 m_heightAmount = heightAmount;
1578 emit heightAmountChanged(m_heightAmount);
1579 markDirty(HeightDirty);
1580}
1581
1582void QQuick3DPrincipledMaterial::setMinHeightMapSamples(int samples)
1583{
1584 if (m_minHeightMapSamples == samples)
1585 return;
1586
1587 m_minHeightMapSamples = samples;
1588 emit minHeightMapSamplesChanged(samples);
1589 markDirty(HeightDirty);
1590}
1591
1592void QQuick3DPrincipledMaterial::setMaxHeightMapSamples(int samples)
1593{
1594 if (m_maxHeightMapSamples == samples)
1595 return;
1596
1597 m_maxHeightMapSamples = samples;
1598 emit maxHeightMapSamplesChanged(samples);
1599 markDirty(HeightDirty);
1600}
1601
1602QSSGRenderGraphObject *QQuick3DPrincipledMaterial::updateSpatialNode(QSSGRenderGraphObject *node)
1603{
1604 static const auto channelMapping = [](TextureChannelMapping mapping) {
1605 return QSSGRenderDefaultMaterial::TextureChannelMapping(mapping);
1606 };
1607
1608 if (!node) {
1609 markAllDirty();
1610 node = new QSSGRenderDefaultMaterial(QSSGRenderGraphObject::Type::PrincipledMaterial);
1611 }
1612
1613 // Set common material properties
1614 QQuick3DMaterial::updateSpatialNode(node);
1615
1616 QSSGRenderDefaultMaterial *material = static_cast<QSSGRenderDefaultMaterial *>(node);
1617
1618 material->specularModel = QSSGRenderDefaultMaterial::MaterialSpecularModel::SchlickGGX;
1619
1620 if (m_dirtyAttributes & LightingModeDirty)
1621 material->lighting = QSSGRenderDefaultMaterial::MaterialLighting(m_lighting);
1622
1623 if (m_dirtyAttributes & BlendModeDirty)
1624 material->blendMode = QSSGRenderDefaultMaterial::MaterialBlendMode(m_blendMode);
1625
1626 if (m_dirtyAttributes & BaseColorDirty) {
1627 if (!m_baseColorMap)
1628 material->colorMap = nullptr;
1629 else
1630 material->colorMap = m_baseColorMap->getRenderImage();
1631
1632 material->color = QSSGUtils::color::sRGBToLinear(m_baseColor);
1633 material->baseColorSingleChannelEnabled = m_baseColorSingleChannelEnabled;
1634 material->baseColorChannel = channelMapping(m_baseColorChannel);
1635 }
1636
1637 if (m_dirtyAttributes & EmissiveDirty) {
1638 if (!m_emissiveMap)
1639 material->emissiveMap = nullptr;
1640 else
1641 material->emissiveMap = m_emissiveMap->getRenderImage();
1642
1643 material->emissiveColor = m_emissiveFactor;
1644 material->emissiveSingleChannelEnabled = m_emissiveSingleChannelEnabled;
1645 material->emissiveChannel = channelMapping(m_emissiveChannel);
1646 }
1647
1648 if (m_dirtyAttributes & RoughnessDirty) {
1649 if (!m_roughnessMap)
1650 material->roughnessMap = nullptr;
1651 else
1652 material->roughnessMap = m_roughnessMap->getRenderImage();
1653
1654 material->specularRoughness = m_roughness;
1655 material->roughnessChannel = channelMapping(m_roughnessChannel);
1656 }
1657
1658 if (m_dirtyAttributes & MetalnessDirty) {
1659 if (!m_metalnessMap)
1660 material->metalnessMap = nullptr;
1661 else
1662 material->metalnessMap = m_metalnessMap->getRenderImage();
1663
1664 material->metalnessAmount = m_metalnessAmount;
1665 material->metalnessChannel = channelMapping(m_metalnessChannel);
1666
1667 }
1668
1669 if (m_dirtyAttributes & SpecularDirty) {
1670 if (!m_specularReflectionMap)
1671 material->specularReflection = nullptr;
1672 else
1673 material->specularReflection = m_specularReflectionMap->getRenderImage();
1674
1675 if (!m_specularMap) {
1676 material->specularMap = nullptr;
1677 } else {
1678 material->specularMap = m_specularMap->getRenderImage();
1679 }
1680
1681 material->specularAmount = m_specularAmount;
1682 material->specularTint = QVector3D(m_specularTint, m_specularTint, m_specularTint);
1683 material->ior = m_indexOfRefraction;
1684 material->fresnelScaleBiasEnabled = m_fresnelScaleBiasEnabled;
1685 material->fresnelScale = m_fresnelScale;
1686 material->fresnelBias = m_fresnelBias;
1687 material->fresnelPower = m_fresnelPower;
1688 material->specularAmountSingleChannelEnabled = m_specularSingleChannelEnabled;
1689 material->specularAmountChannel = channelMapping(m_specularChannel);
1690 }
1691
1692 if (m_dirtyAttributes & OpacityDirty) {
1693 material->opacity = m_opacity;
1694 if (!m_opacityMap)
1695 material->opacityMap = nullptr;
1696 else
1697 material->opacityMap = m_opacityMap->getRenderImage();
1698
1699 material->invertOpacityMapValue = m_invertOpacityMapValue;
1700 material->opacity = m_opacity;
1701 material->opacityChannel = channelMapping(m_opacityChannel);
1702 }
1703
1704 if (m_dirtyAttributes & NormalDirty) {
1705 if (!m_normalMap)
1706 material->normalMap = nullptr;
1707 else
1708 material->normalMap = m_normalMap->getRenderImage();
1709
1710 material->bumpAmount = m_normalStrength;
1711 }
1712
1713 if (m_dirtyAttributes & OcclusionDirty) {
1714 if (!m_occlusionMap)
1715 material->occlusionMap = nullptr;
1716 else
1717 material->occlusionMap = m_occlusionMap->getRenderImage();
1718 material->occlusionAmount = m_occlusionAmount;
1719 material->occlusionChannel = channelMapping(m_occlusionChannel);
1720 }
1721
1722 if (m_dirtyAttributes & AlphaModeDirty) {
1723 material->alphaMode = QSSGRenderDefaultMaterial::MaterialAlphaMode(m_alphaMode);
1724 material->alphaCutoff = m_alphaCutoff;
1725 }
1726
1727 if (m_dirtyAttributes & PointSizeDirty)
1728 material->pointSize = m_pointSize;
1729
1730 if (m_dirtyAttributes & LineWidthDirty)
1731 material->lineWidth = m_lineWidth;
1732
1733 if (m_dirtyAttributes & HeightDirty) {
1734 if (!m_heightMap)
1735 material->heightMap = nullptr;
1736 else
1737 material->heightMap = m_heightMap->getRenderImage();
1738 material->heightAmount = m_heightAmount;
1739 material->minHeightSamples = m_minHeightMapSamples;
1740 material->maxHeightSamples = m_maxHeightMapSamples;
1741 material->heightChannel = channelMapping(m_heightChannel);
1742 }
1743
1744 if (m_dirtyAttributes & ClearcoatDirty) {
1745 material->clearcoatAmount = m_clearcoatAmount;
1746 if (!m_clearcoatMap)
1747 material->clearcoatMap = nullptr;
1748 else
1749 material->clearcoatMap = m_clearcoatMap->getRenderImage();
1750 material->clearcoatChannel = channelMapping(m_clearcoatChannel);
1751 material->clearcoatRoughnessAmount = m_clearcoatRoughnessAmount;
1752 if (!m_clearcoatRoughnessMap)
1753 material->clearcoatRoughnessMap = nullptr;
1754 else
1755 material->clearcoatRoughnessMap = m_clearcoatRoughnessMap->getRenderImage();
1756 material->clearcoatRoughnessChannel = channelMapping(m_clearcoatRoughnessChannel);
1757 if (!m_clearcoatNormalMap)
1758 material->clearcoatNormalMap = nullptr;
1759 else
1760 material->clearcoatNormalMap = m_clearcoatNormalMap->getRenderImage();
1761 material->clearcoatNormalStrength = m_clearcoatNormalStrength;
1762 material->clearcoatFresnelScaleBiasEnabled = m_clearcoatFresnelScaleBiasEnabled;
1763 material->clearcoatFresnelScale = m_clearcoatFresnelScale;
1764 material->clearcoatFresnelBias = m_clearcoatFresnelBias;
1765 material->clearcoatFresnelPower = m_clearcoatFresnelPower;
1766 }
1767
1768 if (m_dirtyAttributes & TransmissionDirty) {
1769 material->transmissionFactor = m_transmissionFactor;
1770 if (!m_transmissionMap)
1771 material->transmissionMap = nullptr;
1772 else
1773 material->transmissionMap = m_transmissionMap->getRenderImage();
1774 material->transmissionChannel = channelMapping(m_transmissionChannel);
1775 }
1776
1777 if (m_dirtyAttributes & VolumeDirty) {
1778 material->thicknessFactor = m_thicknessFactor;
1779 if (!m_thicknessMap)
1780 material->thicknessMap = nullptr;
1781 else
1782 material->thicknessMap = m_thicknessMap->getRenderImage();
1783 material->thicknessChannel = channelMapping(m_thicknessChannel);
1784
1785 material->attenuationDistance = m_attenuationDistance;
1786 material->attenuationColor = QSSGUtils::color::sRGBToLinear(m_attenuationColor).toVector3D();
1787 }
1788
1789 if (m_dirtyAttributes & VertexColorsDirty) {
1790 material->vertexColorsEnabled = m_vertexColorsEnabled;
1791 material->vertexColorsMaskEnabled = m_vertexColorsMaskEnabled;
1792 material->vertexColorRedMask = QSSGRenderDefaultMaterial::VertexColorMaskFlags::fromInt(m_vertexColorRedMask);
1793 material->vertexColorGreenMask = QSSGRenderDefaultMaterial::VertexColorMaskFlags::fromInt(m_vertexColorGreenMask);
1794 material->vertexColorBlueMask = QSSGRenderDefaultMaterial::VertexColorMaskFlags::fromInt(m_vertexColorBlueMask);
1795 material->vertexColorAlphaMask = QSSGRenderDefaultMaterial::VertexColorMaskFlags::fromInt(m_vertexColorAlphaMask);
1796 }
1797
1798 m_dirtyAttributes = 0;
1799
1800 return node;
1801}
1802
1803void QQuick3DPrincipledMaterial::itemChange(QQuick3DObject::ItemChange change, const QQuick3DObject::ItemChangeData &value)
1804{
1805 if (change == QQuick3DObject::ItemSceneChange)
1806 updateSceneManager(value.sceneManager);
1807}
1808
1809void QQuick3DPrincipledMaterial::updateSceneManager(QQuick3DSceneManager *sceneManager)
1810{
1811 // Check all the resource value's scene manager, and update as necessary.
1812 if (sceneManager) {
1813 QQuick3DObjectPrivate::refSceneManager(m_baseColorMap, *sceneManager);
1814 QQuick3DObjectPrivate::refSceneManager(m_emissiveMap, *sceneManager);
1815 QQuick3DObjectPrivate::refSceneManager(m_specularReflectionMap, *sceneManager);
1816 QQuick3DObjectPrivate::refSceneManager(m_specularMap, *sceneManager);
1817 QQuick3DObjectPrivate::refSceneManager(m_roughnessMap, *sceneManager);
1818 QQuick3DObjectPrivate::refSceneManager(m_opacityMap, *sceneManager);
1819 QQuick3DObjectPrivate::refSceneManager(m_normalMap, *sceneManager);
1820 QQuick3DObjectPrivate::refSceneManager(m_metalnessMap, *sceneManager);
1821 QQuick3DObjectPrivate::refSceneManager(m_occlusionMap, *sceneManager);
1822 QQuick3DObjectPrivate::refSceneManager(m_heightMap, *sceneManager);
1823 QQuick3DObjectPrivate::refSceneManager(m_clearcoatMap, *sceneManager);
1824 QQuick3DObjectPrivate::refSceneManager(m_clearcoatRoughnessMap, *sceneManager);
1825 QQuick3DObjectPrivate::refSceneManager(m_clearcoatNormalMap, *sceneManager);
1826 QQuick3DObjectPrivate::refSceneManager(m_transmissionMap, *sceneManager);
1827 QQuick3DObjectPrivate::refSceneManager(m_thicknessMap, *sceneManager);
1828 } else {
1829 QQuick3DObjectPrivate::derefSceneManager(m_baseColorMap);
1830 QQuick3DObjectPrivate::derefSceneManager(m_emissiveMap);
1831 QQuick3DObjectPrivate::derefSceneManager(m_specularReflectionMap);
1832 QQuick3DObjectPrivate::derefSceneManager(m_specularMap);
1833 QQuick3DObjectPrivate::derefSceneManager(m_roughnessMap);
1834 QQuick3DObjectPrivate::derefSceneManager(m_opacityMap);
1835 QQuick3DObjectPrivate::derefSceneManager(m_normalMap);
1836 QQuick3DObjectPrivate::derefSceneManager(m_metalnessMap);
1837 QQuick3DObjectPrivate::derefSceneManager(m_occlusionMap);
1838 QQuick3DObjectPrivate::derefSceneManager(m_heightMap);
1839 QQuick3DObjectPrivate::derefSceneManager(m_clearcoatMap);
1840 QQuick3DObjectPrivate::derefSceneManager(m_clearcoatRoughnessMap);
1841 QQuick3DObjectPrivate::derefSceneManager(m_clearcoatNormalMap);
1842 QQuick3DObjectPrivate::derefSceneManager(m_transmissionMap);
1843 QQuick3DObjectPrivate::derefSceneManager(m_thicknessMap);
1844 }
1845}
1846
1847void QQuick3DPrincipledMaterial::markDirty(QQuick3DPrincipledMaterial::DirtyType type)
1848{
1849 if (!(m_dirtyAttributes & quint32(type))) {
1850 m_dirtyAttributes |= quint32(type);
1851 update();
1852 }
1853}
1854
1855float QQuick3DPrincipledMaterial::clearcoatAmount() const
1856{
1857 return m_clearcoatAmount;
1858}
1859
1860void QQuick3DPrincipledMaterial::setClearcoatAmount(float newClearcoatAmount)
1861{
1862 if (qFuzzyCompare(m_clearcoatAmount, newClearcoatAmount))
1863 return;
1864 m_clearcoatAmount = newClearcoatAmount;
1865 emit clearcoatAmountChanged(m_clearcoatAmount);
1866 markDirty(ClearcoatDirty);
1867}
1868
1869QQuick3DTexture *QQuick3DPrincipledMaterial::clearcoatMap() const
1870{
1871 return m_clearcoatMap;
1872}
1873
1874void QQuick3DPrincipledMaterial::setClearcoatMap(QQuick3DTexture *newClearcoatMap)
1875{
1876 if (m_clearcoatMap == newClearcoatMap)
1877 return;
1878
1879 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setClearcoatMap, newClearcoatMap, m_clearcoatMap);
1880
1881 m_clearcoatMap = newClearcoatMap;
1882 emit clearcoatMapChanged(m_clearcoatMap);
1883 markDirty(ClearcoatDirty);
1884}
1885
1886QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::clearcoatChannel() const
1887{
1888 return m_clearcoatChannel;
1889}
1890
1891void QQuick3DPrincipledMaterial::setClearcoatChannel(QQuick3DMaterial::TextureChannelMapping newClearcoatChannel)
1892{
1893 if (m_clearcoatChannel == newClearcoatChannel)
1894 return;
1895 m_clearcoatChannel = newClearcoatChannel;
1896 emit clearcoatChannelChanged(m_clearcoatChannel);
1897 markDirty(ClearcoatDirty);
1898}
1899
1900float QQuick3DPrincipledMaterial::clearcoatRoughnessAmount() const
1901{
1902 return m_clearcoatRoughnessAmount;
1903}
1904
1905void QQuick3DPrincipledMaterial::setClearcoatRoughnessAmount(float newClearcoatRoughnessAmount)
1906{
1907 if (qFuzzyCompare(m_clearcoatRoughnessAmount, newClearcoatRoughnessAmount))
1908 return;
1909 m_clearcoatRoughnessAmount = newClearcoatRoughnessAmount;
1910 emit clearcoatRoughnessAmountChanged(m_clearcoatRoughnessAmount);
1911 markDirty(ClearcoatDirty);
1912}
1913
1914QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::clearcoatRoughnessChannel() const
1915{
1916 return m_clearcoatRoughnessChannel;
1917}
1918
1919void QQuick3DPrincipledMaterial::setClearcoatRoughnessChannel(QQuick3DMaterial::TextureChannelMapping newClearcoatRoughnessChannel)
1920{
1921 if (m_clearcoatRoughnessChannel == newClearcoatRoughnessChannel)
1922 return;
1923 m_clearcoatRoughnessChannel = newClearcoatRoughnessChannel;
1924 emit clearcoatRoughnessChannelChanged(m_clearcoatRoughnessChannel);
1925 markDirty(ClearcoatDirty);
1926}
1927
1928QQuick3DTexture *QQuick3DPrincipledMaterial::clearcoatRoughnessMap() const
1929{
1930 return m_clearcoatRoughnessMap;
1931}
1932
1933void QQuick3DPrincipledMaterial::setClearcoatRoughnessMap(QQuick3DTexture *newClearcoatRoughnessMap)
1934{
1935 if (m_clearcoatRoughnessMap == newClearcoatRoughnessMap)
1936 return;
1937
1938 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setClearcoatRoughnessMap, newClearcoatRoughnessMap, m_clearcoatRoughnessMap);
1939
1940 m_clearcoatRoughnessMap = newClearcoatRoughnessMap;
1941 emit clearcoatRoughnessMapChanged(m_clearcoatRoughnessMap);
1942 markDirty(ClearcoatDirty);
1943}
1944
1945QQuick3DTexture *QQuick3DPrincipledMaterial::clearcoatNormalMap() const
1946{
1947 return m_clearcoatNormalMap;
1948}
1949
1950void QQuick3DPrincipledMaterial::setClearcoatNormalMap(QQuick3DTexture *newClearcoatNormalMap)
1951{
1952 if (m_clearcoatNormalMap == newClearcoatNormalMap)
1953 return;
1954
1955 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setClearcoatNormalMap, newClearcoatNormalMap, m_clearcoatNormalMap);
1956
1957 m_clearcoatNormalMap = newClearcoatNormalMap;
1958 emit clearcoatNormalMapChanged(m_clearcoatNormalMap);
1959 markDirty(ClearcoatDirty);
1960}
1961
1962
1963float QQuick3DPrincipledMaterial::clearcoatNormalStrength() const
1964{
1965 return m_clearcoatNormalStrength;
1966}
1967
1968void QQuick3DPrincipledMaterial::setClearcoatNormalStrength(float newClearcoatNormalStrength)
1969{
1970 if (qFuzzyCompare(m_clearcoatNormalStrength, newClearcoatNormalStrength))
1971 return;
1972
1973 m_clearcoatNormalStrength = newClearcoatNormalStrength;
1974 emit clearcoatNormalStrengthChanged(m_clearcoatNormalStrength);
1975 markDirty(ClearcoatDirty);
1976}
1977
1978float QQuick3DPrincipledMaterial::transmissionFactor() const
1979{
1980 return m_transmissionFactor;
1981}
1982
1983void QQuick3DPrincipledMaterial::setTransmissionFactor(float newTransmissionFactor)
1984{
1985 if (qFuzzyCompare(m_transmissionFactor, newTransmissionFactor))
1986 return;
1987 m_transmissionFactor = newTransmissionFactor;
1988 emit transmissionFactorChanged(m_transmissionFactor);
1989 markDirty(TransmissionDirty);
1990}
1991
1992QQuick3DTexture *QQuick3DPrincipledMaterial::transmissionMap() const
1993{
1994 return m_transmissionMap;
1995}
1996
1997void QQuick3DPrincipledMaterial::setTransmissionMap(QQuick3DTexture *newTransmissionMap)
1998{
1999 if (m_transmissionMap == newTransmissionMap)
2000 return;
2001
2002 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setTransmissionMap, newTransmissionMap, m_transmissionMap);
2003
2004 m_transmissionMap = newTransmissionMap;
2005 emit transmissionMapChanged(m_transmissionMap);
2006 markDirty(TransmissionDirty);
2007}
2008
2009QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::transmissionChannel() const
2010{
2011 return m_transmissionChannel;
2012}
2013
2014float QQuick3DPrincipledMaterial::indexOfRefraction() const
2015{
2016 return m_indexOfRefraction;
2017}
2018
2019bool QQuick3DPrincipledMaterial::fresnelScaleBiasEnabled() const
2020{
2021 return m_fresnelScaleBiasEnabled;
2022}
2023
2024float QQuick3DPrincipledMaterial::fresnelScale() const
2025{
2026 return m_fresnelScale;
2027}
2028
2029float QQuick3DPrincipledMaterial::fresnelBias() const
2030{
2031 return m_fresnelBias;
2032}
2033
2034float QQuick3DPrincipledMaterial::fresnelPower() const
2035{
2036 return m_fresnelPower;
2037}
2038
2039bool QQuick3DPrincipledMaterial::clearcoatFresnelScaleBiasEnabled() const
2040{
2041 return m_clearcoatFresnelScaleBiasEnabled;
2042}
2043
2044float QQuick3DPrincipledMaterial::clearcoatFresnelScale() const
2045{
2046 return m_clearcoatFresnelScale;
2047}
2048
2049float QQuick3DPrincipledMaterial::clearcoatFresnelBias() const
2050{
2051 return m_clearcoatFresnelBias;
2052}
2053
2054float QQuick3DPrincipledMaterial::clearcoatFresnelPower() const
2055{
2056 return m_clearcoatFresnelPower;
2057}
2058
2059bool QQuick3DPrincipledMaterial::vertexColorsEnabled() const
2060{
2061 return m_vertexColorsEnabled;
2062}
2063
2064void QQuick3DPrincipledMaterial::setTransmissionChannel(QQuick3DMaterial::TextureChannelMapping newTransmissionChannel)
2065{
2066 if (m_transmissionChannel == newTransmissionChannel)
2067 return;
2068 m_transmissionChannel = newTransmissionChannel;
2069 emit transmissionChannelChanged(m_transmissionChannel);
2070 markDirty(TransmissionDirty);
2071}
2072
2073float QQuick3DPrincipledMaterial::thicknessFactor() const
2074{
2075 return m_thicknessFactor;
2076}
2077
2078void QQuick3DPrincipledMaterial::setThicknessFactor(float newThicknessFactor)
2079{
2080 if (qFuzzyCompare(m_thicknessFactor, newThicknessFactor))
2081 return;
2082 m_thicknessFactor = newThicknessFactor;
2083 emit thicknessFactorChanged(m_thicknessFactor);
2084 markDirty(VolumeDirty);
2085}
2086
2087QQuick3DTexture *QQuick3DPrincipledMaterial::thicknessMap() const
2088{
2089 return m_thicknessMap;
2090}
2091
2092void QQuick3DPrincipledMaterial::setThicknessMap(QQuick3DTexture *newThicknessMap)
2093{
2094 if (m_thicknessMap == newThicknessMap)
2095 return;
2096
2097 QQuick3DObjectPrivate::attachWatcher(this, &QQuick3DPrincipledMaterial::setThicknessMap, newThicknessMap, m_thicknessMap);
2098
2099 m_thicknessMap = newThicknessMap;
2100 emit thicknessMapChanged(m_thicknessMap);
2101 markDirty(VolumeDirty);
2102}
2103
2104const QQuick3DMaterial::TextureChannelMapping &QQuick3DPrincipledMaterial::thicknessChannel() const
2105{
2106 return m_thicknessChannel;
2107}
2108
2109void QQuick3DPrincipledMaterial::setThicknessChannel(const QQuick3DMaterial::TextureChannelMapping &newThicknessChannel)
2110{
2111 if (m_thicknessChannel == newThicknessChannel)
2112 return;
2113 m_thicknessChannel = newThicknessChannel;
2114 emit thicknessChannelChanged(m_thicknessChannel);
2115 markDirty(VolumeDirty);
2116}
2117
2118float QQuick3DPrincipledMaterial::attenuationDistance() const
2119{
2120 return m_attenuationDistance;
2121}
2122
2123void QQuick3DPrincipledMaterial::setAttenuationDistance(float newAttenuationDistance)
2124{
2125 if (qFuzzyCompare(m_attenuationDistance, newAttenuationDistance))
2126 return;
2127 m_attenuationDistance = newAttenuationDistance;
2128 emit attenuationDistanceChanged(m_attenuationDistance);
2129 markDirty(VolumeDirty);
2130}
2131
2132const QColor &QQuick3DPrincipledMaterial::attenuationColor() const
2133{
2134 return m_attenuationColor;
2135}
2136
2137void QQuick3DPrincipledMaterial::setAttenuationColor(const QColor &newAttenuationColor)
2138{
2139 if (m_attenuationColor == newAttenuationColor)
2140 return;
2141 m_attenuationColor = newAttenuationColor;
2142 emit attenuationColorChanged(m_attenuationColor);
2143 markDirty(VolumeDirty);
2144}
2145
2146void QQuick3DPrincipledMaterial::setIndexOfRefraction(float indexOfRefraction)
2147{
2148 if (qFuzzyCompare(m_indexOfRefraction, indexOfRefraction))
2149 return;
2150
2151 m_indexOfRefraction = indexOfRefraction;
2152 emit indexOfRefractionChanged(m_indexOfRefraction);
2153 markDirty(SpecularDirty);
2154}
2155
2156void QQuick3DPrincipledMaterial::setFresnelScaleBiasEnabled(bool fresnelScaleBiasEnabled)
2157{
2158 if (m_fresnelScaleBiasEnabled == fresnelScaleBiasEnabled)
2159 return;
2160
2161 m_fresnelScaleBiasEnabled = fresnelScaleBiasEnabled;
2162 emit fresnelScaleBiasEnabledChanged(m_fresnelScaleBiasEnabled);
2163 markDirty(SpecularDirty);
2164}
2165
2166void QQuick3DPrincipledMaterial::setFresnelScale(float fresnelScale)
2167{
2168 if (qFuzzyCompare(m_fresnelScale, fresnelScale))
2169 return;
2170
2171 m_fresnelScale = fresnelScale;
2172 emit fresnelScaleChanged(m_fresnelScale);
2173 markDirty(SpecularDirty);
2174}
2175
2176void QQuick3DPrincipledMaterial::setFresnelBias(float fresnelBias)
2177{
2178 if (qFuzzyCompare(m_fresnelBias, fresnelBias))
2179 return;
2180
2181 m_fresnelBias = fresnelBias;
2182 emit fresnelBiasChanged(m_fresnelBias);
2183 markDirty(SpecularDirty);
2184}
2185
2186void QQuick3DPrincipledMaterial::setFresnelPower(float fresnelPower)
2187{
2188 if (qFuzzyCompare(m_fresnelPower, fresnelPower))
2189 return;
2190
2191 m_fresnelPower = fresnelPower;
2192 emit fresnelPowerChanged(m_fresnelPower);
2193 markDirty(SpecularDirty);
2194}
2195
2196void QQuick3DPrincipledMaterial::setClearcoatFresnelScaleBiasEnabled(bool clearcoatFresnelScaleBiasEnabled)
2197{
2198 if (m_clearcoatFresnelScaleBiasEnabled == clearcoatFresnelScaleBiasEnabled)
2199 return;
2200
2201 m_clearcoatFresnelScaleBiasEnabled = clearcoatFresnelScaleBiasEnabled;
2202 emit clearcoatFresnelScaleBiasEnabledChanged(m_clearcoatFresnelScaleBiasEnabled);
2203 markDirty(ClearcoatDirty);
2204}
2205
2206void QQuick3DPrincipledMaterial::setClearcoatFresnelScale(float clearcoatFresnelScale)
2207{
2208 if (qFuzzyCompare(m_clearcoatFresnelScale, clearcoatFresnelScale))
2209 return;
2210
2211 m_clearcoatFresnelScale = clearcoatFresnelScale;
2212 emit clearcoatFresnelScaleChanged(m_clearcoatFresnelScale);
2213 markDirty(ClearcoatDirty);
2214}
2215
2216void QQuick3DPrincipledMaterial::setClearcoatFresnelBias(float clearcoatFresnelBias)
2217{
2218 if (qFuzzyCompare(m_clearcoatFresnelBias, clearcoatFresnelBias))
2219 return;
2220
2221 m_clearcoatFresnelBias = clearcoatFresnelBias;
2222 emit clearcoatFresnelBiasChanged(m_clearcoatFresnelBias);
2223 markDirty(ClearcoatDirty);
2224}
2225
2226void QQuick3DPrincipledMaterial::setClearcoatFresnelPower(float clearcoatFresnelPower)
2227{
2228 if (qFuzzyCompare(m_clearcoatFresnelPower, clearcoatFresnelPower))
2229 return;
2230
2231 m_clearcoatFresnelPower = clearcoatFresnelPower;
2232 emit clearcoatFresnelPowerChanged(m_clearcoatFresnelPower);
2233 markDirty(ClearcoatDirty);
2234}
2235
2236void QQuick3DPrincipledMaterial::setVertexColorsEnabled(bool vertexColors)
2237{
2238 if (m_vertexColorsEnabled == vertexColors)
2239 return;
2240
2241 m_vertexColorsEnabled = vertexColors;
2242 emit vertexColorsEnabledChanged(m_vertexColorsEnabled);
2243 markDirty(VertexColorsDirty);
2244}
2245
2246bool QQuick3DPrincipledMaterial::vertexColorsMaskEnabled() const
2247{
2248 return m_vertexColorsMaskEnabled;
2249}
2250
2251void QQuick3DPrincipledMaterial::setVertexColorsMaskEnabled(bool vertexColorsMaskEnabled)
2252{
2253 if (m_vertexColorsMaskEnabled == vertexColorsMaskEnabled)
2254 return;
2255 m_vertexColorsMaskEnabled = vertexColorsMaskEnabled;
2256 emit vertexColorsMaskEnabledChanged();
2257 markDirty(VertexColorsDirty);
2258}
2259
2260QQuick3DPrincipledMaterial::VertexColorMaskFlags QQuick3DPrincipledMaterial::vertexColorRedMask() const
2261{
2262 return m_vertexColorRedMask;
2263}
2264
2265void QQuick3DPrincipledMaterial::setVertexColorRedMask(QQuick3DPrincipledMaterial::VertexColorMaskFlags vertexColorRedMask)
2266{
2267 if (m_vertexColorRedMask == vertexColorRedMask)
2268 return;
2269 m_vertexColorRedMask = vertexColorRedMask;
2270 emit vertexColorRedMaskChanged();
2271 markDirty(VertexColorsDirty);
2272}
2273
2274QQuick3DPrincipledMaterial::VertexColorMaskFlags QQuick3DPrincipledMaterial::vertexColorGreenMask() const
2275{
2276 return m_vertexColorGreenMask;
2277}
2278
2279void QQuick3DPrincipledMaterial::setVertexColorGreenMask(QQuick3DPrincipledMaterial::VertexColorMaskFlags vertexColorGreenMask)
2280{
2281 if (m_vertexColorGreenMask == vertexColorGreenMask)
2282 return;
2283 m_vertexColorGreenMask = vertexColorGreenMask;
2284 emit vertexColorGreenMaskChanged();
2285 markDirty(VertexColorsDirty);
2286}
2287
2288QQuick3DPrincipledMaterial::VertexColorMaskFlags QQuick3DPrincipledMaterial::vertexColorBlueMask() const
2289{
2290 return m_vertexColorBlueMask;
2291}
2292
2293void QQuick3DPrincipledMaterial::setVertexColorBlueMask(QQuick3DPrincipledMaterial::VertexColorMaskFlags vertexColorBlueMask)
2294{
2295 if (m_vertexColorBlueMask == vertexColorBlueMask)
2296 return;
2297 m_vertexColorBlueMask = vertexColorBlueMask;
2298 emit vertexColorBlueMaskChanged();
2299 markDirty(VertexColorsDirty);
2300}
2301
2302QQuick3DPrincipledMaterial::VertexColorMaskFlags QQuick3DPrincipledMaterial::vertexColorAlphaMask() const
2303{
2304 return m_vertexColorAlphaMask;
2305}
2306
2307void QQuick3DPrincipledMaterial::setVertexColorAlphaMask(QQuick3DPrincipledMaterial::VertexColorMaskFlags vertexColorAlphaMask)
2308{
2309 if (m_vertexColorAlphaMask == vertexColorAlphaMask)
2310 return;
2311 m_vertexColorAlphaMask = vertexColorAlphaMask;
2312 emit vertexColorAlphaMaskChanged();
2313 markDirty(VertexColorsDirty);
2314}
2315
2316QT_END_NAMESPACE
Combined button and popup list for selecting options.