Shadow mapping is like drawing a picture of the things that the sun can't shine on. Imagine you're outside on a sunny day, and you're standing under a tree. The tree blocks the sun from shining on you, and it creates a shadow on the ground. That shadow is like the picture of what the sun can't shine on.
Now, let's pretend you're playing a video game where your character is also outside on a sunny day. The game wants to show you the same shadow that you saw when you were standing under the tree, but it can't just make a shadow appear like magic. Instead, it has to create a picture of everything that the sun can't shine on, which is called a "shadow map."
To make the shadow map, the game takes a "snapshot" of the scene from the point of view of the light source (like the sun). It creates a special kind of picture that only shows the parts of the scene that the light can't reach, which is everything behind other objects that block the light. This is called the "depth buffer."
Once the game has the shadow map, it can use it to figure out where shadows should be in the scene when you're playing the game. It does this by "painting" the shadow map onto the scene from the point of view of the camera (your character's eyes), using a special algorithm that takes into account the position of the light source and the shape of the objects that are casting shadows.
So, when you're playing the game and your character goes under a tree, the game uses the shadow map to create a shadow on the ground that looks just like the one you saw when you were standing under the real tree. This makes the game feel more realistic and immersive, and helps you feel like you're really there in the virtual world.