Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
11Physically Based Rendering (PBR) is a rendering technique that aims to accurately
12simulate the physical properties of materials and lights in a scene. It is based
13on the principles of physics, and uses algorithms to accurately model the way
14light interacts with different materials.
15
16Physically Based Rendering takes into account the way light is absorbed,
17reflected, and scattered by various surfaces, such as metal, glass, and plastic.
18This allows for more realistic and accurate rendering of materials, as well as
19more accurate lighting effects such as reflections, refractions, and shadows.
20
21Aside from looking better, it also simplifies the workflow of artist since
22materials are based on physical parameters, which are more intuitive to use and
23tweak. Another benefit is that using PBR materials makes the look of imported
24assets more consistent with how they were designed.
25
26For 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
29explanation.
30
31\section1 Materials and Workflows
32
33To take advantage of Physically Based Rendering, Qt Quick 3D offers three built-in
34materials: \l PrincipledMaterial, \l SpecularGlossyMaterial, and \l CustomMaterial.
35Each of these materials provides a different workflow for defining material
36properties. The choice of which workflow and material to use will depend on the
37type of material you want to create or the workflow defined by the tool you are
38using to create the material.
39
40\section2 Metallic Roughness Workflow
41
42The Metallic Roughness workflow is a method for implementing Physically Based Rendering
43that uses two main parameters to represent the appearance of a material: metallic
44reflectance and surface roughness. The metallic reflectance is a value ranging
45from 0 (non-metallic) to 1 (fully metallic) that determines how much of the incoming
46light is reflected by the material and how much is absorbed. The surface roughness
47is a value ranging from 0 (smooth) to 1 (rough) that determines how rough or smooth
48the surface of the material appears. The appearance of a material in the
49Metallic/Roughness workflow is determined by its base color, metallic reflectance,
50and surface roughness values, which can be stored as textures or constant values.
51
52The base color of the material for the Metallic Roughness workflow contains both the
53reflected color for non-metals (dielectrics) and the reflectance value for metals.
54
55\section3 PrincipledMaterial
56
57The \l PrincipledMaterial is the primary material that enables the Metallic Roughness
58workflow in Qt Quick 3D.
59An example of how to use the PrincipledMaterial is shown below:
60
61\qml
62import QtQuick
63import QtQuick3D
64import QtQuick3D.Helpers
65
66Window {
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
112This example shows two spheres, one with a non-metallic material and one with a
113metallic material and shows the different meanings that base color has depending
114on the metalness amount.
115
116\image pbr_example.jpg
117
118In the previous example all of the relevant properties of the Metallic Roughness
119workflow are defined via a constant value, but they can also be defined using
120textures. The following example shows how to use textures to define the base color,
121metallness, and roughness of a material:
122
123\qml
124import QtQuick
125import QtQuick3D
126import QtQuick3D.Helpers
127
128Window {
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
171While \l PrincipledMaterial is a very flexible way to create materials, somtimes
172you may need more control over the material properties. For this, Qt Quick 3D
173provides the \l CustomMaterial, which allows you to augment the values used in
174the Metallic Roughness workflow by adjusting the shader code used by the material.
175
176See \l{Programmable Materials, Effects, Geometry, and Texture data} for an
177introduction to augmenting materials and the built-in PBR lighting system with
178custom shader code.
179
180\section2 Specular and Glossiness Workflow
181
182The Specular/Glossiness workflow is a method for implementing Physically Based
183Rendering that uses two main parameters to represent the appearance of a
184material: specular reflectance and glossiness. The specular reflectance is a
185color value that determines the color and intensity of the specular highlights
186on the surface of the material. The glossiness is a value ranging from 0 (rough)
187to 1 (smooth) that determines how rough or smooth the surface of the material appears.
188In the Specular/Glossiness workflow, the appearance of a material is determined by its
189albedo, specular reflectance, and glossiness values, which can be stored as textures or
190constant values. A material with a high specular reflectance and low glossiness will
191appear more metallic and will have sharp specular highlights, while a material with a
192low specular reflectance and high glossiness will appear more diffuse and will have
193soft specular highlights.
194
195\section3 SpecularGlossyMaterial
196
197The \l SpecularGlossyMaterial is the material that enables the Specular/Glossiness in
198Qt Quick 3D.
199
200\section2 More examples
201
202For more examples, see \l{Qt Quick 3D - Principled Material Example} and \l{Qt
203Quick 3D - Custom Materials Example}.
204
205*/