1 | // Copyright (C) 2019 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #include "qquick3dprincipledmaterial_p.h" |
5 | #include "qquick3dobject_p.h" |
6 | |
7 | #include <QtQuick3DRuntimeRender/private/qssgrenderdefaultmaterial_p.h> |
8 | #include <QtQuick3DUtils/private/qssgutils_p.h> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | /*! |
13 | \qmltype PrincipledMaterial |
14 | \inherits Material |
15 | \inqmlmodule QtQuick3D |
16 | \brief Lets you define a material for 3D items using the metal/roughness workflow. |
17 | |
18 | Before a Model can be rendered in a scene, it must have at least one material attached |
19 | to it that describes how the mesh should be shaded. The PrincipledMaterial is a PBR |
20 | metal/roughness material that aims at being an easy to use material with a minimal |
21 | set of parameters. |
22 | In addition to having few parameters, all input values are strictly normalized |
23 | between 0 and 1 and have sensible defaults, meaning even without changing any values, |
24 | the material can be used to shader a model. For an introduction on how the |
25 | different properties of the principled material affects how a model is shaded, |
26 | see the \l{Qt Quick 3D - Principled Material Example}{Principled Material example}. |
27 | |
28 | \section1 Metal/Roughness workflow |
29 | |
30 | The Principled material is what's known as a metal/roughness material, in essence |
31 | that means the main characteristics of the material is controlled through |
32 | the \l {PrincipledMaterial::metalnessMap} {metallness}, \l {PrincipledMaterial::roughnessMap} {roughness}, |
33 | and the \l {PrincipledMaterial::baseColorMap} {base color} property. |
34 | |
35 | \section2 Metalness |
36 | |
37 | Real world materials are put into two main categories, metals and dielectrics (non-metals). |
38 | In the Principled material, the category a material belongs to is decided by the |
39 | \c metalness value. Setting the \c metalness value to 0, means the material is a dialectric, |
40 | while everything above 0 is a considered to be a metal. In reality metals will have |
41 | a \c metalness value of 1, but values between 0 and 1 are possible, and usually used |
42 | for metals with reduced reflectance. For example, to render corrosion, or similar, |
43 | on a material, the \c metalness of the material should be reduced to give the output |
44 | properties more similar to a dielectric material. |
45 | Since the \c metalness value affects the reflectance of the material it might be tempting to |
46 | use the metalness to adjust glossiness, but consider what type of material you want |
47 | to describe first. Increasing the \c metalness value to give a dielectric material |
48 | a more polished look, will introduce properties that are not accurate for a dielectric |
49 | material, so consider if it would be more appropriate to adjust, for example, |
50 | the \c roughness value instead. |
51 | |
52 | \section2 Roughness |
53 | |
54 | The \c roughness of a material describes the condition of an object's surface. |
55 | A low \c roughness value means the object has a smooth surface and therefore be more |
56 | reflective then a material with a higher \c roughness value. |
57 | |
58 | \section2 Base color |
59 | |
60 | The \l {PrincipledMaterial::baseColorMap} {base color} of a metal/roughness material |
61 | contains both the diffuse and the specular data, how much the base color is interpreted |
62 | as one or the other is primarily dictated by the \c metalness value. For example, |
63 | a material with a metalness value of 1, will have most of its base color interpreted |
64 | as specular color, while the diffuse color would be a black tint. The opposite would |
65 | happen for a material with a metalness value of 0. This is of course a bit simplified, |
66 | but gives a rough idea how the \l {PrincipledMaterial::baseColor} {base color} and |
67 | \c metalness value interacts. For those more familiar with a Specular/Glossiness workflow, |
68 | there's a clear difference here which is worth noting, namely that the color data of the |
69 | two materials are not directly compatible, since in a Specular/Glossiness |
70 | \l {DefaultMaterial} {material}, the diffuse and specular color comes from separate inputs. |
71 | */ |
72 | |
73 | /*! |
74 | \qmlproperty enumeration PrincipledMaterial::lighting |
75 | |
76 | This property defines which lighting method is used when generating this |
77 | material. |
78 | |
79 | The default value is \c PrincipledMaterial.FragmentLighting |
80 | |
81 | When using \c PrincipledMaterial.FragmentLighting, diffuse and specular lighting is |
82 | calculated for each rendered pixel. Certain effects (such as a Fresnel or normal map) require |
83 | \c PrincipledMaterial.FragmentLighting to work. |
84 | |
85 | When using \c PrincipledMaterial.NoLighting no lighting is calculated. This |
86 | mode is (predictably) very fast, and is quite effective when image maps are |
87 | used that you do not need to be shaded by lighting. All other shading |
88 | properties except baseColor values, alpha values, and vertex colors will be |
89 | ignored. |
90 | |
91 | \value PrincipledMaterial.NoLighting |
92 | \value PrincipledMaterial.FragmentLighting |
93 | */ |
94 | |
95 | /*! |
96 | \qmlproperty enumeration PrincipledMaterial::blendMode |
97 | |
98 | This property determines how the colors of the model rendered blends with |
99 | those behind it. |
100 | |
101 | \value PrincipledMaterial.SourceOver Default blend mode. Opaque objects |
102 | occlude objects behind them. This default mode does not guarantee alpha |
103 | blending in the rendering pipeline on its own for models that use this |
104 | material, but rather makes the decision dependent on a number of factors: |
105 | if the object's and material's total opacity is \c{1.0}, there is no |
106 | opacity map in the material, and \l alphaMode is not set to a value that |
107 | enforces alpha blending, then the model is treated as opaque, meaning it is |
108 | rendered with depth testing and depth write enabled, together with other |
109 | opaque objects, with blending disabled. Otherwise the model is treated as |
110 | semi-transparent, and is rendered after the opaque objects, together with |
111 | other semi-transparent objects in a back-to-front order based on their |
112 | center's distance from the camera, with alpha blending enabled. |
113 | |
114 | \value PrincipledMaterial.Screen Colors are blended using an inverted |
115 | multiply, producing a lighter result. This blend mode is order-independent; |
116 | if you are using semi-opaque objects and experiencing 'popping' as faces or |
117 | models sort differently, using Screen blending is one way to produce |
118 | results without popping. |
119 | |
120 | \value PrincipledMaterial.Multiply Colors are blended using a multiply, |
121 | producing a darker result. This blend mode is also order-independent. |
122 | |
123 | \sa alphaMode, {Qt Quick 3D Architecture} |
124 | */ |
125 | |
126 | /*! |
127 | \qmlproperty color PrincipledMaterial::baseColor |
128 | |
129 | This property sets the base color for the material. Depending on the type |
130 | of material specified (metal or dielectric) the diffuse and specular channels will be |
131 | set appropriately. For example, a dielectric material will have a diffuse color equal to |
132 | the base color, while it's specular color, depending on the specular amount, will have a |
133 | bright specular color. For metals the diffuse and specular channels will be mixed from |
134 | the base color and have a dark diffuse channel and a specular channel close to the base color. |
135 | |
136 | \sa baseColorMap, alphaMode |
137 | */ |
138 | |
139 | /*! |
140 | \qmlproperty Texture PrincipledMaterial::baseColorMap |
141 | |
142 | This property defines the texture used to set the base color of the material. |
143 | |
144 | \sa baseColor, alphaMode |
145 | */ |
146 | |
147 | /*! |
148 | \qmlproperty bool PrincipledMaterial::baseColorSingleChannelEnabled |
149 | \since 6.8 |
150 | |
151 | When this property is enabled, the material will use the single value of the baseColorChannel from |
152 | the baseColorMap as RGB value and use 1.0 as alpha value. |
153 | The default value is false. |
154 | */ |
155 | |
156 | /*! |
157 | \qmlproperty enumeration PrincipledMaterial::baseColorChannel |
158 | \since 6.8 |
159 | |
160 | This property defines the texture channel used to read the baseColor value from baseColorMap. |
161 | In order to use a single texture channel as color you have to enable the baseColorSingleChannelEnabled |
162 | The default value is \c Material.R. |
163 | |
164 | \value Material.R Read value from texture R channel. |
165 | \value Material.G Read value from texture G channel. |
166 | \value Material.B Read value from texture B channel. |
167 | \value Material.A Read value from texture A channel. |
168 | */ |
169 | |
170 | /*! |
171 | \qmlproperty real PrincipledMaterial::metalness |
172 | |
173 | The metalness property defines the \e metalness of the the material. The value |
174 | is normalized, where 0.0 means the material is a \e dielectric (non-metallic) material and |
175 | a value of 1.0 means the material is a metal. |
176 | |
177 | \note In principle, materials are either dielectrics with a metalness of 0, or metals with a |
178 | metalness of 1. Metalness values between 0 and 1 are still allowed and will give a material that |
179 | is a blend between the different models. |
180 | |
181 | The range is [0.0, 1.0]. The default value is 0. |
182 | */ |
183 | |
184 | /*! |
185 | \qmlproperty Texture PrincipledMaterial::metalnessMap |
186 | |
187 | This property sets a Texture to be used to set the metalness amount for the |
188 | different parts of the material. |
189 | */ |
190 | |
191 | /*! |
192 | \qmlproperty enumeration PrincipledMaterial::metalnessChannel |
193 | |
194 | This property defines the texture channel used to read the metalness value from metalnessMap. |
195 | The default value is \c Material.B. |
196 | |
197 | \value Material.R Read value from texture R channel. |
198 | \value Material.G Read value from texture G channel. |
199 | \value Material.B Read value from texture B channel. |
200 | \value Material.A Read value from texture A channel. |
201 | */ |
202 | |
203 | /*! |
204 | \qmlproperty bool PrincipledMaterial::emissiveSingleChannelEnabled |
205 | \since 6.8 |
206 | |
207 | When this property is enabled, the material will use the single value of the emissiveChannel from |
208 | the emissiveMap as RGB value. |
209 | The default value is false. |
210 | */ |
211 | |
212 | /*! |
213 | \qmlproperty enumeration PrincipledMaterial::emissiveChannel |
214 | \since 6.8 |
215 | |
216 | This property defines the texture channel used to read the emissive value from emissiveMap. |
217 | In order to use a single texture channel as color you have to enable the emissiveSingleChannelEnabled |
218 | The default value is \c Material.R. |
219 | |
220 | \value Material.R Read value from texture R channel. |
221 | \value Material.G Read value from texture G channel. |
222 | \value Material.B Read value from texture B channel. |
223 | \value Material.A Read value from texture A channel. |
224 | */ |
225 | |
226 | /*! |
227 | \qmlproperty Texture PrincipledMaterial::emissiveMap |
228 | |
229 | This property sets a RGB Texture to be used to specify the intensity of the |
230 | emissive color. |
231 | */ |
232 | |
233 | /*! |
234 | \qmlproperty vector3d PrincipledMaterial::emissiveFactor |
235 | |
236 | This property determines the color of self-illumination for this material. |
237 | If an emissive map is set, the x, y, and z components are used as factors |
238 | (multipliers) for the R, G and B channels of the texture, respectively. |
239 | The default value is (0, 0, 0) and it means no emissive contribution at all. |
240 | |
241 | \note Setting the lightingMode to DefaultMaterial.NoLighting means emissive |
242 | Factor does not have an effect on the scene. |
243 | */ |
244 | |
245 | /*! |
246 | \qmlproperty Texture PrincipledMaterial::specularReflectionMap |
247 | |
248 | This property sets a Texture used for specular highlights on the material. |
249 | |
250 | This is typically used to perform environment mapping: as the model is |
251 | rotated, the map will appear as though it is reflecting from the |
252 | environment. For this to work as expected, the Texture's |
253 | \l{Texture::mappingMode}{mappingMode} needs to be set to |
254 | Texture.Environment. Specular reflection maps are an easy way to add a |
255 | high-quality look with a relatively low cost. |
256 | |
257 | \note Associating a \l{SceneEnvironment::lightProbe}{light probe} with the |
258 | \l SceneEnvironment, and thus relying on image-based lighting, can achieve |
259 | similar environmental reflection effects. Light probes are however a |
260 | conceptually different, and when it comes to performance, potentially more |
261 | expensive solution. Each approaches have their own specific uses, and the |
262 | one to use needs to be decided on a case by case basis. When it comes to |
263 | the Texture set to the property, specularReflectionMap has an advantage, |
264 | because it presents no limitations and supports all types of textures, |
265 | including ones that source their data from a Qt Quick sub-scene via |
266 | \l{Texture::sourceItem}{sourceItem}. |
267 | |
268 | \note Crisp images cause your material to look very glossy; the more you |
269 | blur your image the softer your material will appear. |
270 | |
271 | \sa Texture::mappingMode |
272 | */ |
273 | |
274 | /*! |
275 | \qmlproperty Texture PrincipledMaterial::specularMap |
276 | |
277 | The property defines a RGB Texture to modulate the amount and the color of |
278 | specularity across the surface of the material. These values are multiplied |
279 | by the specularAmount. |
280 | |
281 | \note The specular map will be ignored unless the material is dielectric. |
282 | */ |
283 | |
284 | /*! |
285 | \qmlproperty bool PrincipledMaterial::specularSingleChannelEnabled |
286 | \since 6.8 |
287 | |
288 | When this property is enabled, the material will use the single value of the specularChannel from |
289 | the specularMap as RGB value. |
290 | The default value is false. |
291 | */ |
292 | |
293 | /*! |
294 | \qmlproperty enumeration PrincipledMaterial::specularChannel |
295 | \since 6.8 |
296 | |
297 | This property defines the texture channel used to read the specular color value from specularMap. |
298 | In order to use a single texture channel as color you have to enable the specularSingleChannelEnabled |
299 | The default value is \c Material.R. |
300 | |
301 | \value Material.R Read value from texture R channel. |
302 | \value Material.G Read value from texture G channel. |
303 | \value Material.B Read value from texture B channel. |
304 | \value Material.A Read value from texture A channel. |
305 | */ |
306 | |
307 | /*! |
308 | \qmlproperty real PrincipledMaterial::specularTint |
309 | |
310 | This property defines how much of the base color contributes to the specular reflections. |
311 | |
312 | \note This property does only apply to dielectric materials. |
313 | */ |
314 | |
315 | /*! |
316 | \qmlproperty real PrincipledMaterial::specularAmount |
317 | |
318 | This property controls the strength of specularity (highlights and |
319 | reflections). |
320 | |
321 | The range is [0.0, 1.0]. The default value is \c 1.0. |
322 | |
323 | \note For non-dielectrics (metals) this property has no effect. |
324 | |
325 | \note This property does not affect the specularReflectionMap, but does affect the amount of |
326 | reflections from a scenes SceneEnvironment::lightProbe. |
327 | */ |
328 | |
329 | /*! |
330 | \qmlproperty real PrincipledMaterial::roughness |
331 | |
332 | This property controls the size of the specular highlight generated from |
333 | lights, and the clarity of reflections in general. Larger values increase |
334 | the roughness, softening specular highlights and blurring reflections. |
335 | The range is [0.0, 1.0]. The default value is 0. |
336 | */ |
337 | |
338 | /*! |
339 | \qmlproperty Texture PrincipledMaterial::roughnessMap |
340 | |
341 | This property defines a Texture to control the specular roughness of the |
342 | material. |
343 | */ |
344 | |
345 | /*! |
346 | \qmlproperty enumeration PrincipledMaterial::roughnessChannel |
347 | |
348 | This property defines the texture channel used to read the roughness value from roughnessMap. |
349 | The default value is \c Material.G. |
350 | |
351 | \value Material.R Read value from texture R channel. |
352 | \value Material.G Read value from texture G channel. |
353 | \value Material.B Read value from texture B channel. |
354 | \value Material.A Read value from texture A channel. |
355 | */ |
356 | |
357 | /*! |
358 | \qmlproperty real PrincipledMaterial::opacity |
359 | |
360 | This property drops the opacity of just this material, separate from the |
361 | model. |
362 | */ |
363 | |
364 | /*! |
365 | \qmlproperty Texture PrincipledMaterial::opacityMap |
366 | |
367 | This property defines a Texture used to control the opacity differently for |
368 | different parts of the material. |
369 | */ |
370 | |
371 | /*! |
372 | \qmlproperty real PrincipledMaterial::invertOpacityMapValue |
373 | \since 6.8 |
374 | |
375 | This property inverts the opacity value of the opacityMap. |
376 | The default value is \c false. |
377 | */ |
378 | |
379 | /*! |
380 | \qmlproperty enumeration PrincipledMaterial::opacityChannel |
381 | |
382 | This property defines the texture channel used to read the opacity value from opacityMap. |
383 | The default value is \c Material.A. |
384 | |
385 | \value Material.R Read value from texture R channel. |
386 | \value Material.G Read value from texture G channel. |
387 | \value Material.B Read value from texture B channel. |
388 | \value Material.A Read value from texture A channel. |
389 | */ |
390 | |
391 | /*! |
392 | \qmlproperty Texture PrincipledMaterial::normalMap |
393 | |
394 | This property defines an RGB image used to simulate fine geometry |
395 | displacement across the surface of the material. The RGB channels indicate |
396 | XYZ normal deviations. |
397 | |
398 | \note Normal maps will not affect the silhouette of a model. |
399 | */ |
400 | |
401 | /*! |
402 | \qmlproperty real PrincipledMaterial::normalStrength |
403 | |
404 | This property controls the amount of simulated displacement for the normalMap. |
405 | */ |
406 | |
407 | /*! |
408 | \qmlproperty real PrincipledMaterial::occlusionAmount |
409 | |
410 | This property contains the factor used to modify the values from the \l occlusionMap texture. |
411 | The value should be between 0.0 to 1.0. The default is 1.0 |
412 | */ |
413 | |
414 | /*! |
415 | \qmlproperty Texture PrincipledMaterial::occlusionMap |
416 | |
417 | This property defines a texture used to determine how much light the |
418 | different areas of the material should receive. Values are expected to be |
419 | linear from 0.0 to 1.0, where 0.0 means no lighting and 1.0 means the |
420 | effect of the lighting is left unchanged. |
421 | |
422 | \sa occlusionAmount |
423 | */ |
424 | |
425 | /*! |
426 | \qmlproperty enumeration PrincipledMaterial::occlusionChannel |
427 | |
428 | This property defines the texture channel used to read the occlusion value from occlusionMap. |
429 | The default value is \c Material.R. |
430 | |
431 | \value Material.R Read value from texture R channel. |
432 | \value Material.G Read value from texture G channel. |
433 | \value Material.B Read value from texture B channel. |
434 | \value Material.A Read value from texture A channel. |
435 | */ |
436 | |
437 | /*! |
438 | \qmlproperty enumeration PrincipledMaterial::alphaMode |
439 | |
440 | This property specifies how the alpha color value from \l baseColor and the |
441 | alpha channel of a \l{baseColorMap}{base color map} are used. |
442 | |
443 | \note The alpha cutoff test only considers the base color alpha. \l opacity |
444 | and \l [QtQuick3D] {Node::opacity} are not taken into account there. |
445 | |
446 | \note When sampling a base color map, the effective alpha value is the |
447 | sampled alpha multiplied by the \l baseColor alpha. |
448 | |
449 | \value PrincipledMaterial.Default No test is applied, the effective alpha |
450 | value is passed on as-is. Note that a \l baseColor or \l baseColorMap alpha |
451 | less than \c 1.0 does not automatically imply alpha blending, the object |
452 | with the material may still be treated as opaque, if no other relevant |
453 | properties (such as, an opacity less than 1, the presence of an opacity |
454 | map, or a non-default \l blendMode value) trigger treating the object as |
455 | semi-transparent. To ensure alpha blending happens regardless of any other |
456 | object or material property, set \c Blend instead. |
457 | |
458 | \value PrincipledMaterial.Blend No cutoff test is applied, but guarantees |
459 | that alpha blending happens. The object with this material will therefore |
460 | never be treated as opaque by the renderer. |
461 | |
462 | \value PrincipledMaterial.Opaque No cutoff test is applied and the rendered |
463 | object is assumed to be fully opaque, meaning the alpha values in the |
464 | vertex color, base color, and base color map are ignored and a value of 1.0 |
465 | is substituted instead. This mode does not guarantee alpha blending does |
466 | not happen. If relevant properties (such as, an opacity less than 1, an |
467 | opacity map, or a non-default \l blendMode) say so, then the object will |
468 | still be treated as semi-transparent by the rendering pipeline, just like |
469 | with the \c Default alphaMode. |
470 | |
471 | \value PrincipledMaterial.Mask A test based on \l alphaCutoff is applied. |
472 | If the effective alpha value falls below \l alphaCutoff, the fragment is |
473 | changed to fully transparent and is discarded (with all implications of |
474 | discarding: the depth buffer is not written for that fragment). Otherwise |
475 | the alpha is changed to 1.0, so that the fragment will become fully opaque. |
476 | When it comes to alpha blending, the behavior of this mode is identical to |
477 | \c Opaque, regardless of the cutoff test's result. This means that the |
478 | \l{https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#alpha-coverage}{glTF |
479 | 2 spec's alpha coverage} Implementation Notes are fulfilled. Objects with |
480 | alpha cutoff tests can also cast shadows since they behave like opaque |
481 | objects by default, unless the relevant properties (such as, an opacity |
482 | less than 1, an opacity map, or a non-default \l blendMode) imply otherwise |
483 | (in which case casting shadows will not be possible). |
484 | |
485 | \sa alphaCutoff, blendMode |
486 | */ |
487 | |
488 | /*! |
489 | \qmlproperty real PrincipledMaterial::alphaCutoff |
490 | |
491 | The alphaCutoff property can be used to specify the cutoff value when using |
492 | the \l{alphaMode}{Mask alphaMode}. Fragments where the alpha value falls |
493 | below the threshold will be rendered fully transparent (\c{0.0} for all |
494 | color channels). When the alpha value is equal or greater than the cutoff |
495 | value, the color will not be affected in any way. |
496 | |
497 | The default value is 0.5. |
498 | |
499 | \sa alphaMode |
500 | */ |
501 | |
502 | /*! |
503 | \qmlproperty real PrincipledMaterial::pointSize |
504 | |
505 | This property determines the size of the points rendered, when the geometry |
506 | is using a primitive type of points. The default value is 1.0. This |
507 | property is not relevant when rendering other types of geometry, such as, |
508 | triangle meshes. |
509 | |
510 | \warning Point sizes other than 1 may not be supported at run time, |
511 | depending on the underyling graphics API. For example, setting a size other |
512 | than 1 has no effect with Direct 3D. |
513 | */ |
514 | |
515 | /*! |
516 | \qmlproperty real PrincipledMaterial::lineWidth |
517 | |
518 | This property determines the width of the lines rendered, when the geometry |
519 | is using a primitive type of lines or line strips. The default value is |
520 | 1.0. This property is not relevant when rendering other types of geometry, |
521 | such as, triangle meshes. |
522 | |
523 | \warning Line widths other than 1 may not be suported at run time, |
524 | depending on the underlying graphics API. When that is the case, the |
525 | request to change the width is ignored. For example, none of the following |
526 | can be expected to support wide lines: Direct3D, Metal, OpenGL with core |
527 | profile contexts. |
528 | */ |
529 | |
530 | /*! |
531 | \qmlproperty Texture PrincipledMaterial::heightMap |
532 | |
533 | This property defines a texture used to determine the height the texture |
534 | will be displaced when rendered through the use of Parallax Mapping. Values |
535 | are expected to be linear from 0.0 to 1.0, where 0.0 means no displacement |
536 | and 1.0 means means maximum displacement. |
537 | |
538 | */ |
539 | |
540 | /*! |
541 | \qmlproperty enumeration PrincipledMaterial::heightChannel |
542 | |
543 | This property defines the texture channel used to read the height value |
544 | from heightMap. The default value is \c Material.R. |
545 | |
546 | \value Material.R Read value from texture R channel. |
547 | \value Material.G Read value from texture G channel. |
548 | \value Material.B Read value from texture B channel. |
549 | \value Material.A Read value from texture A channel. |
550 | |
551 | */ |
552 | |
553 | /*! |
554 | \qmlproperty real PrincipledMaterial::heightAmount |
555 | |
556 | This property contains the factor used to modify the values from the |
557 | \l heightMap texture. The value should be between 0.0 to 1.0. The default |
558 | value is 0.0 which means that height displacement will be disabled, even |
559 | if a height map set. |
560 | */ |
561 | |
562 | /*! |
563 | \qmlproperty int PrincipledMaterial::minHeightMapSamples |
564 | |
565 | This property defines the minimum number of samples used for performing |
566 | Parallex Occlusion Mapping using the \l heightMap. The minHeightMapSamples |
567 | value is the number of samples of the heightMap are used when looking directly |
568 | at a surface (when the camera view is perpendicular to the fragment). |
569 | The default value is 8. |
570 | |
571 | The actual number of samples used for each fragment will be between |
572 | \l minHeightMapSamples and \l maxHeightMapSamples depending on the angle of |
573 | the camera relative to the surface being rendered. |
574 | |
575 | \note This value should only be adjusted to fine tune materials using a |
576 | \l heightMap in the case undesired artifacts are present. |
577 | */ |
578 | |
579 | /*! |
580 | \qmlproperty int PrincipledMaterial::maxHeightMapSamples |
581 | |
582 | This property defines the maximum number of samples used for performing |
583 | Parallex Occlusion Mapping using the \l heightMap. The maxHeightMapSamples |
584 | value is the number of samples of the heightMap are used when looking |
585 | parallel to a surface. |
586 | The default value is 32. |
587 | |
588 | The actual number of samples used for each fragment will be between |
589 | \l minHeightMapSamples and \l maxHeightMapSamples depending on the angle of |
590 | the camera relative to the surface being rendered. |
591 | |
592 | \note This value should only be adjusted to fine tune materials using a |
593 | \l heightMap in the case undesired artifacts are present. |
594 | */ |
595 | |
596 | /*! |
597 | \qmlproperty float PrincipledMaterial::clearcoatAmount |
598 | |
599 | This property defines the intensity of the clearcoat layer. |
600 | |
601 | The default value is \c 0.0 |
602 | */ |
603 | |
604 | /*! |
605 | \qmlproperty Texture PrincipledMaterial::clearcoatMap |
606 | |
607 | This property defines a texture used to determine the intensity of the |
608 | clearcoat layer. The value of\l clearcoatAmount will be multiplied by |
609 | the value read from this texture. |
610 | |
611 | */ |
612 | |
613 | /*! |
614 | \qmlproperty enumeration PrincipledMaterial::clearcoatChannel |
615 | |
616 | This property defines the texture channel used to read the clearcoat amount |
617 | value from \l clearcoatMap. The default value is \c Material.R. |
618 | |
619 | \value Material.R Read value from texture R channel. |
620 | \value Material.G Read value from texture G channel. |
621 | \value Material.B Read value from texture B channel. |
622 | \value Material.A Read value from texture A channel. |
623 | |
624 | */ |
625 | |
626 | /*! |
627 | \qmlproperty float PrincipledMaterial::clearcoatRoughnessAmount |
628 | |
629 | This property defines the roughness of the clearcoat layer. |
630 | The default value is \c 0.0 |
631 | */ |
632 | |
633 | /*! |
634 | \qmlproperty Texture PrincipledMaterial::clearcoatRoughnessMap |
635 | |
636 | This property defines a texture used to determine the roughness of the |
637 | clearcoat layer. The value of\l clearcoatRoughnessAmount will be |
638 | multiplied by the value read from this texture. |
639 | |
640 | */ |
641 | |
642 | /*! |
643 | \qmlproperty enumeration PrincipledMaterial::clearcoatRoughnessChannel |
644 | |
645 | This property defines the texture channel used to read the clearcoat |
646 | roughness amount from \l clearcoatRoughnessMap. |
647 | The default value is \c Material.G. |
648 | |
649 | \value Material.R Read value from texture R channel. |
650 | \value Material.G Read value from texture G channel. |
651 | \value Material.B Read value from texture B channel. |
652 | \value Material.A Read value from texture A channel. |
653 | |
654 | */ |
655 | |
656 | /*! |
657 | \qmlproperty Texture PrincipledMaterial::clearcoatNormalMap |
658 | |
659 | This property defines a texture used to determine the normal mapping |
660 | applied to the clearcoat layer. |
661 | |
662 | */ |
663 | |
664 | |
665 | /*! |
666 | \qmlproperty real PrincipledMaterial::clearcoatNormalStrength |
667 | |
668 | This property controls the amount of simulated displacement for the clearcoatNormalMap. |
669 | */ |
670 | |
671 | /*! |
672 | \qmlproperty float PrincipledMaterial::transmissionFactor |
673 | |
674 | This property defines the percentage of light that is transmitted through |
675 | the material's surface. |
676 | The default value is \c 0.0 |
677 | */ |
678 | |
679 | /*! |
680 | \qmlproperty Texture PrincipledMaterial::transmissionMap |
681 | |
682 | This property defines a texture used to determine percentage of light that |
683 | is transmitted through the surface.. The value of |
684 | \l transmissionFactor will be multiplied by the value read from this |
685 | texture. |
686 | |
687 | */ |
688 | |
689 | /*! |
690 | \qmlproperty enumeration PrincipledMaterial::transmissionChannel |
691 | |
692 | This property defines the texture channel used to read the transmission |
693 | percentage from \l transmissionMap. |
694 | The default value is \c Material.R. |
695 | |
696 | \value Material.R Read value from texture R channel. |
697 | \value Material.G Read value from texture G channel. |
698 | \value Material.B Read value from texture B channel. |
699 | \value Material.A Read value from texture A channel. |
700 | |
701 | */ |
702 | |
703 | /*! |
704 | \qmlproperty float PrincipledMaterial::thicknessFactor |
705 | |
706 | This property defines the thickness of the volume beneath the surface. |
707 | Unlike many other properties of PrincipledMaterial, the value in defined |
708 | in thicknessFactor is a value from 0.0 to +infinity for thickness in the |
709 | models coordinate space. A value of 0.0 means that the material is |
710 | thin-walled. |
711 | The default value is \c 0.0 |
712 | */ |
713 | |
714 | /*! |
715 | \qmlproperty Texture PrincipledMaterial::thicknessMap |
716 | |
717 | This property defines a texture used to define the thickness of a |
718 | material volume. The value of \l thicknessFactor will be multiplied by the |
719 | value read from this texture. |
720 | |
721 | */ |
722 | |
723 | /*! |
724 | \qmlproperty enumeration PrincipledMaterial::thicknessChannel |
725 | |
726 | This property defines the texture channel used to read the thickness |
727 | amount from \l transmissionMap. |
728 | The default value is \c Material.G. |
729 | |
730 | \value Material.R Read value from texture R channel. |
731 | \value Material.G Read value from texture G channel. |
732 | \value Material.B Read value from texture B channel. |
733 | \value Material.A Read value from texture A channel. |
734 | |
735 | */ |
736 | |
737 | /*! |
738 | \qmlproperty float PrincipledMaterial::attenuationDistance |
739 | |
740 | This property defines the Density of the medium given as the average |
741 | distance that light travels in the medium before interacting with a |
742 | particle. The value is given in world space. |
743 | The default value is \c +infinity. |
744 | */ |
745 | |
746 | /*! |
747 | \qmlproperty color PrincipledMaterial::attenuationColor |
748 | |
749 | This property defines the color that white lights turns into due to |
750 | absorption when reaching the attenuation distance. |
751 | The default value is \c Qt.White |
752 | |
753 | */ |
754 | |
755 | /*! |
756 | \qmlproperty real PrincipledMaterial::indexOfRefraction |
757 | |
758 | This property defines the index of refraction of the material. The default |
759 | value of \c 1.5 will be the ideal value for materials like plastics or glass |
760 | but other materials like water, asphalt, sapphire, or diamond would require |
761 | and adjusted value to look more realistic. For realistic materials the |
762 | indexOfRefraction should usually be between \c 1.0 and \c 3.0 |
763 | |
764 | Some examples of common materials' index of refractions are: |
765 | |
766 | \table |
767 | \header |
768 | \li Material |
769 | \li Index of Refraction |
770 | \row |
771 | \li Air |
772 | \li 1.0 |
773 | \row |
774 | \li Water |
775 | \li 1.33 |
776 | \row |
777 | \li Glass |
778 | \li 1.55 |
779 | \row |
780 | \li Sapphire |
781 | \li 1.76 |
782 | \row |
783 | \li Diamond |
784 | \li 2.42 |
785 | \endtable |
786 | |
787 | \note No known material in the world have ior much greater than \c 3.0. |
788 | */ |
789 | |
790 | /*! |
791 | \qmlproperty real PrincipledMaterial::fresnelScaleBiasEnabled |
792 | |
793 | By Setting the value to true the material will take Fresnel Scale and Fresnel Bias into account. |
794 | The default value is \c false. |
795 | */ |
796 | |
797 | /*! |
798 | \qmlproperty real PrincipledMaterial::fresnelScale |
799 | |
800 | This property scale head-on reflections (looking directly at the |
801 | surface) while maintaining reflections seen at grazing angles. |
802 | In order to affect changes to the material you have to enable fresnelScaleBiasEnabled. |
803 | The default value is \c 1.0. |
804 | */ |
805 | |
806 | /*! |
807 | \qmlproperty real PrincipledMaterial::fresnelBias |
808 | |
809 | This property push forward head-on reflections (looking directly at the |
810 | surface) while maintaining reflections seen at grazing angles. |
811 | In order to affect changes to the material you have to enable fresnelScaleBiasEnabled. |
812 | The default value is \c 0.0. |
813 | */ |
814 | |
815 | /*! |
816 | \qmlproperty real PrincipledMaterial::fresnelPower |
817 | |
818 | This property decreases head-on reflections (looking directly at the |
819 | surface) while maintaining reflections seen at grazing angles. |
820 | The default value is \c 5.0. |
821 | */ |
822 | |
823 | /*! |
824 | \qmlproperty real PrincipledMaterial::clearcoatFresnelScaleBiasEnabled |
825 | |
826 | By Setting the value to true the material will take Clearcoat Fresnel Scale and Clearcoat Fresnel Bias into account. |
827 | The default value is \c false. |
828 | */ |
829 | |
830 | /*! |
831 | \qmlproperty real PrincipledMaterial::clearcoatFresnelScale |
832 | |
833 | This property scale head-on reflections (looking directly at the |
834 | surface) while maintaining reflections seen at grazing angles. |
835 | In order to affect changes to the material you have to enable clearcoatFresnelScaleBiasEnabled. |
836 | The default value is \c 1.0. |
837 | */ |
838 | |
839 | /*! |
840 | \qmlproperty real PrincipledMaterial::clearcoatFresnelBias |
841 | |
842 | This property push forward head-on reflections (looking directly at the |
843 | surface) while maintaining reflections seen at grazing angles. |
844 | In order to affect changes to the material you have to enable clearcoatFresnelScaleBiasEnabled. |
845 | The default value is \c 0.0. |
846 | */ |
847 | |
848 | /*! |
849 | \qmlproperty real PrincipledMaterial::clearcoatFresnelPower |
850 | |
851 | This property decreases head-on reflections (looking directly at the |
852 | surface) while maintaining reflections seen at grazing angles. |
853 | The default value is \c 5.0. |
854 | */ |
855 | |
856 | /*! |
857 | \qmlproperty bool PrincipledMaterial::vertexColorsEnabled |
858 | \since 6.5 |
859 | |
860 | When this property is enabled, the material will use vertex colors from the |
861 | mesh. These will be multiplied by any other colors specified for the |
862 | material. The default value is true. |
863 | */ |
864 | |
865 | /*! |
866 | \qmlproperty bool PrincipledMaterial::vertexColorsMaskEnabled |
867 | \since 6.8 |
868 | |
869 | When this property is enabled, the material will use vertex colors from the |
870 | mesh as mask of various properties e.g RoughnessAmount, SpecularAmount, ... . |
871 | The default value is false. |
872 | */ |
873 | |
874 | /*! |
875 | \qmlproperty enumeration PrincipledMaterial::vertexColorRedMask |
876 | \since 6.8 |
877 | |
878 | This property defines the vertex color red channel used as the specifies mask. |
879 | The value is a bit-wise combination of flags. |
880 | The default value is \c PrincipledMaterial.NoMask. |
881 | |
882 | \value PrincipledMaterial.NoMask. |
883 | \value PrincipledMaterial.ClearcoatAmountMask. |
884 | \value PrincipledMaterial.ClearcoatRoughnessAmountMask. |
885 | \value PrincipledMaterial.ClearcoatNormalStrengthMask. |
886 | \value PrincipledMaterial.HeightAmountMask. |
887 | \value PrincipledMaterial.MetalnessMask. |
888 | \value PrincipledMaterial.RoughnessMask. |
889 | \value PrincipledMaterial.NormalStrengthMask. |
890 | \value PrincipledMaterial.OcclusionAmountMask. |
891 | \value PrincipledMaterial.SpecularAmountMask. |
892 | \value PrincipledMaterial.ThicknessFactorMask. |
893 | \value PrincipledMaterial.TransmissionFactorMask. |
894 | */ |
895 | |
896 | /*! |
897 | \qmlproperty enumeration PrincipledMaterial::vertexColorGreenMask |
898 | \since 6.8 |
899 | |
900 | This property defines the vertex color green channel used as the specifies mask. |
901 | The value is a bit-wise combination of flags. |
902 | The default value is \c PrincipledMaterial.NoMask. |
903 | |
904 | \value PrincipledMaterial.NoMask. |
905 | \value PrincipledMaterial.ClearcoatAmountMask. |
906 | \value PrincipledMaterial.ClearcoatRoughnessAmountMask. |
907 | \value PrincipledMaterial.ClearcoatNormalStrengthMask. |
908 | \value PrincipledMaterial.HeightAmountMask. |
909 | \value PrincipledMaterial.MetalnessMask. |
910 | \value PrincipledMaterial.RoughnessMask. |
911 | \value PrincipledMaterial.NormalStrengthMask. |
912 | \value PrincipledMaterial.OcclusionAmountMask. |
913 | \value PrincipledMaterial.SpecularAmountMask. |
914 | \value PrincipledMaterial.ThicknessFactorMask. |
915 | \value PrincipledMaterial.TransmissionFactorMask. |
916 | */ |
917 | |
918 | /*! |
919 | \qmlproperty enumeration PrincipledMaterial::vertexColorBlueMask |
920 | \since 6.8 |
921 | |
922 | This property defines the vertex color blue channel used as the specifies mask. |
923 | The value is a bit-wise combination of flags. |
924 | The default value is \c PrincipledMaterial.NoMask. |
925 | |
926 | \value PrincipledMaterial.NoMask. |
927 | \value PrincipledMaterial.ClearcoatAmountMask. |
928 | \value PrincipledMaterial.ClearcoatRoughnessAmountMask. |
929 | \value PrincipledMaterial.ClearcoatNormalStrengthMask. |
930 | \value PrincipledMaterial.HeightAmountMask. |
931 | \value PrincipledMaterial.MetalnessMask. |
932 | \value PrincipledMaterial.RoughnessMask. |
933 | \value PrincipledMaterial.NormalStrengthMask. |
934 | \value PrincipledMaterial.OcclusionAmountMask. |
935 | \value PrincipledMaterial.SpecularAmountMask. |
936 | \value PrincipledMaterial.ThicknessFactorMask. |
937 | \value PrincipledMaterial.TransmissionFactorMask. |
938 | */ |
939 | |
940 | /*! |
941 | \qmlproperty enumeration PrincipledMaterial::vertexColorAlphaMask |
942 | \since 6.8 |
943 | |
944 | This property defines the vertex color alpha channel used as the specifies mask. |
945 | The value is a bit-wise combination of flags. |
946 | The default value is \c PrincipledMaterial.NoMask. |
947 | |
948 | \value PrincipledMaterial.NoMask. |
949 | \value PrincipledMaterial.ClearcoatAmountMask. |
950 | \value PrincipledMaterial.ClearcoatRoughnessAmountMask. |
951 | \value PrincipledMaterial.ClearcoatNormalStrengthMask. |
952 | \value PrincipledMaterial.HeightAmountMask. |
953 | \value PrincipledMaterial.MetalnessMask. |
954 | \value PrincipledMaterial.RoughnessMask. |
955 | \value PrincipledMaterial.NormalStrengthMask. |
956 | \value PrincipledMaterial.OcclusionAmountMask. |
957 | \value PrincipledMaterial.SpecularAmountMask. |
958 | \value PrincipledMaterial.ThicknessFactorMask. |
959 | \value PrincipledMaterial.TransmissionFactorMask. |
960 | */ |
961 | |
962 | QQuick3DPrincipledMaterial::QQuick3DPrincipledMaterial(QQuick3DObject *parent) |
963 | : QQuick3DMaterial(*(new QQuick3DObjectPrivate(QQuick3DObjectPrivate::Type::PrincipledMaterial)), parent) |
964 | {} |
965 | |
966 | QQuick3DPrincipledMaterial::~QQuick3DPrincipledMaterial() |
967 | { |
968 | } |
969 | |
970 | QQuick3DPrincipledMaterial::Lighting QQuick3DPrincipledMaterial::lighting() const |
971 | { |
972 | return m_lighting; |
973 | } |
974 | |
975 | QQuick3DPrincipledMaterial::BlendMode QQuick3DPrincipledMaterial::blendMode() const |
976 | { |
977 | return m_blendMode; |
978 | } |
979 | |
980 | QColor QQuick3DPrincipledMaterial::baseColor() const |
981 | { |
982 | return m_baseColor; |
983 | } |
984 | |
985 | QQuick3DTexture *QQuick3DPrincipledMaterial::baseColorMap() const |
986 | { |
987 | return m_baseColorMap; |
988 | } |
989 | |
990 | bool QQuick3DPrincipledMaterial::baseColorSingleChannelEnabled() const |
991 | { |
992 | return m_baseColorSingleChannelEnabled; |
993 | } |
994 | |
995 | QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::baseColorChannel() const |
996 | { |
997 | return m_baseColorChannel; |
998 | } |
999 | |
1000 | bool QQuick3DPrincipledMaterial::specularSingleChannelEnabled() const |
1001 | { |
1002 | return m_specularSingleChannelEnabled; |
1003 | } |
1004 | |
1005 | QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::specularChannel() const |
1006 | { |
1007 | return m_specularChannel; |
1008 | } |
1009 | |
1010 | bool QQuick3DPrincipledMaterial::emissiveSingleChannelEnabled() const |
1011 | { |
1012 | return m_emissiveSingleChannelEnabled; |
1013 | } |
1014 | |
1015 | QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::emissiveChannel() const |
1016 | { |
1017 | return m_emissiveChannel; |
1018 | } |
1019 | |
1020 | QQuick3DTexture *QQuick3DPrincipledMaterial::emissiveMap() const |
1021 | { |
1022 | return m_emissiveMap; |
1023 | } |
1024 | |
1025 | QVector3D QQuick3DPrincipledMaterial::emissiveFactor() const |
1026 | { |
1027 | return m_emissiveFactor; |
1028 | } |
1029 | |
1030 | QQuick3DTexture *QQuick3DPrincipledMaterial::specularReflectionMap() const |
1031 | { |
1032 | return m_specularReflectionMap; |
1033 | } |
1034 | |
1035 | QQuick3DTexture *QQuick3DPrincipledMaterial::specularMap() const |
1036 | { |
1037 | return m_specularMap; |
1038 | } |
1039 | |
1040 | float QQuick3DPrincipledMaterial::specularTint() const |
1041 | { |
1042 | return m_specularTint; |
1043 | } |
1044 | |
1045 | float QQuick3DPrincipledMaterial::specularAmount() const |
1046 | { |
1047 | return m_specularAmount; |
1048 | } |
1049 | |
1050 | float QQuick3DPrincipledMaterial::roughness() const |
1051 | { |
1052 | return m_roughness; |
1053 | } |
1054 | |
1055 | QQuick3DTexture *QQuick3DPrincipledMaterial::roughnessMap() const |
1056 | { |
1057 | return m_roughnessMap; |
1058 | } |
1059 | |
1060 | bool QQuick3DPrincipledMaterial::invertOpacityMapValue() const |
1061 | { |
1062 | return m_invertOpacityMapValue; |
1063 | } |
1064 | |
1065 | float QQuick3DPrincipledMaterial::opacity() const |
1066 | { |
1067 | return m_opacity; |
1068 | } |
1069 | |
1070 | QQuick3DTexture *QQuick3DPrincipledMaterial::opacityMap() const |
1071 | { |
1072 | return m_opacityMap; |
1073 | } |
1074 | |
1075 | QQuick3DTexture *QQuick3DPrincipledMaterial::normalMap() const |
1076 | { |
1077 | return m_normalMap; |
1078 | } |
1079 | |
1080 | float QQuick3DPrincipledMaterial::metalness() const |
1081 | { |
1082 | return m_metalnessAmount; |
1083 | } |
1084 | |
1085 | QQuick3DTexture *QQuick3DPrincipledMaterial::metalnessMap() const |
1086 | { |
1087 | return m_metalnessMap; |
1088 | } |
1089 | |
1090 | float QQuick3DPrincipledMaterial::normalStrength() const |
1091 | { |
1092 | return m_normalStrength; |
1093 | } |
1094 | |
1095 | QQuick3DTexture *QQuick3DPrincipledMaterial::occlusionMap() const |
1096 | { |
1097 | return m_occlusionMap; |
1098 | } |
1099 | |
1100 | float QQuick3DPrincipledMaterial::occlusionAmount() const |
1101 | { |
1102 | return m_occlusionAmount; |
1103 | } |
1104 | |
1105 | QQuick3DPrincipledMaterial::AlphaMode QQuick3DPrincipledMaterial::alphaMode() const |
1106 | { |
1107 | return m_alphaMode; |
1108 | } |
1109 | |
1110 | float QQuick3DPrincipledMaterial::alphaCutoff() const |
1111 | { |
1112 | return m_alphaCutoff; |
1113 | } |
1114 | |
1115 | QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::roughnessChannel() const |
1116 | { |
1117 | return m_roughnessChannel; |
1118 | } |
1119 | |
1120 | QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::opacityChannel() const |
1121 | { |
1122 | return m_opacityChannel; |
1123 | } |
1124 | |
1125 | QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::metalnessChannel() const |
1126 | { |
1127 | return m_metalnessChannel; |
1128 | } |
1129 | |
1130 | QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::occlusionChannel() const |
1131 | { |
1132 | return m_occlusionChannel; |
1133 | } |
1134 | |
1135 | float QQuick3DPrincipledMaterial::pointSize() const |
1136 | { |
1137 | return m_pointSize; |
1138 | } |
1139 | |
1140 | float QQuick3DPrincipledMaterial::lineWidth() const |
1141 | { |
1142 | return m_lineWidth; |
1143 | } |
1144 | |
1145 | QQuick3DTexture *QQuick3DPrincipledMaterial::heightMap() const |
1146 | { |
1147 | return m_heightMap; |
1148 | } |
1149 | |
1150 | QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::heightChannel() const |
1151 | { |
1152 | return m_heightChannel; |
1153 | } |
1154 | |
1155 | float QQuick3DPrincipledMaterial::heightAmount() const |
1156 | { |
1157 | return m_heightAmount; |
1158 | } |
1159 | |
1160 | int QQuick3DPrincipledMaterial::minHeightMapSamples() const |
1161 | { |
1162 | return m_minHeightMapSamples; |
1163 | } |
1164 | |
1165 | int QQuick3DPrincipledMaterial::maxHeightMapSamples() const |
1166 | { |
1167 | return m_maxHeightMapSamples; |
1168 | } |
1169 | |
1170 | void QQuick3DPrincipledMaterial::markAllDirty() |
1171 | { |
1172 | m_dirtyAttributes = 0xffffffff; |
1173 | QQuick3DMaterial::markAllDirty(); |
1174 | } |
1175 | |
1176 | void QQuick3DPrincipledMaterial::setLighting(QQuick3DPrincipledMaterial::Lighting lighting) |
1177 | { |
1178 | if (m_lighting == lighting) |
1179 | return; |
1180 | |
1181 | m_lighting = lighting; |
1182 | emit lightingChanged(lighting: m_lighting); |
1183 | markDirty(type: LightingModeDirty); |
1184 | } |
1185 | |
1186 | void QQuick3DPrincipledMaterial::setBlendMode(QQuick3DPrincipledMaterial::BlendMode blendMode) |
1187 | { |
1188 | if (m_blendMode == blendMode) |
1189 | return; |
1190 | |
1191 | m_blendMode = blendMode; |
1192 | emit blendModeChanged(blendMode: m_blendMode); |
1193 | markDirty(type: BlendModeDirty); |
1194 | } |
1195 | |
1196 | void QQuick3DPrincipledMaterial::setBaseColor(QColor diffuseColor) |
1197 | { |
1198 | if (m_baseColor == diffuseColor) |
1199 | return; |
1200 | |
1201 | m_baseColor = diffuseColor; |
1202 | emit baseColorChanged(baseColor: m_baseColor); |
1203 | markDirty(type: BaseColorDirty); |
1204 | } |
1205 | |
1206 | void QQuick3DPrincipledMaterial::setBaseColorMap(QQuick3DTexture *baseColorMap) |
1207 | { |
1208 | if (m_baseColorMap == baseColorMap) |
1209 | return; |
1210 | |
1211 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &QQuick3DPrincipledMaterial::setBaseColorMap, newO: baseColorMap, oldO: m_baseColorMap); |
1212 | |
1213 | m_baseColorMap = baseColorMap; |
1214 | emit baseColorMapChanged(baseColorMap: m_baseColorMap); |
1215 | markDirty(type: BaseColorDirty); |
1216 | } |
1217 | |
1218 | void QQuick3DPrincipledMaterial::setBaseColorSingleChannelEnabled(bool baseColorSingleChannelEnabled) |
1219 | { |
1220 | if (m_baseColorSingleChannelEnabled == baseColorSingleChannelEnabled) |
1221 | return; |
1222 | |
1223 | m_baseColorSingleChannelEnabled = baseColorSingleChannelEnabled; |
1224 | emit baseColorSingleChannelEnabledChanged(baseColorSingleChannelEnabled); |
1225 | markDirty(type: BaseColorDirty); |
1226 | } |
1227 | |
1228 | void QQuick3DPrincipledMaterial::setBaseColorChannel(TextureChannelMapping channel) |
1229 | { |
1230 | if (m_baseColorChannel == channel) |
1231 | return; |
1232 | |
1233 | m_baseColorChannel = channel; |
1234 | emit baseColorChannelChanged(channel); |
1235 | markDirty(type: BaseColorDirty); |
1236 | } |
1237 | |
1238 | void QQuick3DPrincipledMaterial::setSpecularSingleChannelEnabled(bool specularSingleChannelEnabled) |
1239 | { |
1240 | if (m_specularSingleChannelEnabled == specularSingleChannelEnabled) |
1241 | return; |
1242 | |
1243 | m_specularSingleChannelEnabled = specularSingleChannelEnabled; |
1244 | emit specularSingleChannelEnabledChanged(specularColorSingleChannelEnabled: specularSingleChannelEnabled); |
1245 | markDirty(type: SpecularDirty); |
1246 | } |
1247 | |
1248 | void QQuick3DPrincipledMaterial::setSpecularChannel(TextureChannelMapping channel) |
1249 | { |
1250 | if (m_specularChannel == channel) |
1251 | return; |
1252 | |
1253 | m_specularChannel = channel; |
1254 | emit specularChannelChanged(channel); |
1255 | markDirty(type: SpecularDirty); |
1256 | } |
1257 | |
1258 | void QQuick3DPrincipledMaterial::setEmissiveSingleChannelEnabled(bool emissiveSingleChannelEnabled) |
1259 | { |
1260 | if (m_emissiveSingleChannelEnabled == emissiveSingleChannelEnabled) |
1261 | return; |
1262 | |
1263 | m_emissiveSingleChannelEnabled = emissiveSingleChannelEnabled; |
1264 | emit emissiveSingleChannelEnabledChanged(emissiveColorSingleChannelEnabled: emissiveSingleChannelEnabled); |
1265 | markDirty(type: EmissiveDirty); |
1266 | } |
1267 | |
1268 | void QQuick3DPrincipledMaterial::setEmissiveChannel(TextureChannelMapping channel) |
1269 | { |
1270 | if (m_emissiveChannel == channel) |
1271 | return; |
1272 | |
1273 | m_emissiveChannel = channel; |
1274 | emit emissiveChannelChanged(channel); |
1275 | markDirty(type: EmissiveDirty); |
1276 | } |
1277 | |
1278 | void QQuick3DPrincipledMaterial::setEmissiveMap(QQuick3DTexture *emissiveMap) |
1279 | { |
1280 | if (m_emissiveMap == emissiveMap) |
1281 | return; |
1282 | |
1283 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &QQuick3DPrincipledMaterial::setEmissiveMap, newO: emissiveMap, oldO: m_emissiveMap); |
1284 | |
1285 | m_emissiveMap = emissiveMap; |
1286 | emit emissiveMapChanged(emissiveMap: m_emissiveMap); |
1287 | markDirty(type: EmissiveDirty); |
1288 | } |
1289 | |
1290 | void QQuick3DPrincipledMaterial::setEmissiveFactor(QVector3D emissiveFactor) |
1291 | { |
1292 | if (m_emissiveFactor == emissiveFactor) |
1293 | return; |
1294 | |
1295 | m_emissiveFactor = emissiveFactor; |
1296 | emit emissiveFactorChanged(emissiveFactor: m_emissiveFactor); |
1297 | markDirty(type: EmissiveDirty); |
1298 | } |
1299 | |
1300 | void QQuick3DPrincipledMaterial::setSpecularReflectionMap(QQuick3DTexture *specularReflectionMap) |
1301 | { |
1302 | if (m_specularReflectionMap == specularReflectionMap) |
1303 | return; |
1304 | |
1305 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &QQuick3DPrincipledMaterial::setSpecularReflectionMap, newO: specularReflectionMap, oldO: m_specularReflectionMap); |
1306 | |
1307 | m_specularReflectionMap = specularReflectionMap; |
1308 | emit specularReflectionMapChanged(specularReflectionMap: m_specularReflectionMap); |
1309 | markDirty(type: SpecularDirty); |
1310 | } |
1311 | |
1312 | void QQuick3DPrincipledMaterial::setSpecularMap(QQuick3DTexture *specularMap) |
1313 | { |
1314 | if (m_specularMap == specularMap) |
1315 | return; |
1316 | |
1317 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &QQuick3DPrincipledMaterial::setSpecularMap, newO: specularMap, oldO: m_specularMap); |
1318 | |
1319 | m_specularMap = specularMap; |
1320 | emit specularMapChanged(specularMap: m_specularMap); |
1321 | markDirty(type: SpecularDirty); |
1322 | } |
1323 | |
1324 | void QQuick3DPrincipledMaterial::setSpecularTint(float specularTint) |
1325 | { |
1326 | specularTint = ensureNormalized(val: specularTint); |
1327 | if (qFuzzyCompare(p1: m_specularTint, p2: specularTint)) |
1328 | return; |
1329 | |
1330 | m_specularTint = specularTint; |
1331 | emit specularTintChanged(specularTint: m_specularTint); |
1332 | markDirty(type: SpecularDirty); |
1333 | } |
1334 | |
1335 | void QQuick3DPrincipledMaterial::setSpecularAmount(float specularAmount) |
1336 | { |
1337 | specularAmount = ensureNormalized(val: specularAmount); |
1338 | if (qFuzzyCompare(p1: m_specularAmount, p2: specularAmount)) |
1339 | return; |
1340 | |
1341 | m_specularAmount = specularAmount; |
1342 | emit specularAmountChanged(specularAmount: m_specularAmount); |
1343 | markDirty(type: SpecularDirty); |
1344 | } |
1345 | |
1346 | void QQuick3DPrincipledMaterial::setRoughness(float roughness) |
1347 | { |
1348 | roughness = ensureNormalized(val: roughness); |
1349 | if (qFuzzyCompare(p1: m_roughness, p2: roughness)) |
1350 | return; |
1351 | |
1352 | m_roughness = roughness; |
1353 | emit roughnessChanged(roughness: m_roughness); |
1354 | markDirty(type: RoughnessDirty); |
1355 | } |
1356 | |
1357 | void QQuick3DPrincipledMaterial::setRoughnessMap(QQuick3DTexture *roughnessMap) |
1358 | { |
1359 | if (m_roughnessMap == roughnessMap) |
1360 | return; |
1361 | |
1362 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &QQuick3DPrincipledMaterial::setRoughnessMap, newO: roughnessMap, oldO: m_roughnessMap); |
1363 | |
1364 | m_roughnessMap = roughnessMap; |
1365 | emit roughnessMapChanged(roughnessMap: m_roughnessMap); |
1366 | markDirty(type: RoughnessDirty); |
1367 | } |
1368 | |
1369 | void QQuick3DPrincipledMaterial::setInvertOpacityMapValue(bool invertOpacityMapValue) |
1370 | { |
1371 | if (invertOpacityMapValue == m_invertOpacityMapValue) |
1372 | return; |
1373 | |
1374 | m_invertOpacityMapValue = invertOpacityMapValue; |
1375 | emit invertOpacityMapValueChanged(invertOpacityMapValue: m_invertOpacityMapValue); |
1376 | markDirty(type: OpacityDirty); |
1377 | } |
1378 | |
1379 | void QQuick3DPrincipledMaterial::setOpacity(float opacity) |
1380 | { |
1381 | opacity = ensureNormalized(val: opacity); |
1382 | if (qFuzzyCompare(p1: m_opacity, p2: opacity)) |
1383 | return; |
1384 | |
1385 | m_opacity = opacity; |
1386 | emit opacityChanged(opacity: m_opacity); |
1387 | markDirty(type: OpacityDirty); |
1388 | } |
1389 | |
1390 | void QQuick3DPrincipledMaterial::setOpacityMap(QQuick3DTexture *opacityMap) |
1391 | { |
1392 | if (m_opacityMap == opacityMap) |
1393 | return; |
1394 | |
1395 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &::QQuick3DPrincipledMaterial::setOpacityMap, newO: opacityMap, oldO: m_opacityMap); |
1396 | |
1397 | m_opacityMap = opacityMap; |
1398 | emit opacityMapChanged(opacityMap: m_opacityMap); |
1399 | markDirty(type: OpacityDirty); |
1400 | } |
1401 | |
1402 | void QQuick3DPrincipledMaterial::setNormalMap(QQuick3DTexture *normalMap) |
1403 | { |
1404 | if (m_normalMap == normalMap) |
1405 | return; |
1406 | |
1407 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &QQuick3DPrincipledMaterial::setNormalMap, newO: normalMap, oldO: m_normalMap); |
1408 | |
1409 | m_normalMap = normalMap; |
1410 | emit normalMapChanged(normalMap: m_normalMap); |
1411 | markDirty(type: NormalDirty); |
1412 | } |
1413 | |
1414 | void QQuick3DPrincipledMaterial::setMetalness(float metalnessAmount) |
1415 | { |
1416 | metalnessAmount = ensureNormalized(val: metalnessAmount); |
1417 | if (qFuzzyCompare(p1: m_metalnessAmount, p2: metalnessAmount)) |
1418 | return; |
1419 | |
1420 | m_metalnessAmount = metalnessAmount; |
1421 | emit metalnessChanged(metalness: m_metalnessAmount); |
1422 | markDirty(type: MetalnessDirty); |
1423 | } |
1424 | |
1425 | void QQuick3DPrincipledMaterial::setMetalnessMap(QQuick3DTexture *metallicMap) |
1426 | { |
1427 | if (m_metalnessMap == metallicMap) |
1428 | return; |
1429 | |
1430 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &QQuick3DPrincipledMaterial::setMetalnessMap, newO: metallicMap, oldO: m_metalnessMap); |
1431 | |
1432 | m_metalnessMap = metallicMap; |
1433 | emit metalnessMapChanged(metalnessMap: m_metalnessMap); |
1434 | markDirty(type: MetalnessDirty); |
1435 | } |
1436 | |
1437 | void QQuick3DPrincipledMaterial::setNormalStrength(float factor) |
1438 | { |
1439 | factor = ensureNormalized(val: factor); |
1440 | if (qFuzzyCompare(p1: m_normalStrength, p2: factor)) |
1441 | return; |
1442 | |
1443 | m_normalStrength = factor; |
1444 | emit normalStrengthChanged(normalStrength: m_normalStrength); |
1445 | markDirty(type: NormalDirty); |
1446 | } |
1447 | |
1448 | void QQuick3DPrincipledMaterial::setOcclusionMap(QQuick3DTexture *occlusionMap) |
1449 | { |
1450 | if (m_occlusionMap == occlusionMap) |
1451 | return; |
1452 | |
1453 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &QQuick3DPrincipledMaterial::setOcclusionMap, newO: occlusionMap, oldO: m_occlusionMap); |
1454 | |
1455 | m_occlusionMap = occlusionMap; |
1456 | emit occlusionMapChanged(occlusionMap: m_occlusionMap); |
1457 | markDirty(type: OcclusionDirty); |
1458 | } |
1459 | |
1460 | void QQuick3DPrincipledMaterial::setOcclusionAmount(float occlusionAmount) |
1461 | { |
1462 | if (qFuzzyCompare(p1: m_occlusionAmount, p2: occlusionAmount)) |
1463 | return; |
1464 | |
1465 | m_occlusionAmount = occlusionAmount; |
1466 | emit occlusionAmountChanged(occlusionAmount: m_occlusionAmount); |
1467 | markDirty(type: OcclusionDirty); |
1468 | } |
1469 | |
1470 | void QQuick3DPrincipledMaterial::setAlphaMode(QQuick3DPrincipledMaterial::AlphaMode alphaMode) |
1471 | { |
1472 | if (m_alphaMode == alphaMode) |
1473 | return; |
1474 | |
1475 | m_alphaMode = alphaMode; |
1476 | emit alphaModeChanged(alphaMode: m_alphaMode); |
1477 | markDirty(type: AlphaModeDirty); |
1478 | } |
1479 | |
1480 | void QQuick3DPrincipledMaterial::setAlphaCutoff(float alphaCutoff) |
1481 | { |
1482 | if (qFuzzyCompare(p1: m_alphaCutoff, p2: alphaCutoff)) |
1483 | return; |
1484 | |
1485 | m_alphaCutoff = alphaCutoff; |
1486 | emit alphaCutoffChanged(alphaCutoff: m_alphaCutoff); |
1487 | markDirty(type: AlphaModeDirty); |
1488 | } |
1489 | |
1490 | void QQuick3DPrincipledMaterial::setMetalnessChannel(TextureChannelMapping channel) |
1491 | { |
1492 | if (m_metalnessChannel == channel) |
1493 | return; |
1494 | |
1495 | m_metalnessChannel = channel; |
1496 | emit metalnessChannelChanged(channel); |
1497 | markDirty(type: MetalnessDirty); |
1498 | } |
1499 | |
1500 | void QQuick3DPrincipledMaterial::setRoughnessChannel(TextureChannelMapping channel) |
1501 | { |
1502 | if (m_roughnessChannel == channel) |
1503 | return; |
1504 | |
1505 | m_roughnessChannel = channel; |
1506 | emit roughnessChannelChanged(channel); |
1507 | markDirty(type: RoughnessDirty); |
1508 | } |
1509 | |
1510 | void QQuick3DPrincipledMaterial::setOpacityChannel(TextureChannelMapping channel) |
1511 | { |
1512 | if (m_opacityChannel == channel) |
1513 | return; |
1514 | |
1515 | m_opacityChannel = channel; |
1516 | emit opacityChannelChanged(channel); |
1517 | markDirty(type: OpacityDirty); |
1518 | } |
1519 | |
1520 | void QQuick3DPrincipledMaterial::setOcclusionChannel(TextureChannelMapping channel) |
1521 | { |
1522 | if (m_occlusionChannel == channel) |
1523 | return; |
1524 | |
1525 | m_occlusionChannel = channel; |
1526 | emit occlusionChannelChanged(channel); |
1527 | markDirty(type: OcclusionDirty); |
1528 | } |
1529 | |
1530 | void QQuick3DPrincipledMaterial::setPointSize(float size) |
1531 | { |
1532 | if (qFuzzyCompare(p1: m_pointSize, p2: size)) |
1533 | return; |
1534 | m_pointSize = size; |
1535 | emit pointSizeChanged(); |
1536 | markDirty(type: PointSizeDirty); |
1537 | } |
1538 | |
1539 | void QQuick3DPrincipledMaterial::setLineWidth(float width) |
1540 | { |
1541 | if (qFuzzyCompare(p1: m_lineWidth, p2: width)) |
1542 | return; |
1543 | m_lineWidth = width; |
1544 | emit lineWidthChanged(); |
1545 | markDirty(type: LineWidthDirty); |
1546 | } |
1547 | |
1548 | void QQuick3DPrincipledMaterial::setHeightMap(QQuick3DTexture *heightMap) |
1549 | { |
1550 | if (m_heightMap == heightMap) |
1551 | return; |
1552 | |
1553 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &QQuick3DPrincipledMaterial::setHeightMap, newO: heightMap, oldO: m_heightMap); |
1554 | |
1555 | m_heightMap = heightMap; |
1556 | emit heightMapChanged(heightMap: m_heightMap); |
1557 | markDirty(type: HeightDirty); |
1558 | } |
1559 | |
1560 | void QQuick3DPrincipledMaterial::setHeightChannel(QQuick3DMaterial::TextureChannelMapping channel) |
1561 | { |
1562 | if (m_heightChannel == channel) |
1563 | return; |
1564 | |
1565 | m_heightChannel = channel; |
1566 | emit heightChannelChanged(channel: m_heightChannel); |
1567 | markDirty(type: HeightDirty); |
1568 | } |
1569 | |
1570 | void QQuick3DPrincipledMaterial::setHeightAmount(float heightAmount) |
1571 | { |
1572 | if (m_heightAmount == heightAmount) |
1573 | return; |
1574 | |
1575 | m_heightAmount = heightAmount; |
1576 | emit heightAmountChanged(heightAmount: m_heightAmount); |
1577 | markDirty(type: HeightDirty); |
1578 | } |
1579 | |
1580 | void QQuick3DPrincipledMaterial::setMinHeightMapSamples(int samples) |
1581 | { |
1582 | if (m_minHeightMapSamples == samples) |
1583 | return; |
1584 | |
1585 | m_minHeightMapSamples = samples; |
1586 | emit minHeightMapSamplesChanged(samples); |
1587 | markDirty(type: HeightDirty); |
1588 | } |
1589 | |
1590 | void QQuick3DPrincipledMaterial::setMaxHeightMapSamples(int samples) |
1591 | { |
1592 | if (m_maxHeightMapSamples == samples) |
1593 | return; |
1594 | |
1595 | m_maxHeightMapSamples = samples; |
1596 | emit maxHeightMapSamplesChanged(samples); |
1597 | markDirty(type: HeightDirty); |
1598 | } |
1599 | |
1600 | QSSGRenderGraphObject *QQuick3DPrincipledMaterial::updateSpatialNode(QSSGRenderGraphObject *node) |
1601 | { |
1602 | static const auto channelMapping = [](TextureChannelMapping mapping) { |
1603 | return QSSGRenderDefaultMaterial::TextureChannelMapping(mapping); |
1604 | }; |
1605 | |
1606 | if (!node) { |
1607 | markAllDirty(); |
1608 | node = new QSSGRenderDefaultMaterial(QSSGRenderGraphObject::Type::PrincipledMaterial); |
1609 | } |
1610 | |
1611 | // Set common material properties |
1612 | QQuick3DMaterial::updateSpatialNode(node); |
1613 | |
1614 | QSSGRenderDefaultMaterial *material = static_cast<QSSGRenderDefaultMaterial *>(node); |
1615 | |
1616 | material->specularModel = QSSGRenderDefaultMaterial::MaterialSpecularModel::KGGX; |
1617 | |
1618 | if (m_dirtyAttributes & LightingModeDirty) |
1619 | material->lighting = QSSGRenderDefaultMaterial::MaterialLighting(m_lighting); |
1620 | |
1621 | if (m_dirtyAttributes & BlendModeDirty) |
1622 | material->blendMode = QSSGRenderDefaultMaterial::MaterialBlendMode(m_blendMode); |
1623 | |
1624 | if (m_dirtyAttributes & BaseColorDirty) { |
1625 | if (!m_baseColorMap) |
1626 | material->colorMap = nullptr; |
1627 | else |
1628 | material->colorMap = m_baseColorMap->getRenderImage(); |
1629 | |
1630 | material->color = QSSGUtils::color::sRGBToLinear(color: m_baseColor); |
1631 | material->baseColorSingleChannelEnabled = m_baseColorSingleChannelEnabled; |
1632 | material->baseColorChannel = channelMapping(m_baseColorChannel); |
1633 | } |
1634 | |
1635 | if (m_dirtyAttributes & EmissiveDirty) { |
1636 | if (!m_emissiveMap) |
1637 | material->emissiveMap = nullptr; |
1638 | else |
1639 | material->emissiveMap = m_emissiveMap->getRenderImage(); |
1640 | |
1641 | material->emissiveColor = m_emissiveFactor; |
1642 | material->emissiveSingleChannelEnabled = m_emissiveSingleChannelEnabled; |
1643 | material->emissiveChannel = channelMapping(m_emissiveChannel); |
1644 | } |
1645 | |
1646 | if (m_dirtyAttributes & RoughnessDirty) { |
1647 | if (!m_roughnessMap) |
1648 | material->roughnessMap = nullptr; |
1649 | else |
1650 | material->roughnessMap = m_roughnessMap->getRenderImage(); |
1651 | |
1652 | material->specularRoughness = m_roughness; |
1653 | material->roughnessChannel = channelMapping(m_roughnessChannel); |
1654 | } |
1655 | |
1656 | if (m_dirtyAttributes & MetalnessDirty) { |
1657 | if (!m_metalnessMap) |
1658 | material->metalnessMap = nullptr; |
1659 | else |
1660 | material->metalnessMap = m_metalnessMap->getRenderImage(); |
1661 | |
1662 | material->metalnessAmount = m_metalnessAmount; |
1663 | material->metalnessChannel = channelMapping(m_metalnessChannel); |
1664 | |
1665 | } |
1666 | |
1667 | if (m_dirtyAttributes & SpecularDirty) { |
1668 | if (!m_specularReflectionMap) |
1669 | material->specularReflection = nullptr; |
1670 | else |
1671 | material->specularReflection = m_specularReflectionMap->getRenderImage(); |
1672 | |
1673 | if (!m_specularMap) { |
1674 | material->specularMap = nullptr; |
1675 | } else { |
1676 | material->specularMap = m_specularMap->getRenderImage(); |
1677 | } |
1678 | |
1679 | material->specularAmount = m_specularAmount; |
1680 | material->specularTint = QVector3D(m_specularTint, m_specularTint, m_specularTint); |
1681 | material->ior = m_indexOfRefraction; |
1682 | material->fresnelScaleBiasEnabled = m_fresnelScaleBiasEnabled; |
1683 | material->fresnelScale = m_fresnelScale; |
1684 | material->fresnelBias = m_fresnelBias; |
1685 | material->fresnelPower = m_fresnelPower; |
1686 | material->specularAmountSingleChannelEnabled = m_specularSingleChannelEnabled; |
1687 | material->specularAmountChannel = channelMapping(m_specularChannel); |
1688 | } |
1689 | |
1690 | if (m_dirtyAttributes & OpacityDirty) { |
1691 | material->opacity = m_opacity; |
1692 | if (!m_opacityMap) |
1693 | material->opacityMap = nullptr; |
1694 | else |
1695 | material->opacityMap = m_opacityMap->getRenderImage(); |
1696 | |
1697 | material->invertOpacityMapValue = m_invertOpacityMapValue; |
1698 | material->opacity = m_opacity; |
1699 | material->opacityChannel = channelMapping(m_opacityChannel); |
1700 | } |
1701 | |
1702 | if (m_dirtyAttributes & NormalDirty) { |
1703 | if (!m_normalMap) |
1704 | material->normalMap = nullptr; |
1705 | else |
1706 | material->normalMap = m_normalMap->getRenderImage(); |
1707 | |
1708 | material->bumpAmount = m_normalStrength; |
1709 | } |
1710 | |
1711 | if (m_dirtyAttributes & OcclusionDirty) { |
1712 | if (!m_occlusionMap) |
1713 | material->occlusionMap = nullptr; |
1714 | else |
1715 | material->occlusionMap = m_occlusionMap->getRenderImage(); |
1716 | material->occlusionAmount = m_occlusionAmount; |
1717 | material->occlusionChannel = channelMapping(m_occlusionChannel); |
1718 | } |
1719 | |
1720 | if (m_dirtyAttributes & AlphaModeDirty) { |
1721 | material->alphaMode = QSSGRenderDefaultMaterial::MaterialAlphaMode(m_alphaMode); |
1722 | material->alphaCutoff = m_alphaCutoff; |
1723 | } |
1724 | |
1725 | if (m_dirtyAttributes & PointSizeDirty) |
1726 | material->pointSize = m_pointSize; |
1727 | |
1728 | if (m_dirtyAttributes & LineWidthDirty) |
1729 | material->lineWidth = m_lineWidth; |
1730 | |
1731 | if (m_dirtyAttributes & HeightDirty) { |
1732 | if (!m_heightMap) |
1733 | material->heightMap = nullptr; |
1734 | else |
1735 | material->heightMap = m_heightMap->getRenderImage(); |
1736 | material->heightAmount = m_heightAmount; |
1737 | material->minHeightSamples = m_minHeightMapSamples; |
1738 | material->maxHeightSamples = m_maxHeightMapSamples; |
1739 | material->heightChannel = channelMapping(m_heightChannel); |
1740 | } |
1741 | |
1742 | if (m_dirtyAttributes & ClearcoatDirty) { |
1743 | material->clearcoatAmount = m_clearcoatAmount; |
1744 | if (!m_clearcoatMap) |
1745 | material->clearcoatMap = nullptr; |
1746 | else |
1747 | material->clearcoatMap = m_clearcoatMap->getRenderImage(); |
1748 | material->clearcoatChannel = channelMapping(m_clearcoatChannel); |
1749 | material->clearcoatRoughnessAmount = m_clearcoatRoughnessAmount; |
1750 | if (!m_clearcoatRoughnessMap) |
1751 | material->clearcoatRoughnessMap = nullptr; |
1752 | else |
1753 | material->clearcoatRoughnessMap = m_clearcoatRoughnessMap->getRenderImage(); |
1754 | material->clearcoatRoughnessChannel = channelMapping(m_clearcoatRoughnessChannel); |
1755 | if (!m_clearcoatNormalMap) |
1756 | material->clearcoatNormalMap = nullptr; |
1757 | else |
1758 | material->clearcoatNormalMap = m_clearcoatNormalMap->getRenderImage(); |
1759 | material->clearcoatNormalStrength = m_clearcoatNormalStrength; |
1760 | material->clearcoatFresnelScaleBiasEnabled = m_clearcoatFresnelScaleBiasEnabled; |
1761 | material->clearcoatFresnelScale = m_clearcoatFresnelScale; |
1762 | material->clearcoatFresnelBias = m_clearcoatFresnelBias; |
1763 | material->clearcoatFresnelPower = m_clearcoatFresnelPower; |
1764 | } |
1765 | |
1766 | if (m_dirtyAttributes & TransmissionDirty) { |
1767 | material->transmissionFactor = m_transmissionFactor; |
1768 | if (!m_transmissionMap) |
1769 | material->transmissionMap = nullptr; |
1770 | else |
1771 | material->transmissionMap = m_transmissionMap->getRenderImage(); |
1772 | material->transmissionChannel = channelMapping(m_transmissionChannel); |
1773 | } |
1774 | |
1775 | if (m_dirtyAttributes & VolumeDirty) { |
1776 | material->thicknessFactor = m_thicknessFactor; |
1777 | if (!m_thicknessMap) |
1778 | material->thicknessMap = nullptr; |
1779 | else |
1780 | material->thicknessMap = m_thicknessMap->getRenderImage(); |
1781 | material->thicknessChannel = channelMapping(m_thicknessChannel); |
1782 | |
1783 | material->attenuationDistance = m_attenuationDistance; |
1784 | material->attenuationColor = QSSGUtils::color::sRGBToLinear(color: m_attenuationColor).toVector3D(); |
1785 | } |
1786 | |
1787 | if (m_dirtyAttributes & VertexColorsDirty) { |
1788 | material->vertexColorsEnabled = m_vertexColorsEnabled; |
1789 | material->vertexColorsMaskEnabled = m_vertexColorsMaskEnabled; |
1790 | material->vertexColorRedMask = QSSGRenderDefaultMaterial::VertexColorMaskFlags::fromInt(i: m_vertexColorRedMask); |
1791 | material->vertexColorGreenMask = QSSGRenderDefaultMaterial::VertexColorMaskFlags::fromInt(i: m_vertexColorGreenMask); |
1792 | material->vertexColorBlueMask = QSSGRenderDefaultMaterial::VertexColorMaskFlags::fromInt(i: m_vertexColorBlueMask); |
1793 | material->vertexColorAlphaMask = QSSGRenderDefaultMaterial::VertexColorMaskFlags::fromInt(i: m_vertexColorAlphaMask); |
1794 | } |
1795 | |
1796 | m_dirtyAttributes = 0; |
1797 | |
1798 | return node; |
1799 | } |
1800 | |
1801 | void QQuick3DPrincipledMaterial::itemChange(QQuick3DObject::ItemChange change, const QQuick3DObject::ItemChangeData &value) |
1802 | { |
1803 | if (change == QQuick3DObject::ItemSceneChange) |
1804 | updateSceneManager(window: value.sceneManager); |
1805 | } |
1806 | |
1807 | void QQuick3DPrincipledMaterial::updateSceneManager(QQuick3DSceneManager *sceneManager) |
1808 | { |
1809 | // Check all the resource value's scene manager, and update as necessary. |
1810 | if (sceneManager) { |
1811 | QQuick3DObjectPrivate::refSceneManager(obj: m_baseColorMap, mgr&: *sceneManager); |
1812 | QQuick3DObjectPrivate::refSceneManager(obj: m_emissiveMap, mgr&: *sceneManager); |
1813 | QQuick3DObjectPrivate::refSceneManager(obj: m_specularReflectionMap, mgr&: *sceneManager); |
1814 | QQuick3DObjectPrivate::refSceneManager(obj: m_specularMap, mgr&: *sceneManager); |
1815 | QQuick3DObjectPrivate::refSceneManager(obj: m_roughnessMap, mgr&: *sceneManager); |
1816 | QQuick3DObjectPrivate::refSceneManager(obj: m_opacityMap, mgr&: *sceneManager); |
1817 | QQuick3DObjectPrivate::refSceneManager(obj: m_normalMap, mgr&: *sceneManager); |
1818 | QQuick3DObjectPrivate::refSceneManager(obj: m_metalnessMap, mgr&: *sceneManager); |
1819 | QQuick3DObjectPrivate::refSceneManager(obj: m_occlusionMap, mgr&: *sceneManager); |
1820 | QQuick3DObjectPrivate::refSceneManager(obj: m_heightMap, mgr&: *sceneManager); |
1821 | QQuick3DObjectPrivate::refSceneManager(obj: m_clearcoatMap, mgr&: *sceneManager); |
1822 | QQuick3DObjectPrivate::refSceneManager(obj: m_clearcoatRoughnessMap, mgr&: *sceneManager); |
1823 | QQuick3DObjectPrivate::refSceneManager(obj: m_clearcoatNormalMap, mgr&: *sceneManager); |
1824 | QQuick3DObjectPrivate::refSceneManager(obj: m_transmissionMap, mgr&: *sceneManager); |
1825 | QQuick3DObjectPrivate::refSceneManager(obj: m_thicknessMap, mgr&: *sceneManager); |
1826 | } else { |
1827 | QQuick3DObjectPrivate::derefSceneManager(obj: m_baseColorMap); |
1828 | QQuick3DObjectPrivate::derefSceneManager(obj: m_emissiveMap); |
1829 | QQuick3DObjectPrivate::derefSceneManager(obj: m_specularReflectionMap); |
1830 | QQuick3DObjectPrivate::derefSceneManager(obj: m_specularMap); |
1831 | QQuick3DObjectPrivate::derefSceneManager(obj: m_roughnessMap); |
1832 | QQuick3DObjectPrivate::derefSceneManager(obj: m_opacityMap); |
1833 | QQuick3DObjectPrivate::derefSceneManager(obj: m_normalMap); |
1834 | QQuick3DObjectPrivate::derefSceneManager(obj: m_metalnessMap); |
1835 | QQuick3DObjectPrivate::derefSceneManager(obj: m_occlusionMap); |
1836 | QQuick3DObjectPrivate::derefSceneManager(obj: m_heightMap); |
1837 | QQuick3DObjectPrivate::derefSceneManager(obj: m_clearcoatMap); |
1838 | QQuick3DObjectPrivate::derefSceneManager(obj: m_clearcoatRoughnessMap); |
1839 | QQuick3DObjectPrivate::derefSceneManager(obj: m_clearcoatNormalMap); |
1840 | QQuick3DObjectPrivate::derefSceneManager(obj: m_transmissionMap); |
1841 | QQuick3DObjectPrivate::derefSceneManager(obj: m_thicknessMap); |
1842 | } |
1843 | } |
1844 | |
1845 | void QQuick3DPrincipledMaterial::markDirty(QQuick3DPrincipledMaterial::DirtyType type) |
1846 | { |
1847 | if (!(m_dirtyAttributes & quint32(type))) { |
1848 | m_dirtyAttributes |= quint32(type); |
1849 | update(); |
1850 | } |
1851 | } |
1852 | |
1853 | float QQuick3DPrincipledMaterial::clearcoatAmount() const |
1854 | { |
1855 | return m_clearcoatAmount; |
1856 | } |
1857 | |
1858 | void QQuick3DPrincipledMaterial::setClearcoatAmount(float newClearcoatAmount) |
1859 | { |
1860 | if (qFuzzyCompare(p1: m_clearcoatAmount, p2: newClearcoatAmount)) |
1861 | return; |
1862 | m_clearcoatAmount = newClearcoatAmount; |
1863 | emit clearcoatAmountChanged(amount: m_clearcoatAmount); |
1864 | markDirty(type: ClearcoatDirty); |
1865 | } |
1866 | |
1867 | QQuick3DTexture *QQuick3DPrincipledMaterial::clearcoatMap() const |
1868 | { |
1869 | return m_clearcoatMap; |
1870 | } |
1871 | |
1872 | void QQuick3DPrincipledMaterial::setClearcoatMap(QQuick3DTexture *newClearcoatMap) |
1873 | { |
1874 | if (m_clearcoatMap == newClearcoatMap) |
1875 | return; |
1876 | |
1877 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &QQuick3DPrincipledMaterial::setClearcoatMap, newO: newClearcoatMap, oldO: m_clearcoatMap); |
1878 | |
1879 | m_clearcoatMap = newClearcoatMap; |
1880 | emit clearcoatMapChanged(texture: m_clearcoatMap); |
1881 | markDirty(type: ClearcoatDirty); |
1882 | } |
1883 | |
1884 | QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::clearcoatChannel() const |
1885 | { |
1886 | return m_clearcoatChannel; |
1887 | } |
1888 | |
1889 | void QQuick3DPrincipledMaterial::setClearcoatChannel(QQuick3DMaterial::TextureChannelMapping newClearcoatChannel) |
1890 | { |
1891 | if (m_clearcoatChannel == newClearcoatChannel) |
1892 | return; |
1893 | m_clearcoatChannel = newClearcoatChannel; |
1894 | emit clearcoatChannelChanged(channel: m_clearcoatChannel); |
1895 | markDirty(type: ClearcoatDirty); |
1896 | } |
1897 | |
1898 | float QQuick3DPrincipledMaterial::clearcoatRoughnessAmount() const |
1899 | { |
1900 | return m_clearcoatRoughnessAmount; |
1901 | } |
1902 | |
1903 | void QQuick3DPrincipledMaterial::setClearcoatRoughnessAmount(float newClearcoatRoughnessAmount) |
1904 | { |
1905 | if (qFuzzyCompare(p1: m_clearcoatRoughnessAmount, p2: newClearcoatRoughnessAmount)) |
1906 | return; |
1907 | m_clearcoatRoughnessAmount = newClearcoatRoughnessAmount; |
1908 | emit clearcoatRoughnessAmountChanged(amount: m_clearcoatRoughnessAmount); |
1909 | markDirty(type: ClearcoatDirty); |
1910 | } |
1911 | |
1912 | QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::clearcoatRoughnessChannel() const |
1913 | { |
1914 | return m_clearcoatRoughnessChannel; |
1915 | } |
1916 | |
1917 | void QQuick3DPrincipledMaterial::setClearcoatRoughnessChannel(QQuick3DMaterial::TextureChannelMapping newClearcoatRoughnessChannel) |
1918 | { |
1919 | if (m_clearcoatRoughnessChannel == newClearcoatRoughnessChannel) |
1920 | return; |
1921 | m_clearcoatRoughnessChannel = newClearcoatRoughnessChannel; |
1922 | emit clearcoatRoughnessChannelChanged(channel: m_clearcoatRoughnessChannel); |
1923 | markDirty(type: ClearcoatDirty); |
1924 | } |
1925 | |
1926 | QQuick3DTexture *QQuick3DPrincipledMaterial::clearcoatRoughnessMap() const |
1927 | { |
1928 | return m_clearcoatRoughnessMap; |
1929 | } |
1930 | |
1931 | void QQuick3DPrincipledMaterial::setClearcoatRoughnessMap(QQuick3DTexture *newClearcoatRoughnessMap) |
1932 | { |
1933 | if (m_clearcoatRoughnessMap == newClearcoatRoughnessMap) |
1934 | return; |
1935 | |
1936 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &QQuick3DPrincipledMaterial::setClearcoatRoughnessMap, newO: newClearcoatRoughnessMap, oldO: m_clearcoatRoughnessMap); |
1937 | |
1938 | m_clearcoatRoughnessMap = newClearcoatRoughnessMap; |
1939 | emit clearcoatRoughnessMapChanged(texture: m_clearcoatRoughnessMap); |
1940 | markDirty(type: ClearcoatDirty); |
1941 | } |
1942 | |
1943 | QQuick3DTexture *QQuick3DPrincipledMaterial::clearcoatNormalMap() const |
1944 | { |
1945 | return m_clearcoatNormalMap; |
1946 | } |
1947 | |
1948 | void QQuick3DPrincipledMaterial::setClearcoatNormalMap(QQuick3DTexture *newClearcoatNormalMap) |
1949 | { |
1950 | if (m_clearcoatNormalMap == newClearcoatNormalMap) |
1951 | return; |
1952 | |
1953 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &QQuick3DPrincipledMaterial::setClearcoatNormalMap, newO: newClearcoatNormalMap, oldO: m_clearcoatNormalMap); |
1954 | |
1955 | m_clearcoatNormalMap = newClearcoatNormalMap; |
1956 | emit clearcoatNormalMapChanged(texture: m_clearcoatNormalMap); |
1957 | markDirty(type: ClearcoatDirty); |
1958 | } |
1959 | |
1960 | |
1961 | float QQuick3DPrincipledMaterial::clearcoatNormalStrength() const |
1962 | { |
1963 | return m_clearcoatNormalStrength; |
1964 | } |
1965 | |
1966 | void QQuick3DPrincipledMaterial::setClearcoatNormalStrength(float newClearcoatNormalStrength) |
1967 | { |
1968 | if (qFuzzyCompare(p1: m_clearcoatNormalStrength, p2: newClearcoatNormalStrength)) |
1969 | return; |
1970 | |
1971 | m_clearcoatNormalStrength = newClearcoatNormalStrength; |
1972 | emit clearcoatNormalStrengthChanged(clearcoatNormalStrength: m_clearcoatNormalStrength); |
1973 | markDirty(type: ClearcoatDirty); |
1974 | } |
1975 | |
1976 | float QQuick3DPrincipledMaterial::transmissionFactor() const |
1977 | { |
1978 | return m_transmissionFactor; |
1979 | } |
1980 | |
1981 | void QQuick3DPrincipledMaterial::setTransmissionFactor(float newTransmissionFactor) |
1982 | { |
1983 | if (qFuzzyCompare(p1: m_transmissionFactor, p2: newTransmissionFactor)) |
1984 | return; |
1985 | m_transmissionFactor = newTransmissionFactor; |
1986 | emit transmissionFactorChanged(amount: m_transmissionFactor); |
1987 | markDirty(type: TransmissionDirty); |
1988 | } |
1989 | |
1990 | QQuick3DTexture *QQuick3DPrincipledMaterial::transmissionMap() const |
1991 | { |
1992 | return m_transmissionMap; |
1993 | } |
1994 | |
1995 | void QQuick3DPrincipledMaterial::setTransmissionMap(QQuick3DTexture *newTransmissionMap) |
1996 | { |
1997 | if (m_transmissionMap == newTransmissionMap) |
1998 | return; |
1999 | |
2000 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &QQuick3DPrincipledMaterial::setTransmissionMap, newO: newTransmissionMap, oldO: m_transmissionMap); |
2001 | |
2002 | m_transmissionMap = newTransmissionMap; |
2003 | emit transmissionMapChanged(texture: m_transmissionMap); |
2004 | markDirty(type: TransmissionDirty); |
2005 | } |
2006 | |
2007 | QQuick3DMaterial::TextureChannelMapping QQuick3DPrincipledMaterial::transmissionChannel() const |
2008 | { |
2009 | return m_transmissionChannel; |
2010 | } |
2011 | |
2012 | float QQuick3DPrincipledMaterial::indexOfRefraction() const |
2013 | { |
2014 | return m_indexOfRefraction; |
2015 | } |
2016 | |
2017 | bool QQuick3DPrincipledMaterial::fresnelScaleBiasEnabled() const |
2018 | { |
2019 | return m_fresnelScaleBiasEnabled; |
2020 | } |
2021 | |
2022 | float QQuick3DPrincipledMaterial::fresnelScale() const |
2023 | { |
2024 | return m_fresnelScale; |
2025 | } |
2026 | |
2027 | float QQuick3DPrincipledMaterial::fresnelBias() const |
2028 | { |
2029 | return m_fresnelBias; |
2030 | } |
2031 | |
2032 | float QQuick3DPrincipledMaterial::fresnelPower() const |
2033 | { |
2034 | return m_fresnelPower; |
2035 | } |
2036 | |
2037 | bool QQuick3DPrincipledMaterial::clearcoatFresnelScaleBiasEnabled() const |
2038 | { |
2039 | return m_clearcoatFresnelScaleBiasEnabled; |
2040 | } |
2041 | |
2042 | float QQuick3DPrincipledMaterial::clearcoatFresnelScale() const |
2043 | { |
2044 | return m_clearcoatFresnelScale; |
2045 | } |
2046 | |
2047 | float QQuick3DPrincipledMaterial::clearcoatFresnelBias() const |
2048 | { |
2049 | return m_clearcoatFresnelBias; |
2050 | } |
2051 | |
2052 | float QQuick3DPrincipledMaterial::clearcoatFresnelPower() const |
2053 | { |
2054 | return m_clearcoatFresnelPower; |
2055 | } |
2056 | |
2057 | bool QQuick3DPrincipledMaterial::vertexColorsEnabled() const |
2058 | { |
2059 | return m_vertexColorsEnabled; |
2060 | } |
2061 | |
2062 | void QQuick3DPrincipledMaterial::setTransmissionChannel(QQuick3DMaterial::TextureChannelMapping newTransmissionChannel) |
2063 | { |
2064 | if (m_transmissionChannel == newTransmissionChannel) |
2065 | return; |
2066 | m_transmissionChannel = newTransmissionChannel; |
2067 | emit transmissionChannelChanged(channel: m_transmissionChannel); |
2068 | markDirty(type: TransmissionDirty); |
2069 | } |
2070 | |
2071 | float QQuick3DPrincipledMaterial::thicknessFactor() const |
2072 | { |
2073 | return m_thicknessFactor; |
2074 | } |
2075 | |
2076 | void QQuick3DPrincipledMaterial::setThicknessFactor(float newThicknessFactor) |
2077 | { |
2078 | if (qFuzzyCompare(p1: m_thicknessFactor, p2: newThicknessFactor)) |
2079 | return; |
2080 | m_thicknessFactor = newThicknessFactor; |
2081 | emit thicknessFactorChanged(amount: m_thicknessFactor); |
2082 | markDirty(type: VolumeDirty); |
2083 | } |
2084 | |
2085 | QQuick3DTexture *QQuick3DPrincipledMaterial::thicknessMap() const |
2086 | { |
2087 | return m_thicknessMap; |
2088 | } |
2089 | |
2090 | void QQuick3DPrincipledMaterial::setThicknessMap(QQuick3DTexture *newThicknessMap) |
2091 | { |
2092 | if (m_thicknessMap == newThicknessMap) |
2093 | return; |
2094 | |
2095 | QQuick3DObjectPrivate::attachWatcher(context: this, setter: &QQuick3DPrincipledMaterial::setThicknessMap, newO: newThicknessMap, oldO: m_thicknessMap); |
2096 | |
2097 | m_thicknessMap = newThicknessMap; |
2098 | emit thicknessMapChanged(texture: m_thicknessMap); |
2099 | markDirty(type: VolumeDirty); |
2100 | } |
2101 | |
2102 | const QQuick3DMaterial::TextureChannelMapping &QQuick3DPrincipledMaterial::thicknessChannel() const |
2103 | { |
2104 | return m_thicknessChannel; |
2105 | } |
2106 | |
2107 | void QQuick3DPrincipledMaterial::setThicknessChannel(const QQuick3DMaterial::TextureChannelMapping &newThicknessChannel) |
2108 | { |
2109 | if (m_thicknessChannel == newThicknessChannel) |
2110 | return; |
2111 | m_thicknessChannel = newThicknessChannel; |
2112 | emit thicknessChannelChanged(channel: m_thicknessChannel); |
2113 | markDirty(type: VolumeDirty); |
2114 | } |
2115 | |
2116 | float QQuick3DPrincipledMaterial::attenuationDistance() const |
2117 | { |
2118 | return m_attenuationDistance; |
2119 | } |
2120 | |
2121 | void QQuick3DPrincipledMaterial::setAttenuationDistance(float newAttenuationDistance) |
2122 | { |
2123 | if (qFuzzyCompare(p1: m_attenuationDistance, p2: newAttenuationDistance)) |
2124 | return; |
2125 | m_attenuationDistance = newAttenuationDistance; |
2126 | emit attenuationDistanceChanged(distance: m_attenuationDistance); |
2127 | markDirty(type: VolumeDirty); |
2128 | } |
2129 | |
2130 | const QColor &QQuick3DPrincipledMaterial::attenuationColor() const |
2131 | { |
2132 | return m_attenuationColor; |
2133 | } |
2134 | |
2135 | void QQuick3DPrincipledMaterial::setAttenuationColor(const QColor &newAttenuationColor) |
2136 | { |
2137 | if (m_attenuationColor == newAttenuationColor) |
2138 | return; |
2139 | m_attenuationColor = newAttenuationColor; |
2140 | emit attenuationColorChanged(color: m_attenuationColor); |
2141 | markDirty(type: VolumeDirty); |
2142 | } |
2143 | |
2144 | void QQuick3DPrincipledMaterial::setIndexOfRefraction(float indexOfRefraction) |
2145 | { |
2146 | if (qFuzzyCompare(p1: m_indexOfRefraction, p2: indexOfRefraction)) |
2147 | return; |
2148 | |
2149 | m_indexOfRefraction = indexOfRefraction; |
2150 | emit indexOfRefractionChanged(indexOfRefraction: m_indexOfRefraction); |
2151 | markDirty(type: SpecularDirty); |
2152 | } |
2153 | |
2154 | void QQuick3DPrincipledMaterial::setFresnelScaleBiasEnabled(bool fresnelScaleBiasEnabled) |
2155 | { |
2156 | if (m_fresnelScaleBiasEnabled == fresnelScaleBiasEnabled) |
2157 | return; |
2158 | |
2159 | m_fresnelScaleBiasEnabled = fresnelScaleBiasEnabled; |
2160 | emit fresnelScaleBiasEnabledChanged(fresnelScaleBiasEnabled: m_fresnelScaleBiasEnabled); |
2161 | markDirty(type: SpecularDirty); |
2162 | } |
2163 | |
2164 | void QQuick3DPrincipledMaterial::setFresnelScale(float fresnelScale) |
2165 | { |
2166 | if (qFuzzyCompare(p1: m_fresnelScale, p2: fresnelScale)) |
2167 | return; |
2168 | |
2169 | m_fresnelScale = fresnelScale; |
2170 | emit fresnelScaleChanged(fresnelScale: m_fresnelScale); |
2171 | markDirty(type: SpecularDirty); |
2172 | } |
2173 | |
2174 | void QQuick3DPrincipledMaterial::setFresnelBias(float fresnelBias) |
2175 | { |
2176 | if (qFuzzyCompare(p1: m_fresnelBias, p2: fresnelBias)) |
2177 | return; |
2178 | |
2179 | m_fresnelBias = fresnelBias; |
2180 | emit fresnelBiasChanged(fresnelBias: m_fresnelBias); |
2181 | markDirty(type: SpecularDirty); |
2182 | } |
2183 | |
2184 | void QQuick3DPrincipledMaterial::setFresnelPower(float fresnelPower) |
2185 | { |
2186 | if (qFuzzyCompare(p1: m_fresnelPower, p2: fresnelPower)) |
2187 | return; |
2188 | |
2189 | m_fresnelPower = fresnelPower; |
2190 | emit fresnelPowerChanged(fresnelPower: m_fresnelPower); |
2191 | markDirty(type: SpecularDirty); |
2192 | } |
2193 | |
2194 | void QQuick3DPrincipledMaterial::setClearcoatFresnelScaleBiasEnabled(bool clearcoatFresnelScaleBiasEnabled) |
2195 | { |
2196 | if (m_clearcoatFresnelScaleBiasEnabled == clearcoatFresnelScaleBiasEnabled) |
2197 | return; |
2198 | |
2199 | m_clearcoatFresnelScaleBiasEnabled = clearcoatFresnelScaleBiasEnabled; |
2200 | emit clearcoatFresnelScaleBiasEnabledChanged(clearcoatFresnelScaleBiasEnabled: m_clearcoatFresnelScaleBiasEnabled); |
2201 | markDirty(type: ClearcoatDirty); |
2202 | } |
2203 | |
2204 | void QQuick3DPrincipledMaterial::setClearcoatFresnelScale(float clearcoatFresnelScale) |
2205 | { |
2206 | if (qFuzzyCompare(p1: m_clearcoatFresnelScale, p2: clearcoatFresnelScale)) |
2207 | return; |
2208 | |
2209 | m_clearcoatFresnelScale = clearcoatFresnelScale; |
2210 | emit clearcoatFresnelScaleChanged(clearcoatFresnelScale: m_clearcoatFresnelScale); |
2211 | markDirty(type: ClearcoatDirty); |
2212 | } |
2213 | |
2214 | void QQuick3DPrincipledMaterial::setClearcoatFresnelBias(float clearcoatFresnelBias) |
2215 | { |
2216 | if (qFuzzyCompare(p1: m_clearcoatFresnelBias, p2: clearcoatFresnelBias)) |
2217 | return; |
2218 | |
2219 | m_clearcoatFresnelBias = clearcoatFresnelBias; |
2220 | emit clearcoatFresnelBiasChanged(clearcoatFresnelBias: m_clearcoatFresnelBias); |
2221 | markDirty(type: ClearcoatDirty); |
2222 | } |
2223 | |
2224 | void QQuick3DPrincipledMaterial::setClearcoatFresnelPower(float clearcoatFresnelPower) |
2225 | { |
2226 | if (qFuzzyCompare(p1: m_clearcoatFresnelPower, p2: clearcoatFresnelPower)) |
2227 | return; |
2228 | |
2229 | m_clearcoatFresnelPower = clearcoatFresnelPower; |
2230 | emit clearcoatFresnelPowerChanged(clearcoatFresnelPower: m_clearcoatFresnelPower); |
2231 | markDirty(type: ClearcoatDirty); |
2232 | } |
2233 | |
2234 | void QQuick3DPrincipledMaterial::setVertexColorsEnabled(bool vertexColors) |
2235 | { |
2236 | if (m_vertexColorsEnabled == vertexColors) |
2237 | return; |
2238 | |
2239 | m_vertexColorsEnabled = vertexColors; |
2240 | emit vertexColorsEnabledChanged(vertexColorsEnabled: m_vertexColorsEnabled); |
2241 | markDirty(type: VertexColorsDirty); |
2242 | } |
2243 | |
2244 | bool QQuick3DPrincipledMaterial::vertexColorsMaskEnabled() const |
2245 | { |
2246 | return m_vertexColorsMaskEnabled; |
2247 | } |
2248 | |
2249 | void QQuick3DPrincipledMaterial::setVertexColorsMaskEnabled(bool vertexColorsMaskEnabled) |
2250 | { |
2251 | if (m_vertexColorsMaskEnabled == vertexColorsMaskEnabled) |
2252 | return; |
2253 | m_vertexColorsMaskEnabled = vertexColorsMaskEnabled; |
2254 | emit vertexColorsMaskEnabledChanged(); |
2255 | markDirty(type: VertexColorsDirty); |
2256 | } |
2257 | |
2258 | QQuick3DPrincipledMaterial::VertexColorMaskFlags QQuick3DPrincipledMaterial::vertexColorRedMask() const |
2259 | { |
2260 | return m_vertexColorRedMask; |
2261 | } |
2262 | |
2263 | void QQuick3DPrincipledMaterial::setVertexColorRedMask(QQuick3DPrincipledMaterial::VertexColorMaskFlags vertexColorRedMask) |
2264 | { |
2265 | if (m_vertexColorRedMask == vertexColorRedMask) |
2266 | return; |
2267 | m_vertexColorRedMask = vertexColorRedMask; |
2268 | emit vertexColorRedMaskChanged(); |
2269 | markDirty(type: VertexColorsDirty); |
2270 | } |
2271 | |
2272 | QQuick3DPrincipledMaterial::VertexColorMaskFlags QQuick3DPrincipledMaterial::vertexColorGreenMask() const |
2273 | { |
2274 | return m_vertexColorGreenMask; |
2275 | } |
2276 | |
2277 | void QQuick3DPrincipledMaterial::setVertexColorGreenMask(QQuick3DPrincipledMaterial::VertexColorMaskFlags vertexColorGreenMask) |
2278 | { |
2279 | if (m_vertexColorGreenMask == vertexColorGreenMask) |
2280 | return; |
2281 | m_vertexColorGreenMask = vertexColorGreenMask; |
2282 | emit vertexColorGreenMaskChanged(); |
2283 | markDirty(type: VertexColorsDirty); |
2284 | } |
2285 | |
2286 | QQuick3DPrincipledMaterial::VertexColorMaskFlags QQuick3DPrincipledMaterial::vertexColorBlueMask() const |
2287 | { |
2288 | return m_vertexColorBlueMask; |
2289 | } |
2290 | |
2291 | void QQuick3DPrincipledMaterial::setVertexColorBlueMask(QQuick3DPrincipledMaterial::VertexColorMaskFlags vertexColorBlueMask) |
2292 | { |
2293 | if (m_vertexColorBlueMask == vertexColorBlueMask) |
2294 | return; |
2295 | m_vertexColorBlueMask = vertexColorBlueMask; |
2296 | emit vertexColorBlueMaskChanged(); |
2297 | markDirty(type: VertexColorsDirty); |
2298 | } |
2299 | |
2300 | QQuick3DPrincipledMaterial::VertexColorMaskFlags QQuick3DPrincipledMaterial::vertexColorAlphaMask() const |
2301 | { |
2302 | return m_vertexColorAlphaMask; |
2303 | } |
2304 | |
2305 | void QQuick3DPrincipledMaterial::setVertexColorAlphaMask(QQuick3DPrincipledMaterial::VertexColorMaskFlags vertexColorAlphaMask) |
2306 | { |
2307 | if (m_vertexColorAlphaMask == vertexColorAlphaMask) |
2308 | return; |
2309 | m_vertexColorAlphaMask = vertexColorAlphaMask; |
2310 | emit vertexColorAlphaMaskChanged(); |
2311 | markDirty(type: VertexColorsDirty); |
2312 | } |
2313 | |
2314 | QT_END_NAMESPACE |
2315 | |
2316 | |