Then we code in the shade
A shadow map is calculated for a light and is used to check what other positions in the world are in shadow from that light. It's a made in two steps.
Create the shadow map
The shadow map is a depth map from the view of the light source. In it all the objects that will cast shadows need to be rendered. For a directional light it can be a orthographic projection, for others a perspective one. On depth information so simple shaders that only write depth can be used. The shadow map need to be update each time the light or any of the shadow casting objects move.
Use the shadow map
Calculate the light transform
When rendering a position in the scene transform that position into the space of the shadow map.
Sample shadow map
Used that light space position to check in the shadow map if the current position is in shadow from the shadow map.
If the position in the scene is in shadow ignore the light else include it's values when calculating the light value.
Advanced Real-time Shadowing - 2016
Sparse Shadow Trees - 2016
Shadow mapping basics - 2015
Shadow Mapping - 2014
Moment Shadow Mapping - 2013
Shadow Mapping - 2012
Shadow Map Allocation - 2011
Graphics Tech: Shadow Maps (part 2): Save 25% texture memory, and possibly much more. - 2010
Graphics Tech: Shadow Maps (part 1) - 2010
Cascading Shadow Maps
Shadows Everywhere - 2020