Monday, October 7, 2013

Shadow Photon Optimization

Originally, I was doing my shadow calculations the "traditional" way by sending shadow rays from the intersection point to the light source to see if they were obstructed. However, sending shadow rays can be an expensive process and so one alternative technique to use is shadow photons.

In the first step of this algorithm, shadow and illumination photons are traced through the scene. Illumination photons are stored at a photons first interaction with a surface and shadow photons are found by continuously tracing the photon in the same direction and storing it at its interactions with subsequent surfaces. 

In the second step of the algorithm, at each intersection point, both shadow photons and illumination photons are gathered in the same way "regular" photons are for global illumination calculations. Once they are gathered, there are 3 outcomes:

1) Shadow photons but no illumination photons. Area is completely in shadow so skip direct lighting calculation. No shadow rays necessary

2) Illumination photons but no shadow photons. Area is completely illuminated so calculate radiance. No shadow rays necessary. 

3) Both shadow and illumination photons present. Hit point is at a shadow boundary/in the penumbra. Send a shadow ray to determine if it is lit or not.

Below is an example rendering with my new shadow algorithm with 64 samples per pixel. The quality of the shadows is on par with my previous shadows with only using half as many samples (before I had 16 pixel samples * 8 light samples).


No comments:

Post a Comment