UE5 Day night cycle

by | Jun 14, 2022 | Blog

Hey guys, its that time of year again, where I actually post some stuff here. 🙂 I have downloaded Unreal Engine 5 and the first thing I tried to create was a day night cycle. I used a space sky sphere I got of the marketplace to show at night and hooked it all up with Unreal Engines atmosphere, clouds and lumen, though lumen is not very visible in the current environment.

It didn’t take long for everything to come together, you get so much for free in Unreal Engine, its amazing. I had some hitches along the way, with the second moon in particular, but in the end I find it absolutely beautiful. The lightning on the clouds are what really sells the effect.

The video does really not do it justice, so I added some screenshots as well.

This is all connected trough a the sun position calculator, which means you can set the day, hour, month, year, etc. You can also calculate the angle of the moon or the sun in the sky sphere material. This lead me to add a texture of a random planet I found on google as a moon. Then I figured, hey why not add a second moon that is a little more offset. Worked like a charm.

You can calculate what the sky sphere should look like by lerping between day and night using Light direction. This will give you a perfect transition between the star field and the empty day scene.

Moon and second moon
Moon is coming up, the second moon is right behind the clouds
Sun is coming up
Nebula
Day