Shader Story
September 19, 2025 · View on GitHub
Lighting Models : 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
// Pseudo-code (Complete per-vertex and per-pixel implementations, with detailed comments, are available in the related Patreon post)
// Link: https://www.patreon.com/posts/shader-story-137878509
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;
Complete per-vertex and per-pixel implementations, with detailed comments, are available on Patreon.
Basic idea
Light is emitted from a source, reflected from the surface, and perceived by the viewer (camera).
Cosine Falloff
The amount of diffuse reflection decreases with the angle between the surface normal N and the light reflection direction L.
Spherical Falloff
Diffuse light contribution also decreases with distance, following the light’s attenuation curve (0 to 1).
Lambertian Equation
d = Σ (from i=0 to n) [ intensity(light_i) × diffuse(material_property) × attenuation(light_i) × max(0, N · L) ]
- Summation over all incident light sources
- Surface diffuse property (material roughness, 0 → black / 1 → full reflection)
- Light attenuation (distance and shadow falloff)
- Cosine factor max(0, dot(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.
🔗 Related Functions
❤️ Support Shader Story
If this article helped you, consider supporting the project on Patreon - you'll get access to the related source files, reference cheat-sheets, and other exclusive resources:
Your support helps keep this library open, growing, and free for everyone.