转载请注明出处为KlayGE游戏引擎,本文的永久链接为http://www.klayge.org/?p=507

In my last article, “Physically-Based Rendering in Game, Part 1“,  I introduce reflectance equation and Lambert. In this article, we mainly focus on physically-based lighting.

Punctual Light Sources

These are classic point, directional, and spot lights in compute games. These local light source can be abstracted to a concept named “punctual light sources“. They are infinitely small light with centain direction. Since what we want is the lighting reach a surface point, we don’t need to consider the attenuation. A punctual light source are parameterized by the light color [latex]\mathbf{c}_{light}[/latex] and the light direction vector [latex]\mathbf{l_c}[/latex]. The light color [latex]\mathbf{c}_{light}[/latex] is specified as the color a white Lambertian surface would have when illuminated by the light from a direction parallel to the surface normal ([latex]\mathbf{l_c}=\mathbf{n}[/latex]).

How to calculate the contribution from this light source to a point? Here we will start by defining a tiny area light source centered on [latex]\mathbf{l_c}[/latex], with a small angular extent [latex]\varepsilon[/latex]. This tiny area light illuminates a shaded surface point with the incoming radiance function [latex]L_{tiny}(\mathbf{l})[/latex]. The incoming radiance function has the following two properties:

[latex]\forall\mathbf{l}|\angle(\mathbf{l}, \mathbf{l_c})>\varepsilon, L_{tiny}(\mathbf{l})=0[/latex]

[latex]if \mathbf{l_c}=\mathbf{n}, \mathbf{c}_{light}=\frac{1}{\pi}\int_{\Omega} L_{tiny}(\mathbf{l}) (\mathbf{n} \cdot \mathbf{l}) d\omega_i[/latex]

The first property says that no light is incoming for any light directions which form an angle greater than [latex]\varepsilon[/latex] with [latex]\mathbf{l_c}[/latex]. The second property follows from the definition of [latex]\mathbf{c}_{light}[/latex]. Since the surface is white, [latex]\mathbf{c}_{diff}=1[/latex]. Applying reflectance equation and Lambert from last article, there’s the second property. Because [latex]\mathbf{c}_{light}[/latex] requires [latex]\mathbf{l_c}=\mathbf{n}[/latex], it is the limit as [latex]\varepsilon[/latex] goes to 0:

[latex]if \mathbf{l_c}=\mathbf{n}, \mathbf{c}_{light}=\lim_{\varepsilon \to 0}(\frac{1}{\pi}\int_{\Omega} L_{tiny}(\mathbf{l}) (\mathbf{n} \cdot \mathbf{l}) d\omega_i)[/latex]

Since [latex]\mathbf{l_c}=\mathbf{n}[/latex] and [latex]\varepsilon \to 0[/latex], we can assume [latex]\mathbf{n} \cdot \mathbf{l}=1[/latex], which gives us:

[latex]\mathbf{c}_{light}=\lim_{\varepsilon \to 0}(\frac{1}{\pi}\int_{\Omega} L_{tiny}(\mathbf{l}) d\omega_i)[/latex]

That is:

[latex]\lim_{\varepsilon \to 0}(\int_{\Omega} L_{tiny}(\mathbf{l}) d\omega_i) = \pi \mathbf{c}_{light}[/latex]

Now we shall apply our tiny area light to a general BRDF, and look at its behavior in the limit as goes to 0:

[latex]L_0(\mathbf{v})=\lim_{\varepsilon \to 0}(\int_{\Omega} \rho(\mathbf{l},\mathbf{v}) \otimes L_{tiny}(\mathbf{l}) (\mathbf{n} \cdot \mathbf{l}) d\omega_i)=\rho(\mathbf{l_c}, \mathbf{v}) \otimes \lim_{\varepsilon \to 0}(\int_{\Omega} L_{tiny}(\mathbf{l}) d\omega_i)(\mathbf{n} \cdot \mathbf{l_c})[/latex]

So

[latex]L_0(\mathbf{v})=\pi \rho(\mathbf{l_c}, \mathbf{v}) \otimes \mathbf{c}_{light} (\mathbf{n} \cdot \mathbf{l_c})[/latex]

As you see, the tiny area light source term disappears. The remaining of our equation is what we familar with.

The second article in this serial discusses the equations in physically-based lighting. The next one is about the BRDF, i.e. [latex]\rho(\mathbf{l_c}, \mathbf{v})[/latex].