This topic comes up in searches but doesnt really have an answer.
here are a couple of things to consider when you are trying this.
- the default sky sphere is not really meant for this.
- the stars can and some times are visible before sunset.
- earth’s rotation… in unreal your stars need to move.
I will be making a tutorial on how I go about fixing this up and making use of the NASA files listed above once I’m done figuring it all out. Meanwhile, here is a brief tutorial that might get you started in the right direction.
enable view engine content, find the skysphere, copy all of its files to your project folders.
Make sure you don’t modify the engine files since any time the launcher verifies the file you loose all modifications.
replace the defualt skybox with your copy and hook up the dynamic light. Refresh materials and make sure everything is working like the engine version.
create an FBX with a sphere that unwraps into a flat map. You can use the grid off the NASA files to help in checking and scaling your UVs to fit.
Remember to flip your normals. The sphere texture needs to be applied on the inside.
import the FBX, open the copy of the sky sphere, drag the mesh to it and scale it up to be slightly larger and enclose the sky sphere.
star material creation. You may want to preserve the scalar parameters and apply/remove on the render via blueprint. While in the BP you may want to create all the needed variables like LAT LON Azimuth and whatever else you might know or think you know. I still haven’t figured it all out or the tutorial would be done
remove star from sky sphere - simply remove the texture nodes. Change the material to enable opacity. Create a scalar to control the opacity.
in BP on update sun direction take the sun height and clamp sequence for the opacity.
the goal is to have a value between 1 and 0 based on the sun height. How you do this is up to you. I have my range between a-0.1 b.3 to a.0 b.1 this makes the skybox invisible and the stars shine through when the sun is below the horizon.
In a nutshell that’s it. The star map from NASA shows up in the sky at night instead of the repeating star pattern.
adjusting the angle and everything else based on Parallel Meridian and Date is something I’m still working on.
a couple of things worth mentioning:
The sun (and moon) or anything with a rotating movement actor end up getting stuck around 90 and -90 degrees. I’m not sure why but there are tons of bug reports here on the forums about that. The best way to tackle this is the exact same way that the Sun Height seems to work.
create 2 float value, angle and speed.
Add the speed to the angle and set the angle on the update function. If this value is above 360 set it back to 0. This should convert the game time (fed into the speed) into the actual angle of the sun or whatever is rotating in a value you can interpret more efficiently then -1 to 1.
I just use this value in world space coords to set the current rotation and solve any problem about things “snagging” and throwing my time table of sunset/moonrise off.
It runs very smoothly though I’m sure it adds overhead which might end up being an issue for mobile and slower computers at the same time it enables you to do other mathematical magic so it’s a necessary evil in my opinion.
Also worth a mention, the sky sphere “T_Sky_Blue” has issues. I’m not sure how I’m fixing it myself, but just know that once you notice the tiling issue you can’t un-see it
Here is a GIF sneak-peak of how things look from the edge of my empty level map.