DevLog #6 – We replaced our sun, and the first sunrise came in at five times noon
United States
Breaking News:
Washington DC
Sunday, Nov 29, 2026
Byzen has had a day/night cycle for a while, and the part that decides the game has always been solid. The sun is computed for Montevideo’s real latitude (−34.9°) and the day of the year, so in the southern hemisphere it sits in the north at noon, winter days are short and shadows run long. One number, daylight from 0 to 1, drives everything the player feels. At night units see 55% as far and ranged fire does 70% of its damage. Melee is untouched on purpose, so fighting up close gets relatively better in the dark. And light sources carve out islands where vision comes back.
The picture was the weak half. Colours and intensities were interpolated by hand between keyframes, and it showed. Last month we handed the image to a physical atmosphere model: Rayleigh and Mie scattering, ozone absorption and second-order scattering. The sun, the moon, the sky, the ambient light, reflections, fog and exposure now all come out of that one model instead of being painted separately.
Mission 1, 18 May 1811, the day of Las Piedras. Same camera, six hours. At noon the sun is due north, so shadows fall south.
The rule was that gameplay must not move by a single number. So the new system draws, and the old one keeps deciding:
We checked the model against published illuminance values. At sunset it gives 997 lux against a reference of about 930. At the end of civil twilight, 6.45 against 6. At the end of nautical twilight, 0.0084 against 0.004. A moonless night, 0.0018 against 0.001. With a full moon at midnight, 0.26 lux, where the real figure is 0.1 to 0.3. Close enough that when something looked wrong, it was usually something else being wrong.
The moon is always full and always opposite the sun. That’s a simplification, and a deliberate one: with a real 29.5-day cycle, a night mission that happened to fall on a new moon would be literally black. The moon is also a real second light, not a tint on the sun, because a switched-off sun casts no shadows, and without them the terrain at night flattens into a painted board.
The first noon we rendered with the new lighting had no shadows. Not faint ones: none. The buildings, the trees and the terrain all looked like an overcast day under a clear sky.
Same frame, same sun. The only change is one import setting on one texture.
We went down the obvious list, turning off the terrain, the sun’s shadows, the extra lights and the moon, and the answer turned out to be one texture. The grass normal map on mission 1’s main terrain layer had been imported as a colour texture. Read as colour, it gets gamma-decoded, and every normal in the field gets pushed off-axis in the same direction. The ground effectively leaned away from the sun whenever the sun came from the north or the east. In the southern hemisphere that’s the whole morning and all of noon.
The old hand-tuned ambient had hidden it, because it lit the ground from everywhere at once. A physically based ambient doesn’t forgive that. It was the only terrain layer with the problem. There may be other mis-imported textures elsewhere in the project, but under this lighting they won’t stay hidden for long.
The main scene has a directional light in it, from long before this system existed, and it stayed alive during missions. With the old cycle nobody could tell. With the physical one it was a second sun, fixed in the south-east, with no exposure applied to it, lighting the night like midday. The cycle now switches off every directional light that isn’t its own sun or moon while a mission runs, and gives them back when it unloads.
This one took two attempts, and the first attempt is the useful part.
Mean frame brightness, 0–255, measured on the captures. The storm made the night 3.4 times brighter than a clear one.
Mean brightness across the frame: 24 on a clear night, 82 in a thunderstorm. The diagnosis looked obvious. The model has a virtual eye that adapts to the light, so a darker sky makes it open up, and a storm ends up looking almost the same as clear weather. The fix that goes with that diagnosis is an exposure compensation driven by the weather: from −1.75 EV at midday to −4.75 EV at night, per unit of storm darkening. At this storm that meant going from −0.9 EV to −3.3.
The frame went from 82 to 86. Brighter.
The problem wasn’t exposure at all. What was lighting that frame wasn’t lit. The low clouds, the shadow side of the volumetric clouds and the rain are all drawn with fixed colours, because they’re effects, not surfaces. At night they formed a pale veil over a dark field, and no physical light model can darken something it doesn’t light. The fix is to scale everything unlit by the square root of the perceived brightness, with a floor of 0.35 on the rain so you can still read that it’s raining. The frame dropped to 35: darker than a clear night by the numbers you’d expect, and the storm still reads.
The note from playtesting was short: the light changes at dawn are too harsh. We measured it, logging the sun’s direct intensity every two game minutes at the default speed of one real minute per game hour.
Left: the sun’s direct light. Right: what the player actually sees. Both plotted from Play-mode logs and the captures.
The sun’s direct light went from 0 to 5 within the first fifth of a degree above the horizon, which is about one real second. At 2.5° it reached 6.7, five and a half times the noon sun. Long shadows snapped in at 3°. It felt like someone had flipped a switch on the landscape.
It’s the virtual eye again, and this time the diagnosis was right. With the sun below the horizon the ground gets very little light, so exposure climbs. When the sun appears, everything facing it gets that full exposure multiplied by fresh direct light. Physically defensible, and it reads like a light switch.
The first fix we tried kept the physics and changed what the eye measures: meter the exposure against light hitting sun-facing surfaces as well, not just the ground. It lowered the peak. It also made the ground (which is most of the frame in an RTS) get darker as the sun came up, from 76 to 57. A sunrise that dims the world is worse than a harsh one. We took it out.
What shipped is a small patch to the package. Direct light from the sun and moon ramps in with a smoothstep between 0° and 20° of altitude, and the ramp is included when the exposure is metered, so the eye follows the light rather than fighting it. Shadows now fade in by 8° instead of 3°. The sun grows from 0 to 2.4 over about an hour of game time, peaking at 12° at twice the noon value, and the frame brightens from 54 to 72 without a single dip. Sunset is symmetric, so the golden hour got softer too. Three tests pin it: the sun enters slowly, its low-angle peak stays under 65% of the unramped one, and the ground never gets darker between dawn and noon.
The package came with a reference configuration: 500 m shadow distance, four cascades, 4096 shadow maps, 64-bit HDR. Copying it would have been easy, and wrong. Our camera is tilted 52°, has a 60° field of view and flies between 18 and 75 m. The top edge of the frame looks 22° below the horizon, so the sky never appears. The farthest point you can see is about 173 m away, and 42 m when you’re zoomed all the way in.
Torches, braziers and campfires are scaled by how open the virtual eye is, times a gain of 4. At midday that comes out near zero, because a campfire at noon doesn’t compete with the sun. By day a fire is sold by the heat shimmer above it, at night by its light. At night they come up to full. We picked the 4 from captures: at 1, the islands of light that the gameplay depends on were barely visible in a physically dark night.
Midnight under a full moon: about 0.26 lux. Vision recovers inside each pool of light, fully at its centre, and stays at 55% everywhere else. Overlapping lights take the maximum, not the sum, so a camp with twenty fires doesn’t cancel the night for the whole map.
Two smaller things turned up along the way:
We also found and patched a bug in the package itself. After a time jump, its multiple-scattering pass kept the previous hour’s ambient, so the night sky came out inflated: 0.064 lux at −12° instead of 0.008. The eye adapted to that fake brightness, and the actual night went nearly black for several seconds. It now restarts the scattering after a jump and iterates until it converges, at most eight times.
Cost: about 0.3 ms of CPU. The sky is recomputed at most ten times a second, and the sky’s reflection probe is 128 px, updated one face at a time.