Work Log by Kevin Beason

Latest personal graphics developments

Preetham et el. sun and sky light model

I was really inspired by the cool images lycium and greenhybrid were making using the sky model by Preetham et al., so in March I read the paper again and overcame my laziness and gag reflex at the spaghetti mess of equations, and hacked together the sky and sun light part of the paper (first image). In hindsight I guess it’s not that complicated really. The sun is straightforward yet also tricky. The sky is basically parameterized by the altitude of the sun and now near the view vector is to it and the horizon. They precomputed a bunch of coefficients that are essentially interpolated. The major hangup I had is that a division by zero happens for turbidities less than 1.7 (or so) since one of the interpolated values goes negative! Watch out for that. Also I seem to recall something numerically terrible happens near the horizon which necessitates some epsilon clamping.

The second image shows the sun’s glare (using another of Shirley’s papers, implemented a few years ago). I modified the third function (f_3) to not be scaled by the glare lines but be angularly symmetric, which produces less pronounced lines.

I added support for baking the sky light to an environment map which I can sample efficiently using the large area light importance sampling from PBRT. One to four shadow rays are always sent to the sun, and a number of samples are taken from the environment. Photons emit from the sun or the sky light with 50% probability each. An example environment map is shown in the third image.

4 comments

4 Comments so far

  1. phresnel December 10th, 2008 7:26 am

    Neeeat. I wasn’t aware of this blog actually, you should advertise more :S

    Great results so far, keep on. And your site is now bookmarked, no, burned into my browser.

    Many greets

    seb (phresnel / ex-greenhybrid)

  2. phresnel December 10th, 2008 7:31 am

    Oh, and, I stumbled over your blog while looking up “http://wscg.zcu.cz/WSCG2007/Papers_2007/short/E59-full.pdf” in google (you where on page 2 for ‘preetham shirley sun sky’, btw), “A critcal review of the Preetham Skylight Model”, which I can recommend if you’re still in sunskyland.

    seb

  3. phresnel December 10th, 2008 7:32 am

    Sorry, but this might be interesting, too, as Preetham implementations seem to be really rare: http://www.spot3d.com/vray/help/150R1/examples_vraysun_sky.htm

    seb

  4. Marcio June 16th, 2009 1:43 am

    Hi there,

    Great Stuff! I have been trying to implement the Preetham model myself.

    I have a question though: how did you compute the sun radiance (and converted appropriately to “color space”)?

    Keep those nice renders coming 🙂

    Cheers

Leave a reply