Light and mirrors

A shadow is a second projection

The construction that puts a shadow on the ground is the construction that puts the scene on the picture plane, with the lamp where the eye was. Shadow drawing is taught as a separate set of recipes and it is one operation with the centre moved, which is why the same code draws both.

A shadow is where the light does not reach because something is in the way. Geometrically, the shadow of a point on the ground is where the line from the light through the point meets the ground.

That is a projection of the point onto the ground plane, from the light as centre. It is the same operation the camera performs when it projects the scene onto the picture plane from the eye as centre — the same function, with two arguments changed.

A box and its shadow, both projections from a pointThe rays from the lamp to the corners are the same construction as the rays from the eye to the corners — one operation, two centres.correct from 26 cm, at 160 mm wide34° across
Fig. 1 A box, its shadow, and the rays from the lamp to the corners. Those rays are the same construction as the rays from the eye to the corners; only the centre is different. The shadow’s outline is a projection of the box.

On this site that is not a figure of speech: projectToGround is called by the camera code and by the shadow code, with the eye and the lamp respectively. One function, two uses, and if it were wrong both would be wrong together.

Why the shadow of a straight line is straight

The fact that makes shadow construction possible at all, and it is worth deriving because everything else rests on it.

Take a straight world line and a point light. The light and the line together define a plane — a straight line and a point not on it always do. Every ray from the light to a point of the line lies in that plane, so every shadow point lies in it too. The shadow also lies on the ground. So the shadow is the intersection of two planes, which is a straight line.

Measured on the site’s figures, the bend in the shadow of a straight edge is 5.7 × 10⁻¹⁴ px over a 314 px span, which is arithmetic noise.

The consequence is the one that makes hand construction feasible: the shadow of a segment is determined by the shadows of its two endpoints. Find those two, join them, done. Nothing in between needs constructing.

The two cases, which are the two families again

Light comes in two geometric kinds and they line up exactly with the two families of projection.

A point lamp is a centre of projection at a finite place, so shadow-casting from it is a perspective projection onto the ground. Shadows diverge, they grow with distance from the lamp, and the shadows of parallel world lines are not parallel.

The sun is a centre of projection at infinity — its rays are parallel — so shadow-casting from it is a parallel projection onto the ground. Shadows of parallel world lines stay parallel in the world, and a post’s shadow is the same length wherever the post stands.

Those are the two families of drawing system, appearing again in a completely different context. The coincidence is not one: both are the same distinction between a finite and an infinite centre, and everything true of one pair is true of the other.

It also means the two cases of shadow construction, which are usually taught as unrelated recipes with different rules, are one operation with the centre moved — exactly as a parallel drawing is a perspective one with the eye at infinity.

The rays and the shadow rays

Constructing a shadow in a picture involves two families of lines, and keeping them apart is most of the skill.

The light rays run from the light through each object point to its shadow. In the picture they converge at the image of the light itself for a lamp, or at the vanishing point of the light direction for the sun.

The shadow lines run along the ground from the foot of each object point to its shadow. In the picture they converge at the image of the lamp’s foot — the point directly below it on the ground — or at the vanishing point of the sun’s ground-projected direction, which is on the horizon.

Every shadow construction is the intersection of one of each. For a vertical post: the light ray from the lamp through the post’s top, and the shadow line from the lamp’s foot through the post’s base. Where they cross is the top of the shadow.

That two-family structure is why shadow construction feels harder than it is. There is nothing in it but two vanishing points and an intersection, and the difficulty is entirely in noticing that the two families are different and have different vanishing points.

Six posts in sunlight from 34°The shadows are parallel in the world, so in the picture they meet at one point on the horizon — found from the drawn shadows to 3e-13 px.horizonshadows meet at x = -58, off the frameon the horizon, as it must be
Fig. 2 The sun case, with the shadow lines’ vanishing point found from the drawn shadows. It lies on the horizon, as it must, because the sun’s ground direction is horizontal.

The lamp’s foot, which is where the second family meets

For a point lamp the shadow lines converge at the image of the lamp’s foot, and that is a fact with a short proof and a useful consequence.

