1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick3D
// qmllint disable missing-property
// Disabling missing-property because the targetMaterial property
// will either be a PrincipaledMaterial or SpecularGlossyMaterial
// but the shared properties are not part of the common base class
ScrollView {
id: rootView
required property PrincipledMaterial principledMaterial
required property SpecularGlossyMaterial specularGlossyMaterial
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
width: availableWidth
property bool specularGlossyMode: false
ColumnLayout {
width: rootView.availableWidth
MarkdownLabel {
text: `# The Basics
PrincipledMaterial is a Physically Based Rendering (PBR) material that follows
the Metal/Roughness workflow. This section describes the basics of using the
fundamental properties of the PrincipledMaterial. An alternative workflow is
the Specular/Glossy workflow which works like the PrincipledMaterial and is
called SpecularGlossyMaterial.
`
}
RowLayout {
Label {
text: "Metalness/Roughness"
}
Switch {
checked: rootView.specularGlossyMode
onCheckedChanged: {
rootView.specularGlossyMode = checked
}
}
Label {
text: "Specular/Glossy"
}
}
ColumnLayout {
implicitWidth: rootView.availableWidth
visible: !rootView.specularGlossyMode
MarkdownLabel {
text: `## Base Color
The Base Color property of the material in the Metal/Roughness workflow defines
both a diffuse reflected color for dielectric (non-metals) as well as the
reflectance value for metals. The PrincipledMaterial enables the Base Color to
be defined either as a single color, or as a texture.
### Base Color (Scalar)
`
}
RowLayout {
Label {
text: "Red (" + rootView.principledMaterial.baseColor.r.toFixed(2) + ")"
Layout.fillWidth: true
}
Slider {
from: 0
to: 1
value: rootView.principledMaterial.baseColor.r
onValueChanged: rootView.principledMaterial.baseColor.r = value
}
}
RowLayout {
Label {
text: "Green (" + rootView.principledMaterial.baseColor.g.toFixed(2) + ")"
Layout.fillWidth: true
}
Slider {
from: 0
to: 1
value: rootView.principledMaterial.baseColor.g
onValueChanged: rootView.principledMaterial.baseColor.g = value
}
}
RowLayout {
Label {
text: "Blue (" + rootView.principledMaterial.baseColor.b.toFixed(2) + ")"
Layout.fillWidth: true
}
Slider {
from: 0
to: 1
value: rootView.principledMaterial.baseColor.b
onValueChanged: rootView.principledMaterial.baseColor.b = value
}
}
MarkdownLabel {
text: `### Base Color (Map)
When using a texture for Base Color, it is important to remember that the final
Base Color value will be the combination of both the Base Color (Scalar) and the
Base Color Map (Texture). Setting the Base Color (Scaler) to White, or in other
words 1.0 for all color channels, the Colors in the Base Color Map will be exactly
as intended.
`
}
RowLayout {
Label {
text: "Enable base color single channel Map
The material will use the single value of the baseColorChannel from
the baseColorMap as RGB value and use 1.0 as alpha value."
}
Switch {
checked: rootView.principledMaterial.baseColorSingleChannelEnabled
onCheckedChanged: {
rootView.principledMaterial.baseColorSingleChannelEnabled = checked
}
}
}
ComboBox {
enabled: rootView.principledMaterial.baseColorSingleChannelEnabled
textRole: "text"
valueRole: "value"
implicitContentWidthPolicy: ComboBox.WidestText
onActivated: rootView.principledMaterial.baseColorChannel = currentValue
Component.onCompleted: currentIndex = indexOfValue(rootView.principledMaterial.baseColorChannel)
model: [
{ value: PrincipledMaterial.R, text: "Red Channel"},
{ value: PrincipledMaterial.G, text: "Green Channel"},
{ value: PrincipledMaterial.B, text: "Blue Channel"},
{ value: PrincipledMaterial.A, text: "Alpha Channel"}
]
}
Button {
text: "Reset Base Color"
onClicked: {
rootView.principledMaterial.baseColor = "white"
}
}
TextureSourceControl {
defaultTexture: "maps/metallic/basecolor.jpg"
onTargetTextureChanged: {
rootView.principledMaterial.baseColorMap = targetTexture
}
}
VerticalSectionSeparator {}
MarkdownLabel {
text: `## Metalness
The Metalness property of the PrincipledMaterial defines how to interpret the
Base Color of the material. A value of 0 means that the material is dielectric
(non-metal) and Base Color should be interpreted as diffuse reflected color. If
the Metalness value is 1 then the material is a raw metal and Base Color should
be interpreted as reflectance values. For the the most realistic results, this
value should be either 0 or 1, but it is possible to set values in between to
get mixed of both for artistic reasons.`
}
RowLayout {
Label {
text: "Metalness (" + rootView.principledMaterial.metalness.toFixed(2) + ")"
Layout.fillWidth: true
}
Slider {
from: 0
to: 1
value: rootView.principledMaterial.metalness
onValueChanged: rootView.principledMaterial.metalness = value
}
}
MarkdownLabel {
text: `### Metalness (Map)
The Metalness Map property specifies a texture to sample the Metalness value
from. Since the Metalness property is only a single floating point value between
0.0 and 1.0, it's only necessary to use a single color channel of the image, or
a greyscale image. By default PrincipledMaterial will use the value in the blue
channel of the texture, but it's possible to change which color channel is used.
`
}
ComboBox {
id: metalnessChannelComboBox
textRole: "text"
valueRole: "value"
implicitContentWidthPolicy: ComboBox.WidestText
onActivated: rootView.principledMaterial.metalnessChannel = currentValue
Component.onCompleted: currentIndex = indexOfValue(rootView.principledMaterial.metalnessChannel)
model: [
{ value: PrincipledMaterial.R, text: "Red Channel"},
{ value: PrincipledMaterial.G, text: "Green Channel"},
{ value: PrincipledMaterial.B, text: "Blue Channel"},
{ value: PrincipledMaterial.A, text: "Alpha Channel"}
]
}
MarkdownLabel {
text: `
When using a Metalness Map the value sampled from the map file is multiplied by
the value of the Metalness property. In practice this means that the maximum
Metalness value possible will be the value set by the Metalness map is the
value in the Metalness property. So most of the time when using a Metalness
Map it will make sense to leave the value of Metalness to 1.0.
`
}
Button {
text: "Reset Metalness Value"
onClicked: rootView.principledMaterial.metalness = 1.0
}
TextureSourceControl {
defaultClearColor: "black"
defaultTexture: "maps/metallic/metallic.jpg"
onTargetTextureChanged: {
rootView.principledMaterial.metalnessMap = targetTexture
}
}
VerticalSectionSeparator {}
MarkdownLabel {
text: `## Roughness
The Roughness property defines the amount of irregularities in the surface of
a material. The more irregular a surface is, the more the light reflecting off
of it will be spread and cause light diffusion. If the surface instead is smooth
with few surface irregularity then light will be reflected in a more focused and
intense manner. A value of 0.0 means that the surface is smooth and reflective as
a mirror, and a value of 1.0 means that the surface is so rough its hard for light
to be reflected at all.`
}
RowLayout {
Label {
text: "Roughness (" + rootView.principledMaterial.roughness.toFixed(2) + ")"
Layout.fillWidth: true
}
Slider {
from: 0
to: 1
value: rootView.principledMaterial.roughness
onValueChanged: rootView.principledMaterial.roughness = value
}
}
MarkdownLabel {
text: `### Roughness (Map)
The Roughness Map property specifies a texture to sample the Roughness value
from. Since the Roughness property is only a single floating point value between
0.0 and 1.0, it's only necessary to use a single color channel of the image, or
a greyscale image. By default PrincipledMaterial will use the value in the green
channel of the texture, but it's possible to change which color channel is used.
`
}
ComboBox {
id: roughnessChannelComboBox
textRole: "text"
valueRole: "value"
implicitContentWidthPolicy: ComboBox.WidestText
onActivated: rootView.principledMaterial.roughnessChannel = currentValue
Component.onCompleted: currentIndex = indexOfValue(rootView.principledMaterial.roughnessChannel)
model: [
{ value: PrincipledMaterial.R, text: "Red Channel"},
{ value: PrincipledMaterial.G, text: "Green Channel"},
{ value: PrincipledMaterial.B, text: "Blue Channel"},
{ value: PrincipledMaterial.A, text: "Alpha Channel"}
]
}
MarkdownLabel {
text: `
When using a Roughness Map the value sampled from the map file is multiplied by
the value of the Roughness property. In practice this means that the maximum
Roughness value possible will be the value set by the Roughness map is the
value in the Roughness property. So most of the time when using a Roughness
Map it will make sense to leave the value of Roughness to 1.0.
`
}
Button {
text: "Reset Roughness Value"
onClicked: rootView.principledMaterial.roughness = 1.0
}
TextureSourceControl {
defaultClearColor: "black"
defaultTexture: "maps/metallic/roughness.jpg"
onTargetTextureChanged: {
rootView.principledMaterial.roughnessMap = targetTexture
}
}
}
ColumnLayout {
implicitWidth: rootView.availableWidth
visible: rootView.specularGlossyMode
MarkdownLabel {
text: `## Albedo Color
The Albedo Color property of the material in the Specular/Glossy workflow defines
both a diffuse color without reflectance values. The SpecularGlossyMaterial enables
the Albedo Color to be defined either as a single color, or as a texture.
### Albedo Color (Scalar)
`
}
RowLayout {
Label {
text: "Red (" + rootView.specularGlossyMaterial.baseColor.r.toFixed(2) + ")"
Layout.fillWidth: true
}
Slider {
from: 0
to: 1
value: rootView.specularGlossyMaterial.albedoColor.r
onValueChanged: rootView.specularGlossyMaterial.albedoColor.r = value
}
}
RowLayout {
Label {
text: "Green (" + rootView.specularGlossyMaterial.albedoColor.g.toFixed(2) + ")"
Layout.fillWidth: true
}
Slider {
from: 0
to: 1
value: rootView.specularGlossyMaterial.albedoColor.g
onValueChanged: rootView.specularGlossyMaterial.albedoColor.g = value
}
}
RowLayout {
Label {
text: "Blue (" + rootView.specularGlossyMaterial.albedoColor.b.toFixed(2) + ")"
Layout.fillWidth: true
}
Slider {
from: 0
to: 1
value: rootView.specularGlossyMaterial.albedoColor.b
onValueChanged: rootView.specularGlossyMaterial.albedoColor.b = value
}
}
MarkdownLabel {
text: `### Albedo (Map)
When using a texture for Albedo Color, it is important to remember that the final
Albedo Color value will be the combination of both the Albedo Color (Scalar) and the
Albedo Color Map (Texture). Setting the Albedo Color (Scaler) to White, or in other
words 1.0 for all color channels, the Colors in the Albedo Map will be exactly
as intended.
`
}
RowLayout {
Label {
text: "Enable albedo single channel Map
The material will use the single value of the albedoChannel from
the albedoMap as RGB value and use 1.0 as alpha value."
}
Switch {
checked: rootView.specularGlossyMaterial.albedoSingleChannelEnabled
onCheckedChanged: {
rootView.specularGlossyMaterial.albedoSingleChannelEnabled = checked
}
}
}
ComboBox {
enabled: rootView.specularGlossyMaterial.albedoSingleChannelEnabled
textRole: "text"
valueRole: "value"
implicitContentWidthPolicy: ComboBox.WidestText
onActivated: rootView.specularGlossyMaterial.albedoChannel = currentValue
Component.onCompleted: currentIndex = indexOfValue(rootView.specularGlossyMaterial.albedoChannel)
model: [
{ value: PrincipledMaterial.R, text: "Red Channel"},
{ value: PrincipledMaterial.G, text: "Green Channel"},
{ value: PrincipledMaterial.B, text: "Blue Channel"},
{ value: PrincipledMaterial.A, text: "Alpha Channel"}
]
}
Button {
text: "Reset Albedo Color"
onClicked: {
rootView.specularGlossyMaterial.albedoColor = "white"
}
}
TextureSourceControl {
defaultTexture: "maps/metallic/basecolor.jpg"
onTargetTextureChanged: {
rootView.specularGlossyMaterial.albedoMap = targetTexture
}
}
VerticalSectionSeparator {}
MarkdownLabel {
text: `## Specular Color
The Specular Color property of the SpecularGlossyMaterial defines the reflectance
Color of the material.`
}
RowLayout {
Label {
text: "Red (" + rootView.specularGlossyMaterial.specularColor.r.toFixed(2) + ")"
Layout.fillWidth: true
}
Slider {
from: 0
to: 1
value: rootView.specularGlossyMaterial.specularColor.r
onValueChanged: rootView.specularGlossyMaterial.specularColor.r = value
}
}
RowLayout {
Label {
text: "Green (" + rootView.specularGlossyMaterial.specularColor.g.toFixed(2) + ")"
Layout.fillWidth: true
}
Slider {
from: 0
to: 1
value: rootView.specularGlossyMaterial.specularColor.g
onValueChanged: rootView.specularGlossyMaterial.specularColor.g = value
}
}
RowLayout {
Label {
text: "Blue (" + rootView.specularGlossyMaterial.specularColor.b.toFixed(2) + ")"
Layout.fillWidth: true
}
Slider {
from: 0
to: 1
value: rootView.specularGlossyMaterial.specularColor.b
onValueChanged: rootView.specularGlossyMaterial.specularColor.b = value
}
}
MarkdownLabel {
text: `### Specular (Map)
The Specular Map property specifies a texture to sample the Specular color value
from. When using a Specular Map the value sampled from the map file is multiplied
by the value of the Specular Color property. In practice this means that the maximum
Specular value possible will be the value set by the Specular map is the
value in the Specular color property. So most of the time when using a Specular
Map it will make sense to leave the value of Specular to 1.0.
`
}
RowLayout {
Label {
text: "Enable specular single channel Map
The material will use the single value of the specularChannel from
the specularMap as RGB value."
}
Switch {
checked: rootView.specularGlossyMaterial.specularSingleChannelEnabled
onCheckedChanged: {
rootView.specularGlossyMaterial.specularSingleChannelEnabled = checked
}
}
}
ComboBox {
enabled: rootView.specularGlossyMaterial.specularSingleChannelEnabled
textRole: "text"
valueRole: "value"
implicitContentWidthPolicy: ComboBox.WidestText
onActivated: rootView.specularGlossyMaterial.specularChannel = currentValue
Component.onCompleted: currentIndex = indexOfValue(rootView.specularGlossyMaterial.specularChannel)
model: [
{ value: PrincipledMaterial.R, text: "Red Channel"},
{ value: PrincipledMaterial.G, text: "Green Channel"},
{ value: PrincipledMaterial.B, text: "Blue Channel"},
{ value: PrincipledMaterial.A, text: "Alpha Channel"}
]
}
Button {
text: "Reset Specular Color Value"
onClicked: rootView.specularGlossyMaterial.specularColor = "white"
}
TextureSourceControl {
defaultClearColor: "black"
defaultTexture: "maps/metallic/metallic.jpg"
onTargetTextureChanged: {
rootView.specularGlossyMaterial.specularMap = targetTexture
}
}
VerticalSectionSeparator {}
MarkdownLabel {
text: `## Glossiness
The Glossiness property defines the amount of irregularities in the surface of
a material. The more irregular a surface is, the more the light reflecting off
of it will be spread and cause light diffusion. If the surface instead is smooth
with few surface irregularity then light will be reflected in a more focused and
intense manner. A value of 1.0 means that the surface is smooth and reflective as
a mirror, and a value of 0.0 means that the surface is so rough its hard for light
to be reflected at all.`
}
RowLayout {
Label {
text: "Glossiness (" + rootView.specularGlossyMaterial.glossiness.toFixed(2) + ")"
Layout.fillWidth: true
}
Slider {
from: 0
to: 1
value: rootView.specularGlossyMaterial.glossiness
onValueChanged: rootView.specularGlossyMaterial.glossiness = value
}
}
MarkdownLabel {
text: `### Glossiness (Map)
The Glossiness Map property specifies a texture to sample the Glossiness value
from. Since the Glossiness property is only a single floating point value between
0.0 and 1.0, it's only necessary to use a single color channel of the image, or
a greyscale image. By default SpecularGlossyMaterial will use the value in the alpha
channel of the texture, but it's possible to change which color channel is used.
`
}
ComboBox {
textRole: "text"
valueRole: "value"
implicitContentWidthPolicy: ComboBox.WidestText
onActivated: rootView.specularGlossyMaterial.glossinessChannel = currentValue
Component.onCompleted: currentIndex = indexOfValue(rootView.specularGlossyMaterial.glossinessChannel)
model: [
{ value: SpecularGlossyMaterial.R, text: "Red Channel"},
{ value: SpecularGlossyMaterial.G, text: "Green Channel"},
{ value: SpecularGlossyMaterial.B, text: "Blue Channel"},
{ value: SpecularGlossyMaterial.A, text: "Alpha Channel"}
]
}
MarkdownLabel {
text: `
When using a Glossiness Map the value sampled from the map file is multiplied by
the value of the Glossiness property. In practice this means that the maximum
Glossiness value possible will be the value set by the Glossiness map is the
value in the Glossiness property. So most of the time when using a Glossiness
Map it will make sense to leave the value of Glossiness to 1.0.
`
}
Button {
text: "Reset Glossiness Value"
onClicked: rootView.specularGlossyMaterial.glossiness = 1.0
}
TextureSourceControl {
defaultClearColor: "white"
defaultTexture: "maps/metallic/roughness.jpg"
onTargetTextureChanged: {
rootView.specularGlossyMaterial.glossinessMap = targetTexture
}
}
}
}
}
// qmllint enable missing-property
|