A physically-based reflection model

Physically-based rendering or PBR is an umbrella term that encompasses tools and techniques that make use of physically-based models of light and reflection. The term itself is somewhat loosely defined, but can generally be described as a shading/reflection model that tries to model the physics of light interacting with matter as accurately as possible. The term may mean slightly different things to different people, but for our purposes, we are interested primarily in how it differs from the Phong and the Blinn-Phong reflection models.

The Blinn-Phong model is an empirical model of reflection based on observation. A PBR model could also be considered an empirical model, but in general, it is more detailed and accurate with regards to the physics of the interaction being represented. The Blinn-Phong model uses a few parameters which are not physically based but produce effective results. For example, separating the light intensity into three (or two) separate values is not physically accurate (there's only one light). However, it provides many "tuneable" parameters to the artist to work with, giving them the flexibility to achieve the desired look.

In recent years, PBR techniques have gained favor due to the fact that they reduce the number of tuneable parameters, and provide more consistent results across a wide variety of materials. Artists have found that previous models (non-PBR) have a tendency to be tricky to "get right." When a scene consists of a wide variety of materials, the parameters may require a significant amount of "tweaking" to make consistent. With PBR-based techniques, the reflection models try to represent the physics more accurately, which tends to make things look more consistent under a wide variety of lighting settings, reducing the amount of fine-tuning required by artists.

In this recipe, we'll implement a basic PBR-based reflection model using point light sources. Before we get started, however, let's go over the math. In the following equations, we'll use the vectors n, l, v, and h, defined as follows:  

  • n: The surface normal
  • l: The vector representing the direction of incoming light
  • v: The direction toward the viewer (camera)
  • h: The vector halfway between l and v (as in the Blinn-Phong model)

A popular mathematical model for describing how light scatters from a surface is called the reflectance equation (a special case of the rendering equation), and has the following form:

This integral might look a bit scary, but basically, it means the following. The amount of outgoing radiance from a surface (Lo) toward the viewer (v), is equal to the integral (think weighted-sum) of the BRDF (f) times the amount of incoming radiance (Li). The integral is over the hemisphere above the surface, for all incoming light directions (l) within that hemisphere weighted by a cosine factor (n · l). This cosine factor is a weight that essentially represents the geometry of the situation. The more directly that the light hits the surface, the higher it is weighted.  A more complete derivation of this equation is available in several texts. In this recipe, we'll simplify this integral to a simple sum, assuming that the only sources of incoming radiance are point light sources. This is of course a huge simplification, we'll consider some techniques to evaluate the integral more accurately later.

The most significant term for us is the BRDF term (f), which stands for bidirectional reflectance distribution function. It represents the fraction of radiance that is reflected from a surface point, given the incoming direction (l) and the outgoing direction (v). Its value is a spectral value (R,G,B), with components ranging from 0 to 1. In this recipe, we'll model the BRDF as a sum of two parts: the diffuse BRDF and the specular BRDF:

The diffuse BRDF represents light that is absorbed into the surface slightly and then is re-radiated. It is common to model this term so that the radiated light has no preferred direction. It is radiated equally in all outgoing directions. This is also called Lambertian reflectance. Since it has no dependence on the incoming or outgoing directions, the Lambertian BRDF is simply a constant value:

The cdiff term represents the fraction of light that is diffusely radiated. It is commonly considered the diffuse color of the object.

The specular term represents surface reflectance. Light that is reflected directly off the surface of the object without being absorbed. This is also sometimes called glossy reflectance. A common way to model this reflectance is based on microfacet theory. This theory was developed to describe reflection from general, non-optically flat surfaces. It models the surface as consisting of small facets that are optically flat (mirrors) and are oriented in various directions. Only those that are oriented correctly to reflect toward the viewer can contribute to the BRDF.

We represent this BRDF as a product of three terms and a correction factor (the denominator):

I won't go into the details of each of these terms. For more information, check out the following See also section. Instead, I'll briefly describe each one. The F term represents Fresnel reflection, the fraction of light reflected from an optically flat surface. The Fresnel reflectance depends on the angle between the normal and the direction of incoming light (angle of incidence). However, since we are using microfacet theory, the microfacet surfaces that contribute are the ones that have their normal vector parallel to the halfway vector (h). Therefore, we use the angle between l and h instead of the angle between l and n

The Fresnel reflectance also depends on the index of refraction of the surface. However, we'll use an approximation that instead uses a different parameter. It is known as the Schlick approximation:

Rather than using the index of refraction, this approximation uses F0, the characteristic specular reflectance of the material. Or in other words, the reflectance when the angle of incidence is zero degrees. This term is useful in that it can be used as a specular "color", which is somewhat more intuitive and natural for artists.

To further understand this F0 term, let's consider values for common materials. It turns out that a material's optical properties are closely tied to its electrical properties. It is therefore helpful to divide materials into three categories: dielectrics (insulators), metals (conductors), and semiconductors. Our model will ignore the third category and focus on the first two. Metals generally do not exhibit any diffuse reflection, because any light that is refracted into the surface is completely absorbed by the free electrons. The value for F0 is much larger for metals than for dielectrics. In fact, dielectrics have very low values for F0, usually in the range of 0.05 (for all RGB components). This leads us to the following technique.

We'll associate a color with a material.  If the material is a metal, there's no diffuse reflection, so we set cdiff to (0,0,0), and use the color as the value for F0 in the Fresnel term. If the material is a dielectric, we set F0 to some small value (we'll use (0.04, 0.04, 0.04)), and use the color as the value for cdiff.  Essentially, we use two slightly different models for metals and dielectrics, switching between the two as needed. Rather than using the same model for both metals and non-metals and tweaking parameters to represent each, we separate them into two different categories each with a slightly different BRDF model. The popular term for this is metalness workflow.

Next, let's consider the D term in the specular BRDF. This is the microgeometry normal distribution function (or microfacet distribution function). It describes the statistical distribution of microsurface orientations. It has a scalar value, and gives the relative concentration of microfacet normals in the direction h. This term has a strong effect on the size and shape of the specular highlight. There are many choices for this function, and several have been developed in recent years based on physical measurements. We'll use a popular one from graphics researchers Trowbridge and Reitz, which was also given the name GGX by a separate research team:

In this equation, α is a term that represents the roughness of the surface. Following the lead of others, we'll use a roughness parameter r, and set α to r2.

Finally, we'll consider the G term in the specular BRDF. This is the geometry function and describes the probability that microsurfaces with a given normal will be visible from both the light direction (l) and the view direction (v). Its value is a scalar between 0 and 1. It is essential for energy conservation. We'll use the following model for G:

Where:

The constant k is a value that is proportional to the roughness. Again, following the lead of others (see the following See also), we'll use the following for k:

Putting all of this together, we now have a complete representation for our BRDF. Before jumping into the code, let's revisit the reflectance equation. This is the first equation we discussed, containing an integral over all directions over the hemisphere above the surface. It would be too costly to try to evaluate this integral in an interactive application, so we'll simplify it by making the assumption that all incoming light comes directly from point light sources. If we do so, the integral reduces to the following sum:

Where N is the number of point light sources, Li is the illumination received at the surface due to ith light source and li is the direction toward the ith light source. Since the intensity of light decreases with distance, we'll use an inverse-square relationship. However, other models could be used here:

Ii is the intensity of the source and di is the distance from the surface point to the light source.

We now have a complete microfacet-based model that can be applied for metallic surfaces and dielectrics. As we covered earlier, we'll modify the BRDF slightly depending on whether we are working with a metal or a dielectric. The number of parameters to this BRDF is relatively small. The following parameters will define a material:

  • The surface roughness (r), a value between 0 and 1
  • Whether or not the material is metallic (Boolean)
  • A color which is interpreted as the diffuse color for dielectrics, or the characteristic specular reflectance (F0) for metals

These parameters are quite intuitive and understandable, as opposed to the many parameters in the Blinn-Phong model from the previous recipe. There's just one color, and roughness is a more intuitive concept than the specular exponent.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.73.125