Of course it is rooted in superstitition; the motif of darkenings or eclipses of the sun and moon are frequently mentioned as evil omens in the Greco-Roman literature of the time (e.g. Cicero, De Republica 1.16.25; Vergil, Georgica 1.463-68; Dionysius Halicarnassus, Antiquitates Romanae 1.77.2; Ovid, Metamorphoses 15.785; Plutarch, Pelopidas 31; Cassius Dio, Historia Romana 47.40.2, etc.). Artemidorus, for example, says that a sun "dim or suffused with blood, or hideous to behold, is inauspicious and evil for all men" (Oneirocritica 2.36). These motifs are mainstays of ancient apocalyptic thought, as signs of the cosmic upheaval that accompany the end of the present world (e.g. Testament of Moses 10:5, Testament of Levi 4:1, Sibylline Oracles 5.477-82, Pseudo-Philo 19:13, 4 Ezra 7:39, etc.). The Zoroastrian/Jewish apocalypse of the Oracles of Hystaspes (which I believe was a literary source for Revelation), for instance, says that "strange prodigies in the sky will confound the minds of men with the greatest terror: the tails of comets, eclipses of the sun, the color of the moon, and the fallings of stars" (apud Lactantius, Divinarum Institutionum 7.16.8). The NT references to this motif are all literarily dependent on Joel 3:4 and similar motifs occur in Isaiah 13:10, 24:33, Amos 8:9, Zephaniah 1:15, and other references to cosmic upheaval can be found in Isaiah 34:4 and similar passages. The OT motif, in turn, is probably dependent on older Egyptian, Hittite, Hurrian, Akkadian, and Canaanite mythology pertaining to the divine cause of disaster and/or Chaoskampf in divine theophany (e.g. the twentieth-century BC Prophecy of Neferti, I.25-29, II.51-54 on the darkening of the sun during a time of disaster). The Chaoskampf theme (which is widely distributed in folklore, and eclipses are commonly thought to result from the acitivity of dragons) is still very much overt in Ezekiel 32:
"You are like a lion among the nations, you are like a dragon in the seas, you burst forth in your rivers, you stire up the waters with your feet, and foul their rivers. Thus says Yahweh: I will throw my net over you, I will haul you up in my dragnet. I will cast you on the ground, on the open field I will fling you. I will cause all the birds of the air to settle on you, I will gorge the beasts of the whole earth with you. I will strew your flesh upon the mountains, I will fill the valleys with your carcass. I will drench the land with your flowing blood, the watercourses will be full of you. When I blot you out, I will cover the heavens, I will make the stars dark. I will cover the sun with a cloud, the moon shall not give its light. All the bright lights of heaven I will blacken over you, I will put darkness upon your land" (Ezekiel 32:2-8).
Here the darkening of the sun is due to the dark cloud that Yahweh covers the land with. Compare with an interesting Akkadian text from the nineteenth century BC about Tishpak's battle with the lion/dragon monster Lammu:
"The cities are distraught, the lands [are thrown into confusion]. The nations are decreased in number, [all of them in mass upheaval]. To their cry of distress no [one answered], to their outcry, no [one asked], 'Who [created] the dragon?" "Sea [created] the dragon." Enlil in heaven drew [its picture], fifty miles is his length, one mile [his width], six cubits his mouth, twelve cubits the circumference of his ea[rs]....Tishpak burst open the clouds and made a violent storm, the seal of his life before him. He shot at him and [slew] the raging dragon. For three years and three months, day and night, the blood of the raging dragon flowed [over the land]" (CT 13.33-34).
Revelation of course has a Christian variant of the old Chaoskampf myth in ch. 12 (indeed, the chaos monster Lotan [= Hebrew Leviathan] in early Canaanite myths was seven-headed, cf. KTU 1.5 I 1-3, 28-30, and cf. the plural "heads" of Leviathan in Psalm 74:14). In the Lotan myth, the heavens wither and droop when Lotan is vanquished by Baal (KTU 1.5 I 1-4 has very close parallels in Psalm 102:25-27 and Isaiah 27:1, 34:4).