Forests provide habitat for a wide variety of plants and animals and perform many other important functions that affect humans. Photosynthesis is the chemical process in the leaves that uses sunlight and carbon dioxide to produce energy-supplying sugars for the tree or plant—in the process the foliage of the plants and trees gives off pure oxygen for breathing. Forests also prevent erosion, the wearing away of soil by wind and rain. In bare landscapes with little or no vegetation, heavy rains fall uniformly over large areas and can wash soil into rivers and streams and cause landslides and flooding. This leads to ecosystems that are deprived of both water and soil, which are quickly carried away in rivers and streams. In forested areas the forest canopy (treetops) intercepts and gradually re-distributes precipitation that would otherwise cause this flooding and erosion—some of the precipitation flows down the bark of the trunks as stemflow, the rest percolates through the branches and foliage as throughfall. This slower and nonuniform distribution of the rain ensures that soil and water will not be immediately carried away. In addition, the roots of the trees and other vegetation hold the soil in place and prevent flooding and clouding of streams and rivers. Forests also increase the ability of the land to capture and store valuable water. The canopy is especially efficient at capturing water from fog—condensed, cloudlike water vapor—which it distributes, like precipitation, into the vegetation and soil. Water stored in tree roots, trunks, stems, and foliage, as well as the soil of the forest floor, enables forests to maintain an even flow of water in rivers and streams in times of heavy precipitation or drought.