Atmospheric Scattering Pixel Shader

PUBLISHED ON APR 13, 2013 — SOFTWARE

Atmospheric Scattering Pixel Shader

I spent some time this weekend working on an atmospheric scattering shader.

It works by comparing a ray cast from the viewer towards the sun and then finding the angle between that ray and a ray cast from the viewer to every sky pixel on the screen (inverse world view ortho projection). It finds the angle between each of these sky pixel rays and the sun ray (dot product). Now that it has an angle for each sky pixel, a color can be assign based on that angle with a number of rules for blending

This implementation is primitive but it beats staring at a black sky. I’ll revisit it when I do another cycle of polishing. Polishing small parts of your game can do wonders for self motivation.

TAGS: SOFTWARE