Friday, October 5, 2012
Sampling the Sun Directly
The sun covers only a tiny fraction of the sky, about 0.00047%, so with naive path tracing, most rays would get lost in space and the image would take forever to converge. By sampling the Sun directly, I was able to speed up my simulation tremendously. At each scattering point, I fire a ray directly towards the Sun, weighted by the Rayleigh scattering phase function in that direction, and weighted by the probability that a ray fired in a random direction would hit the sun. I also still fire a scattered ray in a direction drawn from the Rayleigh scattering phase function, however this ray cannot "see" the Sun. If I were to only sample the Sun, I would lose multiple scattering, which plays an important role in the appearance of the sky. For computing sample directions that are uniformly distributed over the solid angle subtended by the Sun (the Sun is not a point light or a directional light), I used the Sun class that I wrote for Photorealizer.