Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qtquick3d-pbr.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2020 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
6
\title Physically Based Rendering
7
\page quick3d-pbr
8
9
\section1 Introduction
10
11
Physically Based Rendering (PBR) is a rendering technique that aims to accurately
12
simulate the physical properties of materials and lights in a scene. It is based
13
on the principles of physics, and uses algorithms to accurately model the way
14
light interacts with different materials.
15
16
Physically Based Rendering takes into account the way light is absorbed,
17
reflected, and scattered by various surfaces, such as metal, glass, and plastic.
18
This allows for more realistic and accurate rendering of materials, as well as
19
more accurate lighting effects such as reflections, refractions, and shadows.
20
21
Aside from looking better, it also simplifies the workflow of artist since
22
materials are based on physical parameters, which are more intuitive to use and
23
tweak. Another benefit is that using PBR materials makes the look of imported
24
assets more consistent with how they were designed.
25
26
For more details on the theory behind PBR, see:
27
\l{https://learnopengl.com/PBR/Theory} and
28
\l{https://academy.substance3d.com/courses/the-pbr-guide-part-1} for an in-depth
29
explanation.
30
31
\section1 Materials and Workflows
32
33
To take advantage of Physically Based Rendering, Qt Quick 3D offers three built-in
34
materials: \l PrincipledMaterial, \l SpecularGlossyMaterial, and \l CustomMaterial.
35
Each of these materials provides a different workflow for defining material
36
properties. The choice of which workflow and material to use will depend on the
37
type of material you want to create or the workflow defined by the tool you are
38
using to create the material.
39
40
\section2 Metallic Roughness Workflow
41
42
The Metallic Roughness workflow is a method for implementing Physically Based Rendering
43
that uses two main parameters to represent the appearance of a material: metallic
44
reflectance and surface roughness. The metallic reflectance is a value ranging
45
from 0 (non-metallic) to 1 (fully metallic) that determines how much of the incoming
46
light is reflected by the material and how much is absorbed. The surface roughness
47
is a value ranging from 0 (smooth) to 1 (rough) that determines how rough or smooth
48
the surface of the material appears. The appearance of a material in the
49
Metallic/Roughness workflow is determined by its base color, metallic reflectance,
50
and surface roughness values, which can be stored as textures or constant values.
51
52
The base color of the material for the Metallic Roughness workflow contains both the
53
reflected color for non-metals (dielectrics) and the reflectance value for metals.
54
55
\section3 PrincipledMaterial
56
57
The \l PrincipledMaterial is the primary material that enables the Metallic Roughness
58
workflow in Qt Quick 3D.
59
An example of how to use the PrincipledMaterial is shown below:
60
61
\qml
62
import QtQuick
63
import QtQuick3D
64
import QtQuick3D.Helpers
65
66
Window {
67
visible: true
68
width: 640
69
height: 480
70
title: qsTr("PrincipledMaterial")
71
72
View3D {
73
anchors.fill: parent
74
75
environment.backgroundMode: SceneEnvironment.SkyBox
76
environment.lightProbe: Texture {
77
textureData: ProceduralSkyTextureData {}
78
}
79
80
PerspectiveCamera {
81
z: 150
82
y: 40
83
eulerRotation.x: -15
84
}
85
86
Model {
87
x: -50
88
source: "#Sphere"
89
materials: [
90
PrincipledMaterial {
91
baseColor: "red"
92
metalness: 0.0
93
roughness: 0.1
94
}
95
]
96
}
97
Model {
98
x: 50
99
source: "#Sphere"
100
materials: [
101
PrincipledMaterial {
102
baseColor: "red"
103
metalness: 1.0
104
roughness: 0.1
105
}
106
]
107
}
108
}
109
}
110
\endqml
111
112
This example shows two spheres, one with a non-metallic material and one with a
113
metallic material and shows the different meanings that base color has depending
114
on the metalness amount.
115
116
\image pbr_example.jpg
117
118
In the previous example all of the relevant properties of the Metallic Roughness
119
workflow are defined via a constant value, but they can also be defined using
120
textures. The following example shows how to use textures to define the base color,
121
metallness, and roughness of a material:
122
123
\qml
124
import QtQuick
125
import QtQuick3D
126
import QtQuick3D.Helpers
127
128
Window {
129
visible: true
130
width: 640
131
height: 480
132
title: qsTr("PrincipledMaterial with Textures")
133
134
View3D {
135
anchors.fill: parent
136
137
environment.backgroundMode: SceneEnvironment.SkyBox
138
environment.lightProbe: Texture {
139
textureData: ProceduralSkyTextureData {
140
}
141
}
142
143
PerspectiveCamera {
144
z: 150
145
y: 40
146
eulerRotation.x: -15
147
}
148
149
Model {
150
source: "#Sphere"
151
materials: [
152
PrincipledMaterial {
153
baseColorMap: Texture {
154
source: "red.png"
155
}
156
metalnessMap: Texture {
157
source: "metalness.png"
158
}
159
roughnessMap: Texture {
160
source: "roughness.png"
161
}
162
}
163
]
164
}
165
}
166
}
167
\endqml
168
169
\section3 CustomMaterial
170
171
While \l PrincipledMaterial is a very flexible way to create materials, somtimes
172
you may need more control over the material properties. For this, Qt Quick 3D
173
provides the \l CustomMaterial, which allows you to augment the values used in
174
the Metallic Roughness workflow by adjusting the shader code used by the material.
175
176
See \l{Programmable Materials, Effects, Geometry, and Texture data} for an
177
introduction to augmenting materials and the built-in PBR lighting system with
178
custom shader code.
179
180
\section2 Specular and Glossiness Workflow
181
182
The Specular/Glossiness workflow is a method for implementing Physically Based
183
Rendering that uses two main parameters to represent the appearance of a
184
material: specular reflectance and glossiness. The specular reflectance is a
185
color value that determines the color and intensity of the specular highlights
186
on the surface of the material. The glossiness is a value ranging from 0 (rough)
187
to 1 (smooth) that determines how rough or smooth the surface of the material appears.
188
In the Specular/Glossiness workflow, the appearance of a material is determined by its
189
albedo, specular reflectance, and glossiness values, which can be stored as textures or
190
constant values. A material with a high specular reflectance and low glossiness will
191
appear more metallic and will have sharp specular highlights, while a material with a
192
low specular reflectance and high glossiness will appear more diffuse and will have
193
soft specular highlights.
194
195
\section3 SpecularGlossyMaterial
196
197
The \l SpecularGlossyMaterial is the material that enables the Specular/Glossiness in
198
Qt Quick 3D.
199
200
\section2 More examples
201
202
For more examples, see \l{Qt Quick 3D - Principled Material Example} and \l{Qt
203
Quick 3D - Custom Materials Example}.
204
205
*/
qtquick3d
src
quick3d
doc
src
qtquick3d-pbr.qdoc
Generated on
for Qt by
1.14.0