In my last article “Physically-based Rendering in Game, Part 3“, I explained microfacet BRDF. Here I will talk about the difference between BRDF in most current game and physically-based BRDF.

Firstly we review the equation from my second article:

$L_0(\mathbf{v})=\pi \rho(\mathbf{l_c}, \mathbf{v}) \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})$

## Comparison

The reflectance equation common used in game look like this:

$L_{o}(\mathbf{v})=(\mathbf{c}_{diff} (\mathbf{n} \cdot \mathbf{l_c}) + \mathbf{c}_{spec}(\mathbf{r_v} \cdot \mathbf{l_c})^{\alpha}) \otimes \mathbf{c}_{light}$

According to my first article, $(\mathbf{n} \cdot \mathbf{l_c})$ is part of reflectance equation, not diffuse term. So it should be:

$L_{o}(\mathbf{v})=(\mathbf{c}_{diff} + \mathbf{c}_{spec}(\mathbf{r_v} \cdot \mathbf{l_c})^{\alpha}) \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})$

where $\mathbf{r_v}$ is the view vector reflected about the normal. It’s from Phong model. It doesn’t seem to correspond to anything from microfacet theory in my last article. The Blinn-Phong model is very similar to this equation, but it uses the more physically meaningful half-vector h, which is microfacet’s normal m. Changing from Phong to Blinn-Phong gives us the following model:

$L_{o}(\mathbf{v})=(\mathbf{c}_{diff} + \pi \mathbf{c}_{spec}(\mathbf{n} \cdot \mathbf{h})^{\alpha}) \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})$

Recall the Lambert term from the first article, the diffuse term now is the same with physically-based one:

$\mathbf{c}_{diff} = \pi \frac {\mathbf{c}_{diff}} {\pi}$

So, now we focus on specular term. If we look at the specular term only in the equation before:

$L_{o}(\mathbf{v})=\pi (\mathbf{n} \cdot \mathbf{h})^{\alpha} \mathbf{c}_{spec} \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})$

Compare to microfacet specular:

$L_{o}(\mathbf{v})=\pi \frac{D(\mathbf{h})G(\mathbf{l_c},\mathbf{v},\mathbf{h})}{4(\mathbf{n} \cdot \mathbf{l_c})(\mathbf{n} \cdot \mathbf{v})}F(\mathbf{c}_{spec}, \mathbf{l_c},\mathbf{h}) \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})$

Firstly, we can see from these two equations, the $\mathbf{c}_{spec}$ in game can be replaced by Fresnel’s $F(\mathbf{c}_{spec}, \mathbf{l_c}, \mathbf{h})$.

Secondly, recall my last article, I mentioned that $D(\mathbf{h})$ is related to roughness. So $D(\mathbf{h})$ and Blinn-Phong’s $(\mathbf{n} \cdot \mathbf{h})^{\alpha}$ have similar functions. However, to convert the $(\mathbf{n} \cdot \mathbf{h})^{\alpha}$ term into a microfacet normal distribution function it must be correctly normalized. It means the sum of the signed projected areas of the microfacets needs to equal the signed projected area of the macroscopic surface; this must hold true for any viewing direction. Mathematically, this means that the function must fulfil this equation for any v:

$(\mathbf{v} \cdot \mathbf{n}) = \int_{\Theta} D(\mathbf{m})(\mathbf{v} \cdot \mathbf{m}) d\omega_m$

This equation holds for any viewing direction. In the special case, v = n:

$1 = \int_{\Theta} D(\mathbf{m})(\mathbf{n} \cdot \mathbf{m}) d\omega_m$

The Blinn-Phong cosine power term can be made to obey this equation by multiplying it with a simple normalization factor:

$D_{BP}=\frac {\alpha + 2} {2\pi}(\mathbf{n} \cdot \mathbf{m})^{\alpha}$

The only term left is:

$\frac {G(\mathbf{l_c},\mathbf{v},\mathbf{h})}{(\mathbf{n} \cdot \mathbf{l_c})(\mathbf{n} \cdot \mathbf{v})}$

It’s shadowing/masking, or geometry term divided by the foreshortening factors. The physical meaning of this term is visibility. Since our modified specular model has no visibility term, we will simply set it to 1.  That is:

$G_{implicit}(\mathbf{l_c},\mathbf{v},\mathbf{h}) = (\mathbf{n} \cdot \mathbf{l_c})(\mathbf{n} \cdot \mathbf{v})$

This is actually a plausible geometry term for a heightfield microsurface (which is what the Blinn-Phong normal distribution function corresponds to, since it is zero for all backfacing microfacets). $G_{implicit}()$ is equal to 1 when l = n and v = n, which is correct for a heightfield (no microfacets are occluded from the direction of the macrosurface normal). It goes to 0 for either glancing view angles or glancing light angles, which again is correct (the probability of a microfacet being occluded by other microfacets increases with viewing angle).

Until now, several terms from microfacet specular BRDF are all explained, leaving us this rendering model:

$L_{o}(\mathbf{v})=\frac {\alpha + 2} {8}(\mathbf{n} \cdot \mathbf{h})^{\alpha} F(\mathbf{c}_{spec}, \mathbf{l_c},\mathbf{h}) \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})$

The factor is because of $\frac {\alpha + 2} {2\pi} \frac{\pi} {4} = \frac {\alpha + 2} {8}$.

Add the diffuse term back, that is:

$L_{o}(\mathbf{v})=(\mathbf{c}_{diff} + \frac {\alpha + 2} {8}(\mathbf{n} \cdot \mathbf{h})^{\alpha} F(\mathbf{c}_{spec}, \mathbf{l_c},\mathbf{h})) \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})$

This is the final equation, which is physically-based rendering model, derivated by this serial. Compare to the model common used in game, the calculated amount increases little. However, this equation not only ensure the energy-preserving, but also easier for artists to adjust parameters.

The most import equation of this serial is shown. In the next article, which is the last article in this serial, I’ll propose some future works, and will present some rendering results of physically-based model.