How does radiation shielding using absorbing materials work?

I understand that, for example, a thick enough sheet of lead can absorb gamma radiation, but I want to understand what actually happens at the molecular/atomic/subatomic level. Also, can the same logic be applied to cosmic particles? I have tried Googling for an answer, but to no avail. Can someone enlighten me?

There are three basic reactions of gamma rays with matter, pair production (at high energy), photoelectric effect (all energies, but increasing as the energy gets lower), and scattering (which lowers the energy). The first two are absorption, although the positron from pair production will annihilate an electron resulting in two lower energy gamma rays. The lower energy gamma rays are more easily absorbed due the increase in cross-section for the photoelectric effect. These reactions are all on the atomic level.

Casmic ray particles are mostly high speed protons, so the shielding needs are different. However a lead shield that is good for gamma rays should be adequate.