### Per-vertex vs. Per-pixel Lighting

Drag on either object to rotate both.

Per-vertex |
Per-pixel (Phong) |

### About this demo...

This demo lets you compare OpenGL 1.1-style lighting to Phong shading. In OpenGL 1.1, lighting calculations are done at the vertices, and the result is interpolated to interior pixels. In Phong shading, lighting calculations are done at each pixel, using interpolated normal vectors. The demo shows two identical objects with identical lighting, one doing lighting calculations at the vertices and one doing them at each pixel.

The initial view is chosen to be one where the difference is clear: a cylinder illuminated by a light that is close to the cylinder. All of the vertices of the cylinder are located along the top and bottom edges, so per-vertex calculations do not give good results. Try rotating the cylinders around the x-axis and observer how the specular highlights change.

You can try other lights and other objects. The cube and the "rough sphere" are other cases where the per-vertex approximation gives especially bad results. For the torus, which is made of very small triangles, the approximation is pretty good. It can be instructive to look at the (regular) sphere, which has medium-sized triangles.

Specular highlights are not the only thing that is improved by per-pixel lighting. For example, compare the different amounts of "striping" on the cylinder for the two lighting techniques.