The shadow line of a vertical post runs from the post’s base to the shadow of its top. Both those points are on the ground. The plane containing the lamp, the post and its shadow is vertical, and it cuts the ground in a line through the lamp’s foot. So every such shadow line passes through the lamp’s foot.

The consequence for drawing: place the lamp and its foot — one above the other in the picture, on the same vertical — and every shadow line is a line from the foot. That is the single most useful fact in lamp-lit shadow construction and it is why the foot gets marked in every worked example.

It also gives a check on a picture made by someone else. Extend the shadow lines of several objects lit by one lamp; they must be concurrent; and the point they meet at must be vertically below the light. If they are not concurrent, the picture’s shadows were not constructed from one light — which happens constantly in illustration and is the commonest reason a rendered scene looks subtly wrong.

What is not being computed here

The geometry above says where the shadow’s outline goes, and that is all it says.

Everything else about a shadow is physics rather than projection: how dark it is, whether its edge is sharp or soft, how quickly it fades, whether there is a penumbra, how much light bounces back into it from surrounding surfaces. A shadow from a real lamp has a penumbra whose width grows with distance from the occluder and with the size of the source; the sun’s angular diameter of half a degree gives a penumbra that is small nearby and metres wide for a tall building’s shadow.

None of that is here. This site computes the boundary of the region a point source cannot reach, and treats the source as a point, which is exactly the idealisation that makes the boundary a projection.

It is worth stating because the outline is the part that has to be geometrically right for a picture to read, and the softness is the part that has to be physically right for it to look real. They are separate problems and only the first is a projection.

Shadows on things that are not the ground

The construction generalises to any receiving surface, and the generalisation is the same operation with a different plane.

For a shadow falling on a wall: the light ray from the source through the object point continues until it meets the wall, and the intersection with the wall’s plane replaces the intersection with the ground. Everything else is unchanged.

For a shadow that crosses from the ground onto a wall, the outline breaks at the wall’s base and changes direction there. That kink is the intersection of the shadow’s own plane with the two receiving planes, and getting it right is one of the tells of a carefully constructed picture — an outline that runs up a wall without kinking has been drawn rather than constructed.

For a curved receiving surface the shadow of a straight line is no longer straight, for the same reason a straight line on a curved picture surface is not straight. The plane through the light and the line cuts the surface in a curve, and the curve is whatever the surface makes it.

Shadow length against the sun's elevationA 1 m post casts a 1 m shadow at 45° and a 5.7 m shadow at 10°. The curve is a cotangent and it has no upper bound.024620406080elevation of the sun (degrees)length of the shadow of a 1 m post (m)45° — shadow equals heightcot of the elevationunbounded as the sun sets
Fig. 3 The one quantity the geometry fixes once the light’s elevation is chosen: shadow length as a cotangent of the altitude, unbounded as the light gets low.

Constructing it, step by step

The full construction for the commonest case — a vertical post, a point lamp — is four lines and no judgement.

Mark the lamp in the picture and its foot, directly below it on the ground. These are the two centres the construction uses.

From the foot, draw a line through the post’s base. The shadow lies along it.

From the lamp, draw a line through the post’s top. The ray lies along it.

Where the two cross is the tip of the shadow.

For sunlight, the same construction with two vanishing points in place of the two points: the shadow direction’s vanishing point on the horizon, and the ray direction’s vanishing point above or below it.

That is the entire method. Everything else in shadow drawing — objects with several edges, shadows crossing from ground to wall, sloping surfaces — is repeated application of it to different points.

Which faces are lit

The geometry also decides what is in shadow on the object itself, and this is a separate question from where the cast shadow falls.

A face is lit when the light is on the same side of its plane as its outward normal, which is a sign test on a dot product. Faces failing it are in shade — self-shadowed — and the boundary between lit and shaded faces on a smooth object is the terminator.

For a polyhedron the test is per-face and trivial. For a curved surface the terminator is the locus where the surface normal is perpendicular to the light direction, which for a sphere under a distant light is a great circle, and the cast shadow is the projection of that circle onto the receiving surface.

