During photosynthesis, oxygen is produced during the process called photolysis. During photolysis, molecules from water, carbon dioxide and minerals are broken down into smaller units due to light absorption.
In order for a plant to successfully perform photosynthesis, it needs sunlight. The photolysis portion of the photosynthesis process causes hydrogen to bind to an acceptor, releasing oxygen in the form of a dioxygen molecule.
Plants absorb light through chlorophyll, which also gives them their green color. Most sunlight is captured in the leaves, but any green part of the plant has the ability to capture and use the energy from the sun.