Skip to content
Light · TechniqueBeginner

Diffuse (Lambert)

Brightness from how squarely a surface faces the light, the same from every viewing angle.

NormalSurface

Cards

One live example to tweak, learn and copy.

How it works

Diffuse light is the soft, matte part of shading: the light a surface scatters equally in every direction, so it looks the same wherever the camera stands. Its brightness depends on one thing, the angle between the surface and the incoming light, and Lambert’s cosine law says how: it follows the cosine of that angle.

In a shader that cosine is a single dot product between the unit surface normal and the unit direction toward the light, clamped at zero so surfaces turned away get no light rather than negative light:

float diffuse = max(dot(n, toLight), 0.0);
vec3 color = albedo * (lightColor * diffuse + ambient);

That one line is the base of almost every lighting model. Engines run it once per light and add the results; toon shading cuts it into bands; specular highlights sit on top of it; physically based shading divides it by π and pairs it with a microfacet specular term. Getting it right comes down to three checks: both vectors are normalized, both are in the same space, and the light vector points from the surface toward the light, not the way the light travels.

Diffuse alone looks like chalk or clay. What it lacks is anything that depends on the viewer: shine, rims, reflections. Those are the Specular highlights and Fresnel techniques.

Further reading