That gives a check worth having: the cast shadow of a sphere under sunlight is an ellipse, being the parallel projection of a circle onto a plane, and it is the projection of the terminator rather than of the sphere’s silhouette from the camera. Those are different circles, and drawing the shadow as the silhouette flattened is the standard error.

Contact, which is what makes a shadow read

One practical note that is geometry rather than physics, because it is easy to get wrong and it is what makes objects sit on surfaces in a picture.

An object touching the ground has its shadow touching it at the point of contact, always, whatever the light direction. The shadow of the contact point is the contact point, since a point on the receiving surface is its own shadow.

An object above the ground does not: its shadow is detached, and the gap grows with the height and with the shallowness of the light. That gap is the single strongest cue that something is floating, and the reason a rendered object with a missing or misplaced contact shadow reads as pasted on.

So the geometry decides not only where the shadow is but whether the object appears to be in the scene at all. Both are consequences of the same projection, and neither has anything to do with how dark the shadow is drawn.

Six posts in sunlight from 34°The shadows are parallel in the world, so in the picture they meet at one point on the horizon — found from the drawn shadows to 3e-13 px.horizonshadows meet at x = -58, off the frameon the horizon, as it must be
Fig. 4 The parallel case, with the shadow lines’ vanishing point found from the drawn shadows and checked against the horizon.
A box over a reflecting floor, with the reflection computed twiceReflecting the scene and reflecting the camera disagree by 315 px and agree to 0e+0 px once one image axis is reversed — which is what a mirror reversing handedness looks like in numbers.grey: the reflectiontwo routes, agreeing to 0e+0 px after one flip
Fig. 5 And the third use of the same machinery: a reflection is the view from a camera on the far side of the mirror, computed with the identical projection code.
A family of parallel ground lines at 30°, and where they meetAll five lines pass through one point on the horizon, off the edge of the frame at x = 1464.horizon — the image of the line at infinityvanishing point at x = 1464 — off the framecorrect from 26 cm, at 160 mm wide34° across
Fig. 6 The property that makes all three work: parallel world lines image to concurrent picture lines, whether they are edges of an object, shadow directions, or the joins between objects and their reflections.

One function, three subjects

The claim in this essay’s title is implemented rather than asserted, and it is worth saying exactly how.

projectToGround(centre, point, plane) intersects the line from a centre through a point with a plane. The camera calls it to put a scene on the ground for the plan views. The shadow code calls it with the lamp as centre. The same three lines of arithmetic serve both.

That is not a saving of effort — it is three lines. It is a structural claim: if the shadow construction and the perspective construction were different operations, they would need different code, and they do not.

The same holds one level up. A reflection is the view from a reflected camera, computed by the ordinary projection with a moved eye. A parallel drawing is the view from an eye at infinity, computed by the ordinary projection with the divide removed. Four subjects that are taught as four sets of rules turn out to be one function with its arguments varied, and the variation is exactly where the centre of projection is put.

That is the strongest form the site’s premise takes. Not that these things are analogous, but that they are the same computation, and that writing them as one is what makes the analogy checkable.

Projections compose

A shadow drawn on the ground and then photographed has been through two projections: from the lamp onto the ground, then from the eye onto the picture plane. That composition is worth a paragraph, because it explains why the whole subject stays tractable.

The composition of two projections is a projection. Both are projective maps, and projective maps compose to projective maps — so a shadow in a photograph obeys every rule an object in a photograph obeys. Its straight edges are straight, its cross-ratios survive, and its parallel lines converge to points on a line.

That is why shadow construction can be carried out in the picture, with a straightedge, rather than by computing the shadow in the world and projecting it afterwards. Both routes give the same answer, and this site computes it the second way only because the first would need the constructor to be right.

The composition also explains the shadow-of-a-shadow case that comes up in practice: a shadow falling on a wall, seen in a mirror. Three projections — the lamp, the mirror, the eye — and the result is still a projection, still straight, still checkable by the same concurrency tests. A mirror is a camera on the far side of the glass, and composing it with the others costs nothing.

The one case that breaks the chain is a curved surface anywhere in it, whether that is a curved mirror or a curved receiving surface. Then the rays no longer pass through a single point, the map is not projective, and none of the straightedge constructions survive — the same boundary the picture-surface question runs into.