A depth buffer stores depth values for rendered samples so the renderer can compare incoming surfaces with what is already there.
Remembering which surface is nearer
When two opaque objects cover the same screen position, the renderer needs a way to decide which one is visible. A depth test compares the incoming depth with the stored value according to a chosen rule. A depth write controls whether drawing the surface updates that stored value. Testing and writing are separate decisions.

Drawing later does not always mean appearing on top
A surface drawn later can still fail the depth test because another surface is nearer. This is why render order is not a substitute for understanding depth. Transparent overlays need particular care: an apparently empty or partly visible region should not accidentally block something that is meant to remain visible behind it.
Virtual depth is not a scan of the gallery
The depth buffer of a rendered scene does not, by itself, know where the visitor’s hand or the physical painting is. Real-world occlusion requires additional information and integration. For a Painta composition, distinguish a digital detail hiding another digital layer from a real object hiding that detail. When troubleshooting, record the camera angle and which surfaces overlap; those facts are more useful than changing every depth setting at once.