Implementing the Nishita sky texture

Written the 17th of June 2020

I’m not a computer scientist, but I really felt the need to have a better sky system in Blender other than the already available Hosek-Wilkie and Preetham models…
So I worked on implementing a new single scattering sky model, and today the Pull Request for the Nishita Sky Texture has finally been merged into the main Blender 2.90 branch!

How it works

Following this article, the Earth atmosphere can be approximated to a simple sphere, this makes is easy to calculate the distance from the Earth’s surface at every point, making it possible to get the density of air, air molecules and ozone particles at every height.
The implementation in Blender pre-calculates a 512 x 128 pixels image, and then maps it to the 360 degrees environment of the scene.
Multithreading the image calculation also helped make the sky calculate in real-time, this was not possible in 1993 when Nishita first wrote the paper for sky simulation named “Display of the Earth Taking into account Atmospheric Scattering”.
The sky calculation is done in the spectrum domain, 21 wavelengths of visible light are taken into account before converting to RGB, this was found to be the best amount based on some tests.

Helps

I’ve already studied the basics of C code in high school, but having never touched the Blender code before made me afraid of doing it, so I’ve reached out to the developers asking for help, and was surprised by seeing all of them helping and guiding me through the process, huge thanks to them all!