Planetary Atmospheric Scattering Shader

Hello!

Been wanting to do this for a while now. Saw my fellas in our discord do atmospheric scattering, so I finally decided to try it out.

Everything is done in the world (heh) shader, using 5 iterations (we don’t have loops so its a of node groups)

It’s done by sampling the view ray, taking the intersection of the atmosphere and the planet, and diving it into steps.
Then for each iteration, the contribution of the view and light optical depth multiplied by the scattering coefficient, are added together to get the final combined transmittance.

I managed to remove two inner loops, which is used to numerically integrate the light and view optical depth, by analytically integrating the light optical depth and factoring in the view optical depth with the main loop.
Still can’t believe it works, but it’s a massive speed-up in the shader (removing 5+5 samples of optical depth per iteration)
It is Rayleigh scattering for now, I’m planning to add Mie scattering and absorption in the future.

6 Likes