Chrono in Unreal, part 8: The light of the night
The last third of the demo plays at dusk and at night. The first version made the night the way games do: a post filter that darkens the picture and tints it blue. The developer rejected that, “you have to set the light source”, and that sentence is the programme of this part. The night here comes from the exposure and from light sources, not from post-processing. The series: part 1 overview, part 5 the effects of the day, part 6 parasail, part 7 drone, part 9 sequence.
The demo the series is about. The evening from minute 6:03. On YouTube in 1080p the console is readable.
The exposure as a camera
The engine exposes automatically, like an eye or a camera on automatic: it adapts to the mean brightness. For a night that is the opposite of what is wanted, because the automatic pulls a mid-bright picture out of any darkness, and the full moon becomes a pale day. The first version therefore worked with a lower exposure limit that sank with the dusk. The result was either day or black, depending on the limit, and never both in one transition.
The solution is a camera with a fixed setting. From the start of the sunset the lower and the upper exposure limit are set to the same value, the daylight value. It is computed from the sun’s intensity: the luminance of a scene is roughly illuminance times albedo over π, and from that follows the exposure value EV100 = log₂(L · 100 / 12.5), with a small offset for tuning. The limits move to that value over eight seconds so that nothing jumps. From then on the exposure is a constant, and the brightness of every pixel is only what the light sources deliver. The sun sinks and weakens, the picture darkens, and what then shines are the moon, the boat’s lights, the searchlight and the drone’s strobe.
That has a consequence for the light intensities: they have to fit each other, not an automatic. The sun goes from 26 degrees elevation down to the horizon in 45 seconds and to 35 percent of its intensity, warmer in tone and with a disc growing from 0.5 to 2.5 degrees. In another 15 seconds it falls to 0.3 percent, and with the moonrise to 0.05 percent. It does not go below the horizon: the light direction stops at 6 to 7 degrees above it, the night is made by the intensity alone, and at night the HUD reads “sun +7 deg 0.00 lux”. The moon gets 15 percent of the daytime sun. Physically the full moon is about 400000 times weaker than the sun, and with the fixed exposure the night would be black. 15 percent is the value at which, with a fixed camera, beach, boat and canopy are still visible and the scene still reads as night. That is a decision for the picture, and it is named here as such.
The moon
The moon is a second directional light, registered as an atmosphere light so the sky around it turns dark blue rather than black. Two details decide whether that works. First, the sun has to remain the light with priority for water, translucency and fog, otherwise the engine computes those effects with the moon and warns; that is a priority on the light. Second, the atmosphere draws its own disc in the sky for each of its lights. The source size of the moon light is set so small that this disc disappears as a dot inside the visible moon sphere.
The visible moon sphere is an unlit object with a texture, 200 kilometres away along the light’s direction, scaled to 2.2 degrees across. The distance is not cosmetic. At 40 kilometres the sphere drifted against the atmosphere’s disc as soon as the camera moved, parallax, and it stood in front of the volumetric clouds. At 200 kilometres the parallax is under a pixel and the sphere is behind the clouds. The texture is generated procedurally, because with the library’s photo the moon at this size was only a bright spot: the big maria roughly in their places, a bright highland, a few thousand craters with lit rims, Tycho and Copernicus with rays. “Nobody will notice” was the brief, and the goal was a moon that reads as the moon, not a map.
The moonrise is timed to the action: 78 seconds after the dusk begins, shortly before the boat runs for the beach, it comes up behind the dune over 25 seconds, from 4 degrees below the horizon to 24 above, and its light comes up with it. The beach run and the landing of the canopy thereby lie in moonlight, “before it hits the shore there has to be light again”.

