TimeOfDayComponent struct in Thread
A world clock that drives the sun. It advances the time of day while the game runs and, from that one number, sets the rotation, colour and intensity of the directional light, the sky gradient, and the ambient fill.
Properties
| Enabled | bool | Master switch. Off leaves the light exactly as authored. |
| TimeOfDay | float | Hours in [0, 24). Decimal, so 6.5 is half past six. The authored value is where a new game starts. |
| Day | int | Whole days elapsed. Incremented on every midnight crossed; what a day means is the game's business. |
| Paused | bool | Freeze the clock without disabling the lighting it drives. |
| ProceduralSky | bool | Replace the skybox cubemap with a gradient that follows this clock. On by default. |
| Settings | DayNightSettings | Everything about the shape of the day — see below. |
DayNightSettings
| DayLengthMinutes | float | Real minutes per in-game day. 0 freezes the clock instead of dividing by zero. |
| SunriseHour / SunsetHour | float | When the sun crosses the horizon. Sunset before sunrise is permanent night, not an error. |
| DayColor / HorizonColor / NightColor | Vec3 | Sun colour at midday, at the horizon, and after dark. |
| DayIntensity / NightIntensity | float | Sun brightness at either end. Night is moonlight and deliberately not zero. |
| SkyZenithDay / SkyHorizonDay | Vec3 | Daytime sky gradient, straight up and at eye level. |
| SkyZenithNight / SkyHorizonNight | Vec3 | The same two, after dark. |
| AmbientDayIntensity / AmbientNightIntensity | float | Fill light at either end — see Making night dark. |
| NorthYawRadians | float | Turns the whole arc, so a level can face its sunrise wherever the terrain wants it. Changes the compass, never the shape of the day. |
| ArcTiltDegrees | float | The latitude knob. Highest elevation of the day is exactly 90 − this. |
Making night dark
The sun on its own cannot do it, and this is the setting people go looking for when night stays bright. Every ambient term in the lit shader — image-based light off the skybox, SH irradiance, the irradiance volume, and the flat fallback — is multiplied by the scene's ambient colour and intensity. A fill that stays put therefore keeps a cubemap's noon light on the ground at midnight, and the whole cycle reads as a sun sliding across an evenly lit world.
So the clock drives an AmbientLightComponent as well — on its own entity, same pairing rule as the sun. This is opt-in by construction: a scene with no ambient light beside the clock keeps exactly the ambient it was authored with, so adding a clock cannot silently re-light a finished level.
Notes
Sun colour, sky and ambient all cross the horizon on one shared twilight band rather than branching on the sign of the elevation, so none of the three can disagree with the others about whether it is night, and none of them steps in a single frame.
The clock applies in the editor viewport too, without advancing — scrubbing the Time slider moves the sun immediately, so lighting can be judged at any hour without entering Play.
TimeOfDayComponent struct w Thread
Zegar świata, który steruje słońcem. Przesuwa porę dnia w trakcie gry i z tej jednej liczby ustawia rotację, kolor i jasność światła kierunkowego, gradient nieba oraz światło otoczenia.
Właściwości
| Enabled | bool | Główny przełącznik. Wyłączony zostawia światło dokładnie takie, jak ustawione. |
| TimeOfDay | float | Godziny w [0, 24). Dziesiętnie, więc 6.5 to wpół do siódmej. Ustawiona wartość to start nowej gry. |
| Day | int | Pełne minione dni. Zwiększany przy każdej północy; co dzień znaczy, to sprawa gry. |
| Paused | bool | Zatrzymuje zegar bez wyłączania oświetlenia, którym steruje. |
| ProceduralSky | bool | Zastępuje cubemapę skyboxa gradientem podążającym za zegarem. Domyślnie włączone. |
| Settings | DayNightSettings | Wszystko o kształcie doby — patrz niżej. |
DayNightSettings
| DayLengthMinutes | float | Prawdziwe minuty na dobę w grze. 0 zatrzymuje zegar zamiast dzielić przez zero. |
| SunriseHour / SunsetHour | float | Kiedy słońce przecina horyzont. Zachód przed wschodem to wieczna noc, nie błąd. |
| DayColor / HorizonColor / NightColor | Vec3 | Kolor słońca w południe, przy horyzoncie i po zmroku. |
| DayIntensity / NightIntensity | float | Jasność słońca na obu krańcach. Noc to światło księżyca i celowo nie zero. |
| SkyZenithDay / SkyHorizonDay | Vec3 | Dzienny gradient nieba, w zenicie i na wysokości oczu. |
| SkyZenithNight / SkyHorizonNight | Vec3 | Te same dwa po zmroku. |
| AmbientDayIntensity / AmbientNightIntensity | float | Światło wypełniające na obu krańcach — zob. Ciemna noc. |
| NorthYawRadians | float | Obraca cały łuk, żeby poziom miał wschód słońca tam, gdzie pasuje terenowi. Zmienia kompas, nigdy kształt doby. |
| ArcTiltDegrees | float | Pokrętło szerokości geograficznej. Najwyższa wysokość słońca w ciągu dnia to dokładnie 90 − ta wartość. |
Ciemna noc
Samo słońce tego nie zrobi — i tego ustawienia ludzie szukają, gdy noc zostaje jasna. Każdy człon światła otoczenia w shaderze — oświetlenie z obrazu skyboxa, irradiancja SH, wolumen irradiancji i płaski fallback — jest mnożony przez kolor i jasność otoczenia sceny. Wypełnienie, które się nie zmienia, trzyma więc o północy południowe światło cubemapy na ziemi, a cały cykl wygląda jak słońce przesuwające się nad równo oświetlonym światem.
Dlatego zegar steruje też AmbientLightComponent — na jego własnej encji, z tą samą regułą pary co słońce. Z konstrukcji jest to opcjonalne: scena bez światła otoczenia obok zegara zachowuje dokładnie to otoczenie, z jakim ją zrobiono, więc dodanie zegara nie przeoświetli po cichu gotowego poziomu.
Uwagi
Kolor słońca, niebo i otoczenie przechodzą przez horyzont jednym wspólnym pasmem zmierzchu, zamiast rozgałęziać się na znaku wysokości, więc żadne z trzech nie może się z resztą nie zgadzać, czy jest noc, i żadne nie przeskakuje w jednej klatce.
Zegar działa także w viewporcie edytora, bez upływu czasu — przesunięcie suwaka Time od razu przestawia słońce, więc oświetlenie ocenisz o każdej porze bez wchodzenia w Play.