Replace the atmosphere parameters with more accurate ones from ARPC


I have a huge interest in computer graphics & color science and I have developed Enhanced Cloudscapes and Enhanced Skyscapes for X-Plane 11. Most modern flight simulators including MSFS, DCS and X-Plane 12 started to use physically based sky implementations and there has been something about them that was really annoying - overly purple sunsets / sunrises. I have been looking into the issue and I finally came up with a solution.

Firstly, the same issue is shared between so many simulators because they all use the same few papers (most notably Eric Bruneton’s and Sebastien Hillaire’s) as a basis for their implementation, and turns the reference these papers used for some of their parameters had a significant error. The atmosphere is rendered by casting rays and calculating the scattered & absorbed light by physical equations. As different media scatter and absorb light differently, their scattering and absorption behavior is expressed using scattering and absorption coefficients. And the issue lies in how these coefficients are calculated. The physical equations used in atmosphere rendering are normally defined for a spectrum of light, but in computer graphics rendering is not done spectrally but using tristimulus values (such as RGB) due to computing power limitations. This poses an issue as not only the physical equations themselves but the scattering and absorption coefficients as well are defined spectrally (in other words, for a given wavelength) and not for tristimulus values used in rendering. For rendering in RGB, the reference used by these papers picked a single wavelength for red, green and blue as an approximation. The issue is that there isn’t a single wavelength for red, green and blue - 680 nm light is red, but so is 630 nm light and this approach of picking a single wavelength for red, green and blue doesn’t take that into account. Therefore it is a really poor approximation. My solution was developing a way to take all wavelengths into account when calculating the coefficients for red, green and blue. For this, I used CIE 1931 XYZ color matching functions and converted them into sRGB (as the rendering is done in sRGB color space), which means that now I can convert any wavelength I want into sRGB. My approach is simply using these sRGB values as a weight and taking a weighted average of the coefficients. For instance, when calculating the coefficients for red, if a wavelength has a higher amount of red when converted into sRGB than another wavelength, then it will have a higher contribution to the coefficient as well. Using this approach, I managed to significantly improve the accuracy of the sky colors when tested against a spectral implementation of Sebastien Hillaire’s paper and a spectral path tracer.

To validate my approach, I used a root finding algorithm which tried to find the scattering and absorption coefficients which minimized the error between the spectrally rendered reference and also converted a test incoming light and transmitted light into sRGB to solve for the coefficients. In both cases, the expected coefficients almost perfectly matched the coefficients calculated by my approach.

Under the spectrum calculations section, the first line is Rayleigh scattering coefficients and the next line is Ozone absorption coefficients for red, green and blue, calculated using my approach. And the array shown by “x” are the Rayleigh scattering and Ozone absorption coefficients that match the spectrally rendered reference the best, found by the root finding algorithm. You can see that they are in great agreement.

Finally, I can show you the results.

Using the original coefficients:

Using the coefficients from my approach:

As this approach was recently adopted by X-Plane 12, I decided to use it for comparison as well.

Here’s X-Plane 12 with the old coefficients:

And here’s X-Plane 12 with the new coefficients:

So, that’s all. My work is open source and can be accessed from GitHub: GitHub - FarukEroglu2048/ARPC: Atmosphere Rendering Parameter Calculator

Lastly, why did I create this thread? Because I need your help. Meanwhile my work is open source and really easy to implement (it only requires changing 6 parameters in the game engine), it needs to be implemented by the developers of the simulator. And I really don’t know how to contact Asobo developers. In the past the community helped many developers to establish communications with Asobo and I believe that I can have my voice heard by Asobo with the help of you as well. Thank you all in advance.

ARPC is MIT-licensed and even all of it can be included in MSFS without any royalties, which would allow for different skies depending on different conditions. Either case, only the coefficients themselves are enough to finally get rid of the purple skies and they should be fairly easy to change. I’d be more than happy to document anything that’s needed if Asobo team decides to implement any part of ARPC or if they have any questions. I’d also be really happy to give more technical details on how ARPC works if needed.


This is excellent work and deserves Asobo’s full attention to implement.


Sometimes people do things that make me feel like I’m a very dumb person… this is one of those times.


Jaw drops down to desk!!!
Looks really good! Great work!


Do you happen to have any examples with some cloud coverage? Curious how those will look.
Great work!


As I can’t implement it in MSFS myself (the first comparison is from a ShaderToy implementation of Hillaire’s sky), I can’t show with the clouds. If you don’t mind XP12 comparisons (the atmosphere parameters are exposed to the user for debugging reasons in their case, which is quite rare but really helped in this case), I can do that though.


Absolutely! This is great work and could be a huge and easily implemented boost to MSFS’ skies, which, frankly, have started to fall behind the competition quite noticeably.


Asobo should’ve a look at this. It’s so unrealistic right now


This is great work and I hope the dev team can look into this and make it possible for us to have.


You’ve done some insane work on this. Asobo really ought to see it and make this possible.


If I could vote for this 100 times I would. I am so fed up with the cliched “African safari” sunset colours every single time. Even on an overcast wet winter’s day in the UK! Your colours are to me, much more representative of the real world rather than Asobo’s fantasy land.


voted, this needs asap implementation from asobo.
the calculations are definitely wrong in msfs.


It would be awesome for Asobo to take this in consideration.
Mods can you try to get the devs attention to this?


Looks great, sounds great … now its your turn Asobo/MS


I don’t understand the tech but the shots speak for themselves. I am much grateful to @Biology2394 for sharing his knowledge and I hope the team can integrate this into the sim.


It’s really needed. Thank you !


Seems easily and absolutely one of the best changes to fast-lane into MSFS!! And, as Biology mentions, in the long run to delve deeper.


This looks fantastic. Asobo should definitely look into this further.

I love the sky colours in MSFS but some day-to-day or latitude specific variation would be a massive enhancement to the experience.


There we go!


Voted [MODERATOR EDIT: Please do not ping team members] it’s yours…