July 13, 2026 · 5 min read
✨ Math test: the rendering equation, briefly
A KaTeX-heavy mockup post used to test inline and block math rendering. Safe to delete.
Note to self: mockup post to test KaTeX (inline + block, fractions, integrals, Greek, matrices). Delete before launch.
Almost everything a technical artist touches in lighting traces back to one equation. It looks intimidating written out, but each piece has a plain-language job. Here it is.
The equation
The outgoing radiance from a point in direction is the emitted light plus everything reflected from the hemisphere above the surface:
Reading it left to right: take the emitted light , then add up — that's the integral — the contribution of every incoming direction , weighted by how the surface reflects it and how grazing the angle is.
The pieces
- — the light arriving from direction .
- — the BRDF, the surface's rule for turning incoming light into outgoing light.
- — the cosine term, . Light hitting head-on counts fully; light at a grazing angle barely counts at all.
That cosine is why a floor looks bright underfoot and dim toward the horizon.
A concrete BRDF
For a simple diffuse surface with albedo , the BRDF is just a constant:
The in the denominator is the part everyone forgets — it's what keeps energy conserved so a surface never reflects more light than it receives.
Specular is where it gets interesting. The Fresnel term, using Schlick's approximation, is:
where is the reflectance at normal incidence. For most dielectrics , which is why even matte plastic gets a bright rim at grazing angles.
Why the integral is hard
We can't evaluate exactly in real time, so we approximate it. Monte Carlo integration samples random directions and averages:
The is the probability of picking each sample — importance sampling just means choosing to match where is large, so you spend samples where they matter.
A tiny bit of linear algebra
Transforming a normal isn't the same as transforming a position. If is your model matrix, normals must use the inverse-transpose:
For a rotation like
the inverse-transpose equals itself, which is why pure rotations never distort your normals — but non-uniform scale does, and that is the usual culprit behind broken lighting.
Wrapping up
You rarely type these equations into a shader directly, but knowing what each term does turns "the lighting looks wrong" into a diagnosis. The cosine, the , the Fresnel rim — each one is a knob with a physical meaning.
If the math above rendered as crisp symbols rather than raw dollar signs, KaTeX is working.