The process of merging hydrogen and carbon (from carbon dioxide and
water) is accomplished through photosynthesis. Organisms like
diatoms, a one celled plant, can start the process of creating organic matter ("A" in the diagram).
As the carbon and hydrogen are trapped in the food chain for
nourishment of other organisms, crude oil is not produced immediately.
However, as the death of these organisms and the burial of the organic
matter in sediments is complete, crude oil will start to form (black
layers in "B")
The different pathways that the organic matter will go through will
determine the type of oil and gas produced.