Motivation
Knowing which triangle is visible does not determine its color. A renderer must describe how illumination reaches the surface, how the material redirects that illumination, and how the result is measured by an image. Texture adds spatial variation to the material, while animation changes geometry and appearance over time. These tasks share a recurring question: what quantity does an interpolation actually represent? Interpolating a normal, a stored image value, or a matrix without answering that question can produce a plausible picture with the wrong mathematics.
This note develops a deliberately limited rendering model. We treat opaque triangle surfaces, local diffuse illumination, a simple specular approximation, sampled two-dimensional textures, and basic keyframe motion. We do not claim that a local lighting formula solves global light transport. Shadows, interreflection, transmission, and participating media require additional modeling. The purpose is to make several essential mechanisms precise enough that their limitations are visible.
Color equations below apply componentwise to linear RGB values, unless another interpretation is stated. Linear here means proportional to the corresponding light quantity in the adopted color model. A display-encoded value is generally not linear light. Texture storage, decoding, lighting, blending, and final display encoding therefore need a consistent convention. The same word “color” can otherwise hide incompatible quantities.
Definitions
Definition 3.1.1
(Local reflection model)
At a surface point let be an outward unit normal, and let and be unit directions toward a light and viewer. Irradiance measures incoming power per surface area. A bidirectional reflectance distribution function relates incident illumination from a direction to outgoing radiance toward the viewer. A Lambertian reflector has , where the diffuse reflectance satisfies in a scalar channel.
For a single unoccluded directional source, a common diffuse shading term is proportional to . A point-light model can additionally include inverse-square distance attenuation, provided its source intensity is defined consistently. Clamping the cosine to zero expresses that light arriving from the back does not illuminate the front of an opaque one-sided surface. A shadow test is still needed to determine whether the light direction is occluded.
Definition 3.1.2
(Texture samples and premultiplied alpha)
A texture associates a surface coordinate with a stored sample array or a reconstructed function. Bilinear filtering forms a weighted average of four neighboring texels using the fractional coordinates within one grid cell. For a layer with straight color and opacity , its premultiplied color is . The over operation for foreground over background is
Opacity in this elementary compositing model describes an image-layer mixture. It should not be silently equated with a full physical model of refractive glass. Straight color is recovered by dividing premultiplied color by alpha only when alpha is positive; a fully transparent layer has no uniquely recoverable straight color from its premultiplied representation.
Theorem / proposition
Theorem 3.1.3
(Lambertian normalization and energy bound)
For a Lambertian BRDF on a hemisphere, the hemispherical reflected fraction under the BRDF energy test is
Consequently ensures that this diffuse model does not reflect more incident energy than it receives. Under constant incident radiance , its outgoing radiance is .
Theorem 3.1.4
(Premultiplied over is associative)
For layers with premultiplied colors and opacities in the stated range,
The layers must keep the same front-to-back order. The operation is generally not commutative.
The first theorem explains a normalization often omitted when a lighting formula is presented only as an artistic rule. Some practical shaders absorb constants into light parameters, so inspecting a missing visible alone does not diagnose a bug. One must check what the parameters mean. The second theorem justifies grouping precomposited image layers, but gives no permission to reorder transparent surfaces.
Proof sketch or proof idea
Proof
(Lambertian normalization from the hemisphere integral)
In spherical coordinates over the upper hemisphere, , with . Thus
Multiplication by proves the energy test. The reflected radiance under a constant incident field is the same integral multiplied by . This calculation assumes the hemisphere is unoccluded and the incoming field is constant; it does not justify replacing a general environment by one point light.
Concept lensGeometric
The cosine weight as projected area
Project each direction of the upper hemisphere straight down onto the unit disk in the horizontal plane: . The area element of the disk is . So is exactly the area of the shadow a patch of directions casts on the disk, and the total is the area of the unit disk. Lambertian normalization therefore says that the reflected fraction is times the disk area divided by .
Proof
(Associativity from composite transmittance)
For associativity, write , the transmittance of layer . The over rule gives composite transmittance . Either grouping of three layers has color
and transmittance . Multiplication and addition are associative in exact arithmetic, so both results agree. Floating-point rounding can make differently grouped numerical computations differ slightly without invalidating the algebraic identity.
Concept lensAlgebraic
A layer acts as an affine map on the background
An image layer maps a background color to . Compositing is composition of these affine maps. Its associativity is therefore the associativity of function composition. The fixed term records the light supplied by the layer, and the multiplier records how much background remains. Reversing two maps usually changes the fixed term, explaining the importance of layer order without relying on an example alone.
Worked examples
Worked example 3.1.5
(Normalize the normal before evaluating diffuse light)
Let be an unnormalized interpolated normal and let the light direction be . Normalizing gives and . With a diffuse coefficient and a light factor in a convention absorbing the constant normalization, the diffuse term is . Using the unnormalized dot product would produce . Renormalization is needed even if all vertex normals started at unit length, because a nontrivial average of unit vectors need not have unit length.
Worked example 3.1.6
(Bilinear reconstruction inside one cell)
For fractional coordinates , bilinear weights at corners are , hence . With scalar texels the result is . The weights are nonnegative and sum to one, so the result lies between the smallest and largest texel values. That range property does not mean the filter preserves every sharp feature or removes minification aliasing.
Worked example 3.1.7
(Two translucent layers cannot exchange places)
Let a half-opaque red layer have premultiplied color and a half-opaque blue layer . Red over blue gives with alpha ; blue over red gives with the same alpha. Over a black opaque background these are the displayed linear colors. Equal final opacity does not imply equal color, so an opaque depth-buffer strategy cannot simply be reused for transparency.
Shading models and the stage at which they are evaluated
Definition 3.1.8
(Where lighting is evaluated)
With flat shading a single normal or lighting value describes a face. In Gouraud-style shading, lighting is evaluated at vertices and the resulting colors are interpolated. In Phong-style normal interpolation, a nonzero interpolated surface normal is normalized, and a lighting model is evaluated at the image sample.
If the interpolation vanishes, for example by equally averaging opposite unit normals, a separate normal or shading convention is required; there is no unit vector to obtain by normalization. These describe where computation happens; a specular reflection formula commonly associated with the same name is a separate choice. A narrow highlight can fall between vertices, so vertex lighting can miss it even when interpolation itself is implemented correctly.
For a simple specular approximation, reflect the incident direction about a unit normal to obtain , and add a term proportional to , with exponent . Increasing narrows the lobe. This is an empirical local model, not automatically an energy-normalized BRDF. Adding diffuse and specular terms with arbitrary coefficients can violate an energy budget; the Lambertian theorem does not certify the entire combined shader. Also require the surface to face the light before using the intended one-sided highlight.
Texture filtering is a sampling problem
Texture coordinates should first be perspective-correctly interpolated as derived in the previous note. A wrap rule then determines values outside the stored range: repeat, mirror, or clamp are different extensions of the texture function. At boundaries, filtering must use the same extension. A seam may come from a wrap choice, a coordinate discontinuity, or mismatched edge texels; merely increasing texture resolution does not identify which cause is present.
Bilinear filtering reconstructs a continuous function within grid cells, but a pixel may cover many texture cells. Sampling one reconstructed point cannot accurately average an arbitrarily oscillatory texture over that footprint. Mipmapping stores successively reduced representations and selects a scale according to the projected footprint. Interpolating between levels reduces abrupt scale changes. A long narrow footprint motivates anisotropic filtering because one scalar scale cannot simultaneously match its long and short directions. Filter construction and level selection determine the approximation; the existence of a pyramid alone is not a proof of antialiasing.
Texture values also have meanings. A color texture may require decoding into linear light before filtering or lighting; a normal map encodes directions and needs a consistent tangent frame and renormalization of nonzero reconstructed vectors. A height value is neither a color nor a normal. In data visualization, a color map further encodes a numerical variable, so the chosen scale, units, missing-value convention, and perceptual ordering affect interpretation. A visually smooth gradient cannot establish that equal color changes represent equal data differences.
Animation needs a geometric interpolation model
Definition 3.1.9
(Keyframe interpolation and easing)
For keyframe times , define normalized time on the interval. A translation can be interpolated as . It moves at constant velocity with respect to physical time. An easing function replaces to change the speed profile while preserving endpoints when .
For , the derivative vanishes at both endpoints, producing a stop at each end rather than constant speed.
Rotations need additional care. In a plane, interpolating angles gives rotations that remain orthogonal. The angle difference must specify a direction and account for periodicity: going from degrees to degrees can mean a short -degree forward turn or a long backward turn. In three dimensions, unit quaternions give one useful rotation representation. A quaternion and its negative represent the same rotation; choosing consistent signs matters before interpolation. General interpolation and singular cases require their own treatment and are beyond this note.
Hierarchical animation composes local transforms. Rotating a joint changes the coordinate frame for its descendants, so a hand position depends on the ordered chain from root to hand. Evaluating animation by frame number alone makes speed depend on frame rate. Evaluate by time, then sample the resulting motion at display times. Fast motion or changing illumination may still alias temporally; increasing spatial texture quality does not repair insufficient temporal sampling.
Common mistakes
Counterexample mode
Averaging rotation matrices can collapse an object
In two dimensions, and are both valid rotations. Their entrywise midpoint is the zero matrix, which maps every point to the origin. It has determinant zero and preserves no nonzero length. The repaired rule is to choose an interpolation that stays in the rotation group, such as a declared planar angle path. Matrix interpolation is acceptable only when the resulting affine deformation, including possible shrinkage, is actually the intended model.
Common mistake
(Filtering straight color beside transparent texels)
Straight RGB filtered next to transparent texels lets hidden color receive weight without the corresponding opacity, which creates fringes. Filtering premultiplied color and alpha together, then compositing consistently, avoids that particular mismatch.
Common mistake
(Averaging display-encoded values as linear light)
Premultiplication does not fix color-space errors: the average of display-encoded values generally differs from the encoding of the average linear light. As an illustration with a simple square-root encoding (not a standard one), linear values and are encoded as and . Averaging the encoded values gives , which decodes to linear , whereas the average linear light is encoded as . Every stage must preserve the meaning of the quantity being averaged.
Summary
Local reflection uses normalized geometry and a declared light model. Lambertian normalization gives a checkable energy bound, while an arbitrary specular addition needs separate justification. Texture reconstruction and footprint filtering solve different problems. Premultiplied compositing is associative but order-sensitive. Animation requires interpolation within the intended geometric family and sampling in time. These mathematical distinctions explain several common rendering failures without pretending that a short local shader constitutes a complete renderer.
Exercises
Quick check
(Evaluate directly and find the outgoing Lambertian radiance when and constant incident radiance is .)
Integrate azimuth and polar angle separately.
Solution · Answer
Integrating azimuth gives , and , so the integral is . The outgoing radiance is . The factor cancels because the entire hemisphere has constant incident radiance.
Quick check
(Bilinearly filter texels at . Explain why this value cannot exceed for any in the cell.)
Write the four weights and add them.
Solution · Answer
Weights are , giving . For every point in the cell the weights are nonnegative and sum to one, making the result a convex combination of the texels; it lies in . This is a range bound, not an image-detail guarantee.
Quick check
(A foreground layer has straight color and alpha . Composite it over an opaque background . Give the premultiplied result and final alpha.)
Premultiply the foreground first.
Solution · Answer
The foreground premultiplied color is . The background already has alpha one, so over gives and alpha . Dividing by final alpha changes nothing. Reversing the layers would instead yield the opaque blue background alone.
Exercise 3.1.10
(A translation moves from to meters over two seconds using . Compute its position and velocity at one second, and compare with constant-speed interpolation.)
Core
Solution(4)
- 1
Convert time to the normalized parameter
The position is . At we have .
- 2
Evaluate the position
, so meters.
- 3
Differentiate with the chain rule
Key step
meters per second. At this is .
Because: .
- 4
Compare with constant speed
Constant-speed interpolation also has position at one second, but its velocity is throughout. Equal midpoint positions therefore do not imply equal motion, and the eased path has zero velocity at both endpoints.