Why the location of lighting matters
A renderer must assign a color to each visible sample of a triangle. It can evaluate a lighting function at each vertex and interpolate the resulting colors (Gouraud shading), or interpolate the vertex normals, normalize the result, and evaluate lighting at each sample (Phong shading). The latter name describes the interpolation scheme here; it is not the same choice as the Phong specular reflection formula. Both schemes approximate a surface using data at finitely many vertices, but the operations occur in a different order. A nonlinear lighting function generally does not commute with interpolation.
Definition 3.3.1
(Perspective-correct weights)
Let be screen-space barycentric weights that sum to one. For attributes defined on the original triangle under perspective projection, use the corresponding perspective-correct weights , where are the positive clip-space homogeneous components. In an orthographic view the weights coincide. Assume a visible triangle has been clipped so these components are positive; the resulting weights are nonnegative, sum to one, and the denominator is nonzero.
Definition 3.3.2
(Vertex-lit and normal-interpolated shading)
Express normals and light and view directions in the same Euclidean coordinate frame; transform normals appropriately under nonuniform scaling. Let be unit vertex normals, a scalar lighting function under fixed light and view directions, and all color calculations be in linear light. The two procedures are
lights the vertices and interpolates the results; interpolates the normal, normalizes it, and lights the sample.
The second expression requires a nonzero interpolated normal. If it vanishes, normalization is undefined and the implementation needs an explicit fallback. If the lighting also depends on position, the comparison must interpolate position consistently and evaluate it at the sample; the formulas above isolate the normal-dependent part.
Normalization changes the answer
Theorem 3.3.3
(A useful equality and its limit)
For the unclamped linear function , interpolating the vertex values equals evaluating the function at the unnormalized interpolated normal: . This equality does not in general survive normalization or clamping.
Proof
(Distributivity of the dot product)
Distributivity of the dot product gives the displayed equality. Normalization divides by the length of the weighted normal, a quantity that depends nonlinearly on the weights; clamping with is nonlinear as well. The next proposition measures exactly what normalization does, and the worked examples supply explicit failures.
Proposition 3.3.4
(The normalization factor)
Let with unit and weights summing to one, and let without clamping. Then , and . Equality holds exactly when all normals with positive weight are equal. Consequently has the same sign as and .
Proof
(Triangle inequality for the weighted normal)
By the preceding equality, , while . By the triangle inequality, .
If , then . Equality in the triangle inequality for Euclidean norms forces the nonzero summands to be nonnegative multiples of a single vector; being unit vectors scaled by positive weights, the normals with then all equal one common unit vector. Conversely, if those normals are equal to , then and . The statements about sign and size follow from dividing by .
Worked example 3.3.5
(A brighter midpoint)
Proof X-ray
Which hypotheses make the length at most one
The inequality uses three facts: the weights are nonnegative, so they can be pulled out of the norms; they sum to one; and each has unit length, so . The real idea is the equality case. Euclidean length is strictly convex, so the triangle inequality is an equality only when the summands point in one direction, and unit length then makes the normals equal. The hypothesis is used to divide, and then preserves the sign of the intensity. None of this holds for the clamped function, which is not linear in .
Take and , and a unit light direction . At the midpoint in the original triangle (not necessarily the screen-space midpoint) use . With diffuse lighting , both vertex intensities are , so . Their mean normal is , which has length and normalizes to ; consequently . The interpolation has not created extra light: it describes a different approximate normal field. Neither answer alone proves which field matches the underlying object.
Counterexample mode
Linearity stops at normalization
A tempting claim: the dot product is linear, so for diffuse lighting normal interpolation must give the same intensity as vertex interpolation. In the previous example, the unnormalized mean normal does give . But a direction used in a cosine law must have unit length, and normalizing divides by , so the result is , not . The equality holds only before normalization (or when all normals with positive weight coincide); the two shading rules are different approximations.
Worked example 3.3.6
(Unequal weights)
Let , , and . The vertex intensities are and , so . The mean normal is with . Then , larger than , as the proposition predicts.
Worked example 3.3.7
(Opposite normals)
Let , for a unit vector . With weights the mean normal is , so is undefined and a fallback is required. With weights , the mean is , which normalizes to and gives . The vertex intensities are and , so . The two methods differ here, and one of them is not even defined at the symmetric point.
A highlight between vertices
Definition 3.3.8
(One-sided empirical specular term)
For a local empirical specular model, let be the unit reflection of the light direction about a unit normal and the unit direction to the viewer. A one-sided model may use for , only when the surface faces the light. Larger concentrates the response near alignment.
In the example above take and . At either endpoint, has , so both vertex specular values are zero. At the midpoint the interpolated unit normal is , giving and . Vertex interpolation returns zero along this edge even though sample-level normal interpolation finds a highlight there.
Counterexample mode
Vertex shading can miss every highlight on an edge
The claim to refute: if the lighting at both endpoints of an edge is dark, the edge is dark everywhere. With the data above, at both endpoints, yet at the midpoint the unit normal is , so and . Vertex interpolation gives along the whole edge. The repair is to evaluate the specular term at samples with an interpolated normal, or to refine the mesh.
This is a counterexample to the claim that vertex shading always captures every highlight. It is not a guarantee that per-sample shading recovers the true surface: if the mesh or vertex normals fail to represent a small geometric feature, interpolating them cannot recover it. It also does not replace visibility, shadowing or a physically calibrated reflectance model. A zero vertex value does not imply a zero nonlinear function between vertices.
Common mistakes
Common mistake
(Phong shading is not the Phong reflection formula)
Phong shading names where lighting is evaluated (at each sample, with an interpolated normal). The Phong reflection formula names how the specular term depends on . One can light interpolated normals with any model, and vertex-lit shading can use the Phong reflection formula.
Common mistake
(Using an interpolated normal without renormalizing)
The mean of two distinct unit normals is shorter than one. In the brighter-midpoint example, . Feeding to a cosine law as if it were a unit direction gives instead of , and the error grows as the vertex normals diverge.
Exercises
Quick check
(Two unit normals are and . At equal weights and with , compute Gouraud diffuse intensity and normalized-normal diffuse intensity.)
Compute the two vertex intensities first, then normalize the mean normal.
Solution · Answer
The vertex intensities are and , giving . The normalized mean is , so .
Quick check
(Two opposite unit normals have equal weights. Can the sample normal be normalized? What does that say about the input field?)
Compute the mean.
Solution · Answer
Their mean is zero, so normalization is undefined. The interpolation field is degenerate at that point; a fallback must be specified, not an arbitrary division by zero.
Quick check
(If , show by an example that interpolation and clamping need not commute, even without normalization.)
Use opposite normals along and against the light.
Solution · Answer
With , and equal weights, the mean of the clamped values is , whereas clamping the dot product of the mean normal gives . This calculation concerns an unnormalized mean and is not a valid normalized-normal shading calculation.
Exercise 3.3.9
(Two unit normals form an angle and have equal weights. For unclamped diffuse lighting, show that .)
CoreProof
Solution(3)
- 1
Expand the squared length of the mean normal
With and unit ,
- 2
Apply the half-angle identity
Key step
Hence . Since , the cosine is positive, so .
Because: .
- 3
Use the normalization-factor proposition
∎For unclamped diffuse lighting . For the angle of the brighter-midpoint example this factor is , matching .