CNA Samples

Shadow Mapping

Ported from Microsoft's XNA 4.0 Shadow Mapping sample.

Source for this sample on GitHub ↗

An armored character casting a shadow on a checkerboard floor, with a preview of the shadow map at top left. Play ▸

Opens in a new tab. Move the camera to see how the shadow map follows its view.

About this sample

A directional light casts the character's shadow across a checkerboard floor. The sample first renders depth from the light into a floating-point shadow map, then uses that map when drawing the scene. Its projection follows the camera's visible frustum; the small square at the upper left previews the current map.

Controls

ActionKeyboardGamepad
Turn the cameraArrow keysRight stick
Move the cameraW, A, S, DLeft stick
Rotate the characterQ and ELeft and right triggers
Reset the cameraRPress right stick
ExitEscapeBack