skip to content

Why does a low-polygon sphere's highlight look faceted or jump between vertices, and how do flat, Gouraud and per-fragment shading differ?

level: middleimportance: should knowfreq 60%

answer

  1. how often lighting is evaluated
  2. interpolate colours or normals
  3. highlight peaks between vertices
  4. interpolated normals come out shorter

basics

~20 s

Flat shading lights each triangle once, Gouraud lights each vertex and interpolates the colour, and per-fragment shading interpolates normals and lights every pixel. Gouraud misses or smears highlights that peak between vertices; per-fragment shading keeps them.

solid answer

~50 s

The choice is how often lighting is evaluated. **Flat** shading uses one normal per triangle, so a curved surface shows every facet. **Gouraud** shading evaluates the lighting model at each vertex with that vertex's smoothed normal and interpolates the resulting colour across the triangle. Diffuse light varies slowly and survives, but a tight specular highlight peaking inside a triangle is missed, because every vertex computed almost no specular; when the peak lands on a vertex it smears into a star across the neighbouring triangles, and it jumps from vertex to vertex as the sphere turns. **Per-fragment** shading, historically called Phong shading, interpolates the normal instead and evaluates lighting per pixel, so the highlight sits where it should. The interpolated normal must be **renormalised**, because blending unit vectors shortens them and dims the highlight. Per-fragment lighting costs one evaluation per covered pixel rather than per vertex.

go deeper

for a junior

Name the three shading frequencies, what each one lights (face, vertex or pixel) and what a low-polygon sphere looks like under each.

for a middle

Explain why Gouraud drops or smears a tight highlight, why interpolated normals need renormalising, and the naming difference between Phong shading and Phong's model.

for a senior

Choose a frequency per lighting term from the mesh's screen size and the term's frequency content, and diagnose dimmed or jumping highlights from their pattern.

for a principal

Decide where a project's low-end path may drop to per-vertex lighting and how that choice is kept consistent with art that was authored per pixel.

## Three shading frequencies **Shading frequency** is how often the lighting model runs across a surface. The lighting maths can be identical in all three; only the input normal and the number of evaluations change. | Frequency | Normal used | Lighting evaluated | Look on a low-polygon sphere | |---|---|---|---| | **Flat** | one per triangle (the face normal) | once per triangle | visible facets, uniform colour per face | | **Gouraud** | smoothed per-vertex normals | once per vertex, colour interpolated | smooth diffuse, missing or star-shaped highlights | | **Per-fragment** | per-vertex normals interpolated, then renormalised | once per covered pixel | smooth diffuse and correct highlights | A naming trap sits in the middle of this table: **Phong shading** means per-fragment shading with interpolated normals, while the **Phong reflection model** is the specular formula. Both come from the same 1970s work and are easily confused; per-fragment shading can evaluate Blinn-Phong or a physically based model just as well. ## Why Gouraud loses the highlight Take a sphere of about 480 triangles and 240 vertices, with a specular exponent high enough that the highlight is smaller than one triangle. - **Peak inside a triangle.** All three vertices are far from the highlight's centre, each computes nearly zero specular, and interpolating three small values gives a small value everywhere. The highlight disappears. - **Peak on a vertex.** That vertex gets the full highlight and its neighbours almost none, so the brightness spreads linearly across every triangle that shares the vertex: a star or diamond shape whose size is set by the mesh, not the material. - **Rotation.** As the sphere turns, the peak passes between vertices, so the highlight brightens, vanishes and reappears, jumping across the surface. - **Mach bands.** Even diffuse Gouraud shading has creases in its gradient along triangle edges, and the eye exaggerates them into faint light and dark lines. Flat shading fails earlier: with one normal per face every triangle gets one colour, and a highlight lights a whole facet or none. ## Per-fragment shading and renormalisation Per-fragment shading moves the lighting maths to the pixel: 1. Each vertex carries a smoothed normal, the average of its adjacent face normals for a soft surface. 2. The rasterizer interpolates that normal across the triangle, as it would any per-vertex value. 3. The fragment program **renormalises** the interpolated normal to unit length. 4. It evaluates the lighting model with that normal, the light vector and the view vector. Step 3 is easy to forget. A linear blend of two unit vectors is shorter than 1: halfway between two normals that differ by an angle `a`, the length is `cos(a / 2)`. On a 16-slice sphere adjacent normals differ by 22.5 degrees, so the midpoint normal has length `cos(11.25°)`, about 0.98. That shrinks `dot(n, h)` by 2%, and an exponent of 32 magnifies the error: `0.98^32` is about 0.54, roughly halving the highlight midway between vertices. ## What each costs - **Per-vertex** work runs about once per vertex, which shared vertices make cheap: on the order of 240 evaluations for the sphere. - **Per-fragment** work runs once per covered pixel. If the sphere covers a disc 200 pixels across, that is `pi * 100^2`, about 31,000 evaluations, roughly 130 times as many. - The balance flips for **distant or dense meshes**: a detailed model covering a few hundred pixels can have more vertices than pixels, so per-vertex lighting saves nothing there. ## Choosing today Per-fragment lighting is the default on current hardware, because highlights, normal maps and physically based materials all need a per-pixel normal. Per-vertex lighting still earns a place where its error cannot be seen: - diffuse-only contributions from many dim, minor lights; - distant levels of detail and dense meshes; - very low-end targets and deliberately stylised looks. Flat shading is mostly a style choice now, or the result of **hard edges**, where vertices are duplicated so each face carries its own normal. That duplication is how one lighting path gives a cube crisp edges and a sphere smooth ones. A complete answer names what each frequency interpolates, explains the missing and jumping highlight, includes renormalisation with a number that shows why it matters, and compares per-vertex and per-pixel counts for the mesh's real screen size.

  • Is Phong shading the same thing as the Phong reflection model?
    No. Phong shading is a shading frequency: interpolate the vertex normals across the triangle and evaluate lighting per pixel. The Phong reflection model is a specular formula built on the mirrored light vector. They share a name because they were published together, but per-fragment shading can evaluate Blinn-Phong or a physically based model, and Gouraud shading can evaluate Phong's reflection model at each vertex.
  • When is per-vertex lighting still a sensible choice today?
    Where its error cannot be seen and its saving is real: diffuse light from many dim secondary lights, which varies slowly across a triangle; distant levels of detail and dense meshes, where vertices approach the number of covered pixels; and very low-end targets. Tight specular highlights and normal-mapped detail still need per-pixel evaluation.
  • How does one lighting path give a cube hard edges and a sphere smooth shading?
    Through the mesh's normals. A sphere shares each vertex between its faces and stores one averaged normal, so shading blends smoothly. A cube duplicates each corner vertex once per face, each copy carrying that face's normal, so lighting changes abruptly at the edge. Artists mark edges as hard or soft, and the exporter splits vertices along the hard ones.

  • Phong shading simply means using the Phong reflection model.
  • Interpolated normals stay unit length, so renormalising them per fragment is wasted work.
  • Gouraud shading's only flaw is that curved surfaces look faceted.
  • Per-fragment lighting always costs more than per-vertex lighting, whatever the mesh's screen size.
  • A sharper texture fixes a specular highlight that disappears between vertices.