I E

Sunstone dev log 31: diffuse image-based lighting

I’ve added diffuse shading for image lights. The two screenshots below use “Horn-koppe Spring” (CC0) by Grzegorz Wronkowski from Poly Haven.

Damaged Helmet
Bistro

Surfaces facing the sky have a blue tint, while surfaces facing the ground have a green tint. The latter effect is exaggerated in Bistro because ground-facing surfaces (such as the top of doorways) are lit directly by the HDRI. In reality they’d only be lit by sky light reflecting off the floor. The effect looks natural for the floating helmet, though.

Irradiance maps

Physically-based real-time rendering works by approximating the rendering equation:

∫ΩBRDF(x‾,ω‾i,ω‾o)Li(x‾,ω‾i)(ω‾i⋅n‾)dω‾i \int_{\Omega} \text{BRDF}(\bar{x}, \bar{\omega}_i, \bar{\omega}_o) L_i(\bar{x}, \bar{\omega}_i) (\bar{\omega}_i \cdot \bar{n}) \; d\bar{\omega}_i

where

Considering only the diffuse component of a material’s BRDF, this integral becomes

∫Ω1πalbedo(x‾)⋅Li(x‾,ω‾i)(ω‾i⋅n‾)dω‾i=1πalbedo(x‾)∫ΩLi(x‾,ω‾i)(ω‾i⋅n‾)dω‾i \begin{aligned} & \int_{\Omega} \frac{1}{\pi}\text{albedo}(\bar{x}) \cdot L_i(\bar{x}, \bar{\omega}_i) (\bar{\omega}_i \cdot \bar{n}) \; d\bar{\omega}_i \\ = & \frac{1}{\pi}\text{albedo}(\bar{x}) \int_{\Omega} L_i(\bar{x}, \bar{\omega}_i) (\bar{\omega}_i \cdot \bar{n}) \; d\bar{\omega}_i \end{aligned}

where albedo\text{albedo} is a reflectance factor at x‾\bar{x} (essentially the surface colour).

We assume radiance from the image Li(x‾,ω‾i)L_i(\bar{x}, \bar{\omega}_i) is independent of x‾\bar{x}. In other words, the radiance coming from a particular direction is the same at every point. This leaves n‾\bar{n}, a direction, as the only free variable in the integral. The integral can be approximated for many values of n‾\bar{n} and stored in a 2D lookup table indexed by spherical coordinates. This is the irradiance map.

Here are my full derivation notes:

What I built

Next steps

← Sunstone dev log 30: HDRI skybox Newest