Skip to content

Celestial lighting

Choose a lighting ownership model before tuning intensity. A directional Light should have one controller responsible for a given property; otherwise competing components can overwrite rotation, color, enabled state, and shadows each frame.

Shared directional light

CelestialLightController manages a single assigned scene Directional Light. It does not create one automatically. This is the supplied unified solar/lunar handoff model.

  1. Bind the presentation to an initialized context with Astronomy and, for astronomical moonlight, Lunar.
  2. Assign Directional Light to an actual Directional Light.
  3. Configure rotation/enabled-state ownership and whether it manages RenderSettings.sun.
  4. Set solar maximum intensity and elevation start/full thresholds; configure lunar intensity/elevation behavior.
  5. Test twilight handoff, shadow direction, and nighttime appearance in the active render pipeline.

Component defaults include maximum solar intensity 1, maximum lunar intensity 0.08, solar illumination start −6° and full 50°. These are authored intensity values, not calibrated photometric guarantees. Solar palette color and high-Sun neutralization affect the color independently of position.

The shared light can blend direction through twilight. Direction blend start/end are normalized fractions of the handoff, while twilight thresholds are solar-elevation degrees. Optional shadow fading reduces shadow strength near the midpoint to soften a direction change. Shadow types/strength and pipeline support still determine actual rendering.

Stylized moonlight

The unified controller's Stylized Moonlight Override replaces presentation lighting, not Lunar System state. Its settings can use constant intensity, a Night Only solar gate, fixed world Euler rotation, optional color, and optional shadow overrides. Defaults in StylizedMoonlightSettings include intensity 0.4, Night Only enabled, and fixed rotation enabled.

You can light a scene artistically even when the simulated Moon is below the horizon or not full, without pretending its calculated phase changed. Night Only has its own solar fade range; otherwise the shared twilight range applies where configured. Runtime override APIs copy settings; refresh through the controller rather than mutating a returned copy and expecting a change.

Separate Sun and Moon lights

SunLightController is a separate solar-light alternative using Astronomy and optional phase color/presentation settings. MoonLightController can drive a different assigned directional Light from Lunar state and has its own artistic override settings type (MoonLightOverrideSettings). Do not interchange that type with the unified controller's StylizedMoonlightSettings.

The Moon controller does not assign RenderSettings.sun, create a Light, or request GI updates. Its shadow control is off by default. Whether multiple directional lights cast the intended shadows depends on your render pipeline; adding a second light is not proof of a second supported main-light shadow path.

Do not put unified, Sun, and Moon controllers on the same Light and expect their settings to merge. Disable competing ownership before comparing models.

Scene switching and cleanup

Controllers capture/restore properties they own when releasing presentation. External scripts changing those properties concurrently can still interfere. Keep the switcher outside managed roots and use the supplied one-visible-presentation pattern. Changing the active presentation does not set the Sun's simulation time or the Moon's orbital phase.

Related: Lunar simulation, binding, rendering.