Stars and shooting stars
900 stars as a single instanced static mesh, small discs 200 kilometres away, again behind the clouds, with diameters between 0.2 and 0.5 degrees. The twinkle is in the material: the per-instance random value the engine provides gives every star its own phase and rate with which its brightness is modulated over time. So every star twinkles on its own without anyone touching 900 objects per frame. The main stars of Aquarius are laid out from right ascension and declination, the rest at random and not too close to them. The shooting star is an additive cylinder crossing a piece of sky now and then, with a head and a tail of a quarter of the path.
The boat’s lights
The boat’s lights follow the collision regulations, because the developer knew them and judged the picture by them: red to port, green to starboard, each over a sector of 112.5 degrees from dead ahead to 22.5 degrees abaft the beam, plus a white masthead light over 225 degrees and a stern light over 135. Two versions with spotlights were wrong. The first tilted the cone 25 degrees down so it would shine onto the water; but a circular cone with half-angle a around an axis tilted by e spans asin(sin a / cos e) in the horizontal, and the sector reached 10 degrees too far aft. The second sat at the tip of the bow, and because a spot is brightest on its axis, most of the light went into the forward quadrant. A cone is the wrong shape for a sector that has to be equally wide at every elevation. The lanterns are now point lights with a light function, a material that returns a factor per lit point: the direction from the lamp to the point is projected onto the horizontal and dotted with the sector centre, and the factor is 1 when the product exceeds the cosine of the half sector, otherwise 0. The material gets lamp position and sector centre every frame from the boat’s pose. There is one angle system for all lamps: 0 degrees is dead ahead, positive clockwise seen from above, green covers 0 to 112.5 degrees, red 247.5 to 360, the masthead 247.5 through 0 to 112.5, the stern light 112.5 to 247.5. Four lanterns: red and green at the ends of the tower’s top bar, at the full beam of ±1.15 metres and 1.88 metres up, so their forward edges run along the hull sides, and a centre lantern on the centreline, red left, green right, with a black divider so the sectors meet dead ahead. The lamp housings are closed aft and inboard.
The water exposed a limit of the engine that is worth knowing. On sand and hull the sectors are right, on the water every lantern shines all round. The water material is translucent, and the classic light function pass reconstructs the lit point from the depth buffer, which holds no translucent pixels. For translucency, fog and Lumen, light functions exist only through the light function atlas, and that accepts only materials without world position, because it bakes the function into a two-dimensional tile over the light direction. Add the colour of the water, a blue-green that reflects green light about eight times better than red: green is seen from astern too, red hardly at all. The way out, computing the sector mask from the light’s own coordinates instead of the world position and putting the sector centre into the lamp’s rotation, is known and was not taken for this video. The water ahead of the boat gets its light from two white headlights at the bow, aimed horizontally forward like a car’s, with 18 and 30 degree cones; the lanterns, at 30 candela and 12 metres of range, are lanterns and not floodlights. The boat has no red beacon, that belongs to the drone.
The searchlight is the only light with shadows, and the one that carries the evening. Once it is dark it sweeps the beach for 22 seconds, then holds on the canopy for 14, and so on, until it stays on the canopy for the beach run; at the end it holds on the wreck in which the drone floats. The cone itself is visible, because a spotlight in the engine only lights what it hits, and it does not hit air: an additive cone from a basic shape, faint, with its length to the target plus 20 metres and its base as wide as the light’s outer cone there. Three nested cones for a fall-off towards the target were the second version; the first, a single faint cone, is the one that stayed: “the old searchlight was better”.
The drone’s strobe is a double flash per second, a small glowing sphere and a point light, and it comes on with the boat’s lights, at 45 percent of the sunset, because the developer otherwise could no longer find the drone in the vehicle’s picture.

Materials that do not sparkle in the video
Two material changes belong to the light although they were made by day. On the sea and on the sand a noise was visible in the scaled-down video: the water’s 25 cm wave normals and the sand’s ripples are finer than a pixel beyond 60 to 100 metres and turn into flicker in the encoder. Both materials fade their normals and their roughness out with pixel depth; far away the water is shaded smooth and flat, the sand without ripples. At night with the searchlight on the water the difference is largest. The parasail’s line has a slightly emissive material so it shows in the searchlight’s cone; without it the line had vanished in the video, and the developer asked for a thicker line for three runs until it was clear that it had no light.
What it costs
The searchlight with shadows is the one expensive light. All others cast no shadows, the stars are one draw call, the moon sphere one. In the shown run the GPU time rises from around 12 milliseconds by day to 14 to 16 at night, and the frame rate stays at 56 to 57 frames per second.
Two days for the whole build, from setup to night: the pace came from the automation, not from cutting corners on the models. The work was done as a pair, with a clear division of roles. The engineer brought the model physics and the field knowledge that separate a calibrated simulation from a nice-looking animation, and turned that into the system’s requirements. Examples: the canopy’s lift depends on airspeed, the boat regulates the canopy’s height through its own speed and not through the camera, the line to the pilot hangs on the chest and not on a seat, the night comes from light sources and not from a filter, side lights are red to port and green to starboard and cover a 112.5-degree sector that ends cleanly aft. A banner behind the canopy looked silly and went out again. Requirements like these do not come from a prompt but from physics and hands-on practice on the water. The agent, Claude™ Code, turned those requirements into the C++ code, materials and blueprints, built, compiled, launched, took screenshots, read the telemetry and made proposals. What survived being measured against the model stayed. Only once did the source code have to be reviewed to get on: for the sector lights, whose light function did not reach the water.
How these scenes run together into a sequence of nine minutes without intervention, with events as transitions, is in part 9.
Keywords: Unreal Engine night lighting, lock exposure auto exposure, moon directional light atmosphere, procedural moon texture, stars instanced static mesh twinkle, navigation lights light function sector, light function atlas translucency, searchlight visible cone, material distance noise video, serious gaming, simulation consulting Switzerland, swissEmbedded
A picture that comes from light sources instead of filters? We build visualisations whose brightness and colour come from the scene, for simulators and demonstrators.
Unreal® and Unreal Engine® are trademarks or registered trademarks of Epic Games, Inc. in the United States of America and elsewhere; these articles are neither endorsed nor reviewed by Epic Games. Project Chrono is an open-source project of the University of Wisconsin-Madison and Politecnico di Milano under the BSD-3 licence.