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.
The numbers behind the pictures
Specular term (0 to 1), computed on the CPU with the same arithmetic the shaders use.
| Where | Gouraud | Phong |
|---|
How to read it
- Above the centre. The light sits over the middle of the triangle. Phong shows a bright spot there. At the three vertices the highlight is nearly zero, so Gouraud has nothing bright to interpolate and misses the highlight completely.
- Above a vertex. With the default placement the highlight lands exactly on that vertex. Both models show it there, because the vertex is where Gouraud evaluates the equation. Gouraud smears it into a linear fade toward the other two corners, so the centre reads about a third as bright (the average of the vertex values) even though the true highlight is nowhere near the centre; Phong keeps a tight spot. Switch the placement to “straight above” to see that a light directly over a vertex does not put the highlight on it, because the normal there is tilted.
- Between the two. Drag the light slowly from a vertex toward the centre and watch the Gouraud highlight fade away while the Phong highlight travels with the light.
- Curvature. With curvature 0 the surface is flat and the two pictures are much closer. The normals changing across the triangle is what Gouraud cannot represent.