Rain clouds turn gray or black because thick clouds saturated with rain drops scatter sunlight coming through the clouds. When less direct sunlight gets to the bottom of clouds, they appear darker to the human eye. Thin clouds that do not contain a lot of moisture allow enough sunlight through them so that they appear white to observers.
Fewer heavy particles between sunlight and the ground means less light scattering. When water particles get heavier, such as before a rainfall, the darkening effect intensifies. Light scattering also causes the sky to turn blue. Thick layers of small molecules in the atmosphere turn light blue to the human eye.
It is possible to view the effects of direct sunlight on layers of clouds. When airplanes fly through the sky, passengers can see the top and bottom of clouds. Thick clouds do not let enough sunlight to the bottom of clouds, but passengers see sunlight filtering through the thinner top of clouds that appear white. This sunlight at the top is not scattered or blocked by more water particles. When a cloud is 3,000 feet thick or thicker, little direct sunlight reaches the bottom of the cloud to be seen by humans on the ground.