Skip to content
On this page

Lambertian

Lambertian lighting, named after Johann Heinrich Lambert, is one of the most fundamental and widely used models for diffuse reflection in computer graphics.

It works on the principle that light striking a surface is scattered evenly in all directions, perfect for matte materials such as chalk, clay, unpolished stone, etc.

Its strength lies in its simplicity: brightness depends only on the cosine of the angle between the surface normal and the incoming light direction. This is known as Lambert’s Cosine Law.


Visual demo

Shader Story: Lighting Models - Lambertian


Complete per-vertex and per-pixel implementations, with detailed comments, are available on Patreon.

// Pseudo-code (Complete per-vertex and per-pixel implementations, with detailed comments, are available in the related Patreon post)


float3 SurfaceColor;          // surface color
float3 LightColor;            // light color * intensity
float LightAttenuation;       // shadowing / distance falloff

float NdotL = max(0.0, dot(normalDirection, lightDirection));

float LambertDiffuse = NdotL * SurfaceColor; // Lambert's cosine law
float3 finalColor = LambertDiffuse * LightAttenuation * LightColor;

Basic idea

Light is emitted from a source, reflected from the surface, and perceived by the viewer (camera).

Shader Story: Lighting Models - Lambertian. Basic Idea

Cosine Falloff

The amount of diffuse reflection decreases with the angle between the surface normal N and the light reflection direction L.

Shader Story: Lighting Models - Lambertian. Cosine Falloff

Spherical Falloff

Diffuse light contribution also decreases with distance, following the light’s attenuation curve (0 to 1).

Shader Story: Lighting Models - Lambertian. Spherical Falloff

Lambertian Equation

d = Σ (from i=0 to n) [ intensity(light_i) × diffuse(material_property) × attenuation(light_i) × max(0, N · L) ]

The final diffuse d is computed as the sum over all lights of their intensity, the surface’s diffuse material property, light attenuation, and the Lambertian cosine factor max(0, N·L). It ensures that light contributes proportionally to how directly it strikes the surface.


Max • Dot


❤️ Support Shader Story

If this article helped you, consider supporting the project on Patreon: you’ll get access to the related source files and reference cheat-sheets.

DecompiledArt on Patreon DecompiledArt on Buy Me a Coffee

Your support helps keep this library open and free for everyone.