Some science behind the scenes
REM
During sleep, the time when we dream is during REM sleep. Rapid eye movement sleep, or REM sleep, accounts for 20–25% of total sleep time in most human adults. The criteria for REM sleep include rapid eye movements as well as a rapid low-voltage EEG. Dreaming is no different from having a hallucination or a vision, in that the processes by which a dream are created are identical to those used for the creation of a vision or hallucination.
During this stage of REM sleep we may have reduced or absent consciousness, suspended sensory activity, and inactivity of nearly all voluntary muscles. At least in mammals, a descending muscular atonia is seen. Such paralysis may be necessary to protect organisms from self-damage through physically acting out scenes from the often-vivid dreams that occur during this stage.
The start of the REM cycle occurs in the reticular formation and the signals from this organ then spread via both electrical and neurotransmitter release to the rest of the brain in order to induce a state of the body and the brain which is conducive to dreaming. For example, the release of certain neurotransmitters - the monoamines norepinephrine, serotonin and histamine - is completely shut down during REM. It is this that causes REM atonia, a state in which the motor neurons are not stimulated and thus the body's muscles do not move.
The rapid eye movements that do occur during this stage are thus a consequence of the process started in the reticular formation. Amongst many theories, it is hypothesised that the eye movements help to indicate to the vision system that the system is to deactivate itself as the images to be processed by the perception system are to be derived from elsewhere. In other words it is a sort of signalling device to the system that processes sight that it needs to no longer process any signals from the eyes.
During dreaming, the primary visual cortex is inactive, while secondary areas are active. This is similar to when subjects are asked to imagine or recall a visual scene, and different from what happens when they are actually seeing the scene
What happens when any light enters the eye that mimics the frequency of REM sleep, however, is that it reverses the signal and the signal travels to the reticular formation in a reverse action and the person then hallucinates or has a vision. Once having reached the reticular formation, this organ then starts the process associated with ‘waking dreaming’ and atonia can result, for example.
Beyond the Body – Dr Susan Blackmore
In a normal night's sleep a distinct change takes place an hour or two after falling asleep. Although the muscles are still relaxed, the sleeper may move and from the EEG it appears that he is going to wake up and is back in something resembling Stage 1 sleep. Yet he will still be very hard to wake up and in this sense is fast asleep. For this reason this stage is sometimes called paradoxical sleep. The most distinctive feature, however, is the rapid eye movements, or REMs and the stage is also called REM sleep.... If woken up now the sleeper will usually report that he was dreaming... In a typical night's sleep there are four of five complete cycles through different stages of sleep, with four of five REM periods. Since many animals show REM sleep, it can be assumed that they too dream. Dreams seem to take time.