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.
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:
where
- and are the directions to the light and to the viewer, respectively
- is the point being illuminated
- is the normal at
- is the bidirectional reflectance distribution function
- is the radiance at in direction
Considering only the diffuse component of a material’s BRDF, this integral becomes
where is a reflectance factor at (essentially the surface colour).
We assume radiance from the image is independent of . In other words, the radiance coming from a particular direction is the same at every point. This leaves , a direction, as the only free variable in the integral. The integral can be approximated for many values of 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
Compute shader that populates an irradiance map texture
It approximates the integral by averaging uniformly spaced directions over the hemisphere.
Improved bindless (“descriptor indexing”) texture management
The irradiance map texture also lives in the big texture array, and is created in response to loading a HDRI.
Next steps
- Specular image-based lighting