Gouraud vs Phong shading

Both canvases draw the same triangle with the same light and the same lighting equation. The only difference is where the equation is evaluated: Gouraud (left, perVertexLighting.vert) lights the three vertices and blends the three colours across the triangle; Phong (right, perFragmentLighting) blends the surface normal and lights every pixel. The vertex normals tilt outward, as on a curved surface, so a specular highlight can fall in the middle of the triangle, where no vertex can see it.

Gouraud: per-vertex shadingthe lighting equation runs 3 times (once per vertex); colours are interpolated
Phong: per-fragment shadingthe lighting equation runs at every pixel; N, L and E are interpolated
Light position (drag on either canvas to move it freely)
Surface, material and shaders

The numbers behind the pictures

Specular term (0 to 1), computed on the CPU with the same arithmetic the shaders use.

WhereGouraudPhong

How to read it