The sun god was essential for rebirth. The endless cycle of sunrise and sunset was a powerful metaphor for continuous rebirth after death.
Furthermore, one of the principal ancient Egyptian creation myths describe the sun god as the creator of the universe and the originator of all life; since creation was cyclical, the sun god thus brought about rebirth as well. Several mythos coexisted: the sun god rejuvenated the deceased; the deceased fought the sun god's underworld foes; and the deceased was associated with the sun god.
New Kingdom Books of the Underworld describe how each evening the sun entered the subterranean netherworld. He spent the twelve hours of night on a barque, taking a riverine route through underground caverns so that he may return to the eastern horizon for the sunrise. Within these caverns were friendly deities, hostile deities and the dead. The sun god's rays rejuvenated and awakened the dead. However, the sun god was opposed by chaos, represented by a giant serpent named Apep who had to be defeated.
After defeating Apep, and in the fifth hour of the night, the sun god encountered the mummified Osiris. The sun god merged with the corpse, rejuvenating himself. This merge was the model for the joining of ba and mummy for rejuvenation of ordinary mortals. Hence, funerary texts closely associated the deceased with both Osiris and the sun god, particularly after Dynasty 19. By the Middle Kingdom, the deceased was shown travelling with Ra in his barque and fighting his foes, namely by spearing the Apep serpent on behalf of Ra.
The newly-risen dawn sun, represented by a scarab beetle propelling the solar disc into the sky.
The daytime sun.
The evening sun, and the creator god in one of the main cosmogonic myths.