Follow up:
I am lazy so i asked my yellow rubber duck (chatgpt). And here is its answer, and because it is deep AI, check everything below (sometimes it makes silly mistakes that look like THE truth):
- Compute Up Vector (Zenith)
Given latitude (ϕϕ) and longitude (λλ), the up vector in ECEF (Earth-Centered, Earth-Fixed) coordinates is:
UpVector=(cos(ϕ)cos(λ),cos(ϕ)sin(λ),sin(ϕ))
UpVector=(cos(ϕ)cos(λ),cos(ϕ)sin(λ),sin(ϕ))
Where:
ϕϕ = Latitude in radians.
λλ = Longitude in radians.
- Compute Local Sidereal Time (LST) for Correct Skybox Rotation
To align the skybox properly with the stars, we need Local Sidereal Time (LST).
Step 1: Compute Julian Date (JD)
First, convert UTC date and time to Julian Date (JD) using:
JD=367Y−⌊7(Y+⌊M+912⌋)4⌋+⌊275M9⌋+D+1721013.5+UT24
JD=367Y−⌊47(Y+⌊12M+9⌋)⌋+⌊9275M⌋+D+1721013.5+24UT
Where:
Y,M,DY,M,D = Year, month, and day.
UTUT = Universal Time (hours, fraction included).
Example: If it's February 3, 2025, at 12:00 UTC, calculate JD for that timestamp.
Step 2: Compute Greenwich Mean Sidereal Time (GMST)
GMST=280.46061837+360.98564736629(JD−2451545)
GMST=280.46061837+360.98564736629(JD−2451545)
This gives the GMST in degrees.
Step 3: Convert GMST to Local Sidereal Time (LST)
LST=GMST+λ
LST=GMST+λ
λλ is longitude in degrees (positive east, negative west).
-
Compute Skybox Rotation
The HDRI skybox rotation (Yaw) should match LST in degrees.
Convert to radians if needed:
Yaw=LSTmod 360
Yaw=LSTmod360
The up vector gives the correct tilt, and the LST gives the proper skybox rotation.
Final Steps in UE5
Up Vector: Controls the HDRI tilt.
Yaw (LST): Controls the HDRI rotation.
Use SetActorRotation on the skybox.
This should correctly align your HDRI skybox to time and location on Earth. ![:rocket: :rocket:](https://d1ap1mz92jnks1.cloudfront.net/images/emoji/twitter/rocket.png?v=12)
ps.
Use this reply from out future overlords as guide, you have all keywords, and algorithm how to calculate it. So use google for more reliable articles.
And pps:
I already found derp mistake in last step: do not use set actor rotation for the skybox, instead rotate camera vector in material just like i posted in previous reply.