Shader Learn

07 Surfaces and light

dot: the simplest lighting

The more a surface faces the light, the larger the dot product, the brighter it is.

-22
-22
00.5

Runs once per pixelDrag numbers, or edit the code

JS sidegl.uniformMatrix4fv(uModel, …) // rotation -0.35 / 0.10

The dot of two unit vectors is the cosine of their angle; max(dot(N, L), 0) is Lambert diffuse lighting.

Try it

  • Move the light behind the object
  • Set ambient to 0: the unlit side goes fully black