Day 53 - 🧪 Experiment - Writing a BRDF from Scratch (Part 3)

General / 20 July 2026

Sometimes the constraint is the environment, not the math.

Parts 1 and 2 built a dielectric BRDF: Burley diffuse, GGX specular, and hemisphere ambient. This part extends it to metallic materials and runs into a hard limit in the shader previewer.


Metallic

Metals behave differently from dielectrics. A metallic material absorbs diffuse entirely, so with metalness at 1.0 the diffuse contribution drops to zero. At low roughness, that leaves a mostly dark surface with a sharp specular highlight as the only visible term.


Albedo and Ambient

Adding the diffuse ambient term back in brightens the material noticeably. Without it, the metal reads too dark outside of the specular contribution. The ambient gives enough indirect light for the surface to read correctly.


Specular Ambient

This is where it breaks down. Proper specular ambient requires sampling a cubemap or prefiltered environment texture to capture reflected light. The shader previewer does not support texture sampling, so there is no way to evaluate the reflected environment term correctly.


Result

The shader ends up incomplete, but the failure mode is worth noting. The missing piece is not a math problem. It is an environment problem. A real specular ambient term needs an IBL pipeline: a prefiltered environment map and a BRDF lookup table at minimum. That is out of scope for a single-file GLSL previewer, and a good reason to move this into a proper engine next.


© 2026 Stefan Groenewoud. All views are my own, not those of my employer.