The Sun's rays carry radiant energy from the sun in all directions. If the ray hits matter, the matter absorbs part of the energy and heats up. Thus the earth heats up, Moon and other material bodies are heated. A transparent object would be heated less than a black solid object (kinda obvious...