{"id":37,"date":"2008-10-26T21:11:42","date_gmt":"2008-10-27T04:11:42","guid":{"rendered":"http:\/\/www.kevinbeason.com\/worklog\/?p=37"},"modified":"2008-10-26T21:11:42","modified_gmt":"2008-10-27T04:11:42","slug":"preetham-et-el-sun-and-sky-light-model","status":"publish","type":"post","link":"https:\/\/www.kevinbeason.com\/worklog\/2008\/10\/26\/preetham-et-el-sun-and-sky-light-model\/","title":{"rendered":"Preetham et el. sun and sky light model"},"content":{"rendered":"<p>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&#8217;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.<\/p>\n<p>The second image shows the sun&#8217;s glare (using another of Shirley&#8217;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.<\/p>\n<p>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.<\/p>\n\n\t\t<style type=\"text\/css\">\n\t\t\t#gallery-1 {\n\t\t\t\tmargin: auto;\n\t\t\t}\n\t\t\t#gallery-1 .gallery-item {\n\t\t\t\tfloat: left;\n\t\t\t\tmargin-top: 10px;\n\t\t\t\ttext-align: center;\n\t\t\t\twidth: 33%;\n\t\t\t}\n\t\t\t#gallery-1 img {\n\t\t\t\tborder: 2px solid #cfcfcf;\n\t\t\t}\n\t\t\t#gallery-1 .gallery-caption {\n\t\t\t\tmargin-left: 0;\n\t\t\t}\n\t\t\t\/* see gallery_shortcode() in wp-includes\/media.php *\/\n\t\t<\/style>\n\t\t<div id='gallery-1' class='gallery galleryid-37 gallery-columns-3 gallery-size-thumbnail'><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.kevinbeason.com\/worklog\/2008\/10\/26\/preetham-et-el-sun-and-sky-light-model\/image\/'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.kevinbeason.com\/worklog\/wp-content\/uploads\/2008\/10\/image-150x150.png\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/www.kevinbeason.com\/worklog\/2008\/10\/26\/preetham-et-el-sun-and-sky-light-model\/image021\/'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.kevinbeason.com\/worklog\/wp-content\/uploads\/2008\/10\/image021-150x150.png\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" \/><\/a>\n\t\t\t<\/dt><\/dl><dl class='gallery-item'>\n\t\t\t<dt class='gallery-icon portrait'>\n\t\t\t\t<a href='https:\/\/www.kevinbeason.com\/worklog\/2008\/10\/26\/preetham-et-el-sun-and-sky-light-model\/skylight\/'><img loading=\"lazy\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/www.kevinbeason.com\/worklog\/wp-content\/uploads\/2008\/10\/skylight-150x150.jpg\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" srcset=\"https:\/\/www.kevinbeason.com\/worklog\/wp-content\/uploads\/2008\/10\/skylight-150x150.jpg 150w, https:\/\/www.kevinbeason.com\/worklog\/wp-content\/uploads\/2008\/10\/skylight-299x300.jpg 299w, https:\/\/www.kevinbeason.com\/worklog\/wp-content\/uploads\/2008\/10\/skylight.jpg 514w\" sizes=\"auto, (max-width: 150px) 100vw, 150px\" \/><\/a>\n\t\t\t<\/dt><\/dl><br style=\"clear: both\" \/>\n\t\t<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-37","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/www.kevinbeason.com\/worklog\/wp-json\/wp\/v2\/posts\/37","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kevinbeason.com\/worklog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kevinbeason.com\/worklog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kevinbeason.com\/worklog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kevinbeason.com\/worklog\/wp-json\/wp\/v2\/comments?post=37"}],"version-history":[{"count":1,"href":"https:\/\/www.kevinbeason.com\/worklog\/wp-json\/wp\/v2\/posts\/37\/revisions"}],"predecessor-version":[{"id":41,"href":"https:\/\/www.kevinbeason.com\/worklog\/wp-json\/wp\/v2\/posts\/37\/revisions\/41"}],"wp:attachment":[{"href":"https:\/\/www.kevinbeason.com\/worklog\/wp-json\/wp\/v2\/media?parent=37"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kevinbeason.com\/worklog\/wp-json\/wp\/v2\/categories?post=37"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kevinbeason.com\/worklog\/wp-json\/wp\/v2\/tags?post=37"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}