You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/manuals/physically-based-rendering.md
+22-44Lines changed: 22 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,12 +12,16 @@ Defold’s PBR implementation follows the glTF 2.0 material specification and as
12
12
PBR materials can include effects such as metallic reflections, surface roughness, transmission, clearcoat, subsurface scattering, iridescence, and more.
13
13
14
14
::: sidenote
15
-
Embedded textures from GLTF files are not yet exposed or accessible for assignment in Defold. This will come at a later stage, for now only the material data is exposed to the shaders.
15
+
Defold currently exposes PBR material data to shaders, but does not provide a built-in PBR lighting model. You can use this data in your own lighting and reflection shaders to achieve physically based rendering. A default PBR lighting model will be added to Defold at a later stage.
16
+
:::
17
+
18
+
::: sidenote
19
+
Embedded textures from glTF files are currently not automatically assigned in Defold. Only material parameters are exposed to shaders. You can still manually assign textures to model components and sample them in your shader.
16
20
:::
17
21
18
22
## Material properties overview
19
23
20
-
The material properties are parsed from the GLTF 2.0 source files assigned to a model component. Not all properties are considered standard properties, some of these are explicitly exposed via GLTF extensions that may or may not be enabled by the application that exported the gltf files. The relevant extension is denoted in parentheses after the property name below.
24
+
The material properties are parsed from the glTF 2.0 source files assigned to a model component. Not all properties are standard. Some are provided through optional glTF extensions that may or may not be included by the tool used to export the glTF file. The relevant extension is denoted in parentheses after the property name below.
21
25
22
26
Metallic roughness
23
27
: Describes how light interact with the material. The default PBR model.
@@ -79,7 +83,7 @@ Some of these properties provides hints on how the material should be rendered.
79
83
80
84
## Shader integration
81
85
82
-
The PBR material data is exposed to the shaders based on types and name convention. First of all, the base material struct must be a separate uniform block in the shader named 'PbrMaterial':
86
+
The PBR material data is exposed to the shaders based on types and name convention. The PBR material system provides all parsed material parameters to shaders via a structured uniform block named `PbrMaterial`. Each supported glTF extension corresponds to a struct within this block, which can be conditionally compiled using #define flags.
83
87
84
88
```glsl
85
89
uniform PbrMaterial
@@ -172,42 +176,7 @@ struct PbrIridescence
172
176
};
173
177
```
174
178
175
-
Texture usage is also exposed to the shaders, but as previously mentioned, textures from the GLTF containers are not automatically set during rendering. You need to assign the textures to the models yourself for this to properly work. Naming for textures are a bit differently since you cannot store texture uniforms inside structs. In this case, the naming scheme is `<feature>_texture`:
The common properties are set on the material uniform itself (and once again, note the data packing into vec4). Textures follow a similar pattern as we've already seen:
179
+
The common properties are set on the material uniform itself (and once again, note the data packing into vec4).
211
180
212
181
```glsl
213
182
// Common textures
@@ -230,7 +199,7 @@ uniform PbrMaterial
230
199
231
200
### Example shader
232
201
233
-
Here is an example shader that contains all textures and features. Note that you can turn off features simply by using defines around each member of the PbrMaterial itself, as shown in the example below:
202
+
Here is an example shader that contains all features and a proposed naming scheme for texture bindings (again, this must be handled manually). Note that you can turn off features simply by using defines around each member of the PbrMaterial itself, as shown in the example below:
234
203
235
204
```glsl
236
205
// Feature flags, comment or remove these to slim down the shader.
@@ -409,7 +378,16 @@ If specific data points in the material struct are not found, the data for those
409
378
410
379
### Constants
411
380
412
-
Since all of the properties are represented internally by render constants, materials can specify different default values when these values are not present. To do this, you can use the following naming pattern: ´pbrFeature.structMember`:
381
+
Each material property corresponds to an internal render constant in Defold. You can override default values by defining constants on the material resource itself, following the naming pattern`pbrFeature.structMember`. These values will be applied automatically if the matching data is missing in the glTF material.
To use the material data for physically based lighting, implement a BRDF in your fragment shader using the parameters provided in the `PbrMaterial` block.
0 commit comments