Brifing

Optimizing Sky and Cloud Rendering for Around The World

Implementing multiple scattering and custom tone mapping to enhance atmospheric realism in Godot.

Hacker News2 min

1Validating Scattering Models

The developer discovered that Povray failed to simulate multiple scattering, resulting in unrealistic, dark cloud bottoms. To confirm this, a custom multithreaded Monte Carlo ray tracer was written in Rust. This tool demonstrated that true multiple scattering distributes light more uniformly, effectively eliminating the metallic look observed in previous iterations.

2Indirect Lighting Adjustments

Clouds were updated to incorporate indirect sky light by tweaking surface normals to point upward. This simple adjustment allows clouds to adopt a blueish hue, blending them seamlessly with the sky. During sunsets, this technique mixes red direct sunlight with blue indirect light, creating a natural pink tint on clouds.

3Refining Raymarching Integration

An unnatural yellow horizon occurred regardless of sun position, likely due to improper attenuation during raymarching. By reordering the integration operations, the developer reduced excessive attenuation relative to inscattering. While this fix remains a numerical approximation, it significantly improved the visual quality of the sky without requiring complex, expensive calculations.

4Correcting Horizon Artifacts

The game planet is 75 times smaller than Earth, causing atmospheric curvature issues and a dark band at the horizon. A hack was implemented by adding a small value to the global view vector's y-component. This effectively pulls the sky down, hiding the dark band behind the planet's actual horizon.

5Tone Mapping Implementation

To handle HDR color values, the developer evaluated several tone mappers within Godot. Reinhard proved too dark, while ACES and AgX appeared overly desaturated. Ultimately, the Filmic tone mapper with a white point of 2.0 was selected, providing a soft, distant look for clouds and better overall scene contrast.

6Orrery-Based Celestial Mechanics

Calculating precise sunrise and sunset times based on location and season proved mathematically complex. Instead, the developer modeled the planet and moon as an orrery within the engine. By calculating the inverse transformation from the observer's perspective, the system accurately determines celestial positions, serving as both a feature and debugging aid.

7Iterative Lighting Calibration

Tuning the tone mapper required a non-linear approach, necessitating constant back-and-forth adjustments with scene lighting. The developer eventually reduced sky brightness by half to achieve superior contrast after tone mapping. This process highlights the interdependence of atmospheric rendering parameters, where small changes in one stage impact the entire visual pipeline.

8Atmospheric Realism Summary

The project demonstrates that achieving realistic skies requires balancing physical accuracy with performance-oriented hacks. By replacing insufficient lookup tables with custom scattering logic and utilizing engine-based celestial modeling, the developer successfully created a dynamic day-night cycle. These refinements ensure the game's visuals remain cohesive across varying lighting conditions and planetary positions.

Original article: Hacker News — Optimizing Sky and Cloud Rendering for Around The World