1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
6\title Physically Based Rendering
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.
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.
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.
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
31\section1 Materials and Workflows
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.
40\section2 Metallic Roughness Workflow
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.
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.
55\section3 PrincipledMaterial
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:
64import QtQuick3D.Helpers
70 title: qsTr("PrincipledMaterial")
75 environment.backgroundMode: SceneEnvironment.SkyBox
76 environment.lightProbe: Texture {
77 textureData: ProceduralSkyTextureData {}
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.
116\image pbr_example.jpg
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:
126import QtQuick3D.Helpers
132 title: qsTr("PrincipledMaterial with Textures")
137 environment.backgroundMode: SceneEnvironment.SkyBox
138 environment.lightProbe: Texture {
139 textureData: ProceduralSkyTextureData {
153 baseColorMap: Texture {
156 metalnessMap: Texture {
157 source: "metalness.png"
159 roughnessMap: Texture {
160 source: "roughness.png"
169\section3 CustomMaterial
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.
176See \l{Programmable Materials, Effects, Geometry, and Texture data} for an
177introduction to augmenting materials and the built-in PBR lighting system with
180\section2 Specular and Glossiness Workflow
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.
195\section3 SpecularGlossyMaterial
197The \l SpecularGlossyMaterial is the material that enables the Specular/Glossiness in
200\section2 More examples
202For more examples, see \l{Qt Quick 3D - Principled Material Example} and \l{Qt
203Quick 3D - Custom Materials Example}.