Sunstone dev log 29: physical units audit
My main shader calculates radiance () at each pixel of the framebuffer. Currently there are two kinds of light sources: directional and ambient.
Directional light
A directional light has an illuminance (), colour, and direction. Its radiance equation is
where is the surface’s BRDF (parameters omitted), is the light’s irradiance, and is the angle between the light’s direction and the surface’s normal.
The first problem: I’ve given an illuminance for the directional light, so how do I get the irradiance ?
I’m working in the sRGB colour space, which has a linear map to luminance via CIE XYZ:
Since we can compute luminance from an sRGB triple, we can treat the triple as a spectral radiance distribution. My colour components are in the range , so the maximum for a colour is 1. Scaling a triple by gives a triple with with . In other words, a spectral radiance distribution of luminance 1.
So scaling an sRGB triple by (where is luminance) gives a spectral radiance distribution with luminance .
This also relates irradiance and illuminance (), which are the actual quantities used for the directional light.
The second problem: if is irradiance, how does become radiance? The BRDF simply has units .
Ambient light
Ambient light has a luminance () and a colour. The spectral radiance distribution is , giving the radiance equation
I assume that ambient radiance is constant and direction-independence, so factors out of the integral:
The remaining integral is approximated as described here. The BRDF has units , and the integral essentially multiplies by , giving a unitless quantity, when is then used to scale radiance.
Camera
The post-processing shader uses the radiance values to produce the final image. The camera equation computes radiant exposure (), which is written to the framebuffer (see my argument for this here). This is the step where tone mapping can be applied.
Next steps
- Image-based lighting