Learn the basics of PBR

It has been a while since I have blogged, but today I would like to summarize my research on PBR while reading the following book.

BSDF for Raytracing

This book discusses the well-known 3DCG texture function,Bidirectional Scattering Distribution Function(BSDF), and how to implement it in ray tracing. The book covers “Lambert BRDF,” “Phong,“Blinn-Phong, “Perfect Specular, Perfect Refractive,“Torrance-Sparrow,Cook-Torrance, “GGX,” and “Disney BRDF.”

First of all, I bought this book about 2 years ago, although the title sounds difficult.

I bought the book plus the electronic version, although only the electronic version is available now. I had the book on my stack for a long time and suddenly I wanted to sort out the terminology and history of PBR.

It is a book for ray tracing, but I think it is also very useful to learn the formulas of shaders used in real-time 3D. However, since it is mainly about formulas, it is not suitable for learning concepts such as PBR.

What is PBR?

It’s a lighting calculation based on the laws of physics.

The key word is “energy conservation”. In other words, the energy emitted from a light source illuminates an object, and when all the brightness is collected, reflected, transmitted, or absorbed, it equals the energy emitted by the light source. PBR or not PBR is equivalent to whether or not the conservation of energy is satisfied.

However, in real-time 3D, only direct light reflections are accurately calculated according to PBR, while indirect light and SSS (subsurface scattering) are often calculated in a simplified manner. Also, if parameters are added to allow artists to adjust brightness, they often deviate from PBR.

How is this different from traditional rendering?

Previously, reflection models called Lambert, Phong, andBlinn-Phongwere used. In those days, due to GPU limitations, all lighting calculations were computed with 8-10 bit integers corresponding to 0-255 values of 0.0-1.0 . Therefore, when the maximum brightness of a light source was set to 1.0, the brightness of the object surface was calculated as 0.0-1.0 to represent the apparent appearance. Also, the indirect light was calculated by adjusting the fixed brightness with the parameter Ambient.

However, with the introduction of programmable shaders on GPUs and the change in numerical precision from 8-bit integers to 32-bit and 16-bit floating decimals, the time has come to use PBR to calculate.

However, it is not accurate to say that Lambert, Phong, andBlinn-Phongare not PBR. The conventional formula does not satisfy energy conservation, but by multiplying by a certain factor and normalizing, Lambert, Phong,Blinn-Phongcan also satisfy PBR. I won’t go into details, but the above book explained this area.

What are the advantages and disadvantages of using PBR?

The advantage is that by setting light sources and materials based on PBR, you can create realistic renderings with no sense of discomfort. Also, even if the light source changes from morning to day to night, the material parameters can be rendered without changing; with non-PBR rendering methods, it is sometimes necessary to recreate materials and textures for bright and dark scenes.

The disadvantage is that it requires more computation and memory and has a higher processing load than when it was computed with conventional 8-bit integers. Also, it may not be suitable for things that are difficult to represent with physical laws, such as when you want to represent substances that do not exist in the real world, as in a fantasy world. For example, when rendering something like a luminous jewel, the PBR material requires the emissive parameter to be set to the energy of the luminescence. It may be quite difficult to figure out how many lux this brightness is for the light source.

What is the typical formula for PBR?

First of all, the key word is the Cook Transformer Model (Cook-Torrance Model). In a paper published in 1982, it proposed a reflection model based on the microfacet theory of surfaces, which could more accurately reproduce the texture of metals and plastics.

What is a “microfacet” is a material’s surface is made up of fine irregularities that change the way it glows. Two typical parameters are “Roughness” and “Metalness.

In other words,

  • Whether the surface is smooth or rough (Roughness)
  • Whether the surface is metallic or non-metallic (Metalness)

The reflected light is calculated based on these two points.

Several improved methods of calculating the Cook transformer model have been published, and the one currently used primarily in Unity and UE5 is a formula called “GGX. GGX is one of the normal distribution functions for microfacets, also calledTrowbridge-Reitz distribution. I am not sure I understand it correctly, GGX was published by Walter in 2007 as an equation obtained from experimental data, but the equivalent equation was published in 1975 byTrowbridge-Reitz , and it seems that this one was obtained from physical conditions. So, it is called GGX, not Walter model.

Also, there is one calledDisney-BRDF .Cook-Torrance and it is based on GGX, but it seems to have some additional parameters and the diffuse light is not Lambertian. It seems that UE5 and Unity also introduce some of the parameters fromDisney-BRDF .

What I would like to look into next.

This time I didn’t write any diagrams or formulas, so it might have been difficult to understand, but that’s all I have to give you an overview of PBR.

Next, I would like to continue my research on how to implement PBR. I would like to read the source to see how it is calculated in Unity and UE5 shaders.