Work Log by Kevin Beason

Latest personal graphics developments

Archive for October, 2008

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.

5 comments

Fixed absorption of photons and rays

I fixed some simple bugs in the absorption of photons and along rays 6 months ago. The first image is from a debugging session for this. Second image shows a cognac glass with fixed absorption, and also  a text label in the bottom right corner that is automatically added now. The rather hideous texture is something I made in Gimp.

I abandoned my triangle-only architecture and moved to a more flexible one using inheritance. Of course I have Primitive::TriangleMesh, but here is a Primitive::Instance(Primitive::Sphere) which means its an instance of sphere, where the instancing’s matrix is used to store the ellipsoid transformation. I guess this must be the most boring instancing image ever created. Still, it’s an achievement!

Gallery links to full-size images thanks to this thread.

No comments

Embargo is over

I’ve blockaded updating my log to wait for another project to complete for too long. So here is something unrelated.

Photographic DOF

Photographic DOF

Previously I had limited support for Depth of Field (DOF) whose only input was the angle subtended by the lens relative to the center of the focal plane. In March 2008 I added a conventional photography-based “f-stop” parameter system (f/2.8, f/5.6, etc.). The reason for this was to more accurately simulate what a real 35mm camera would do for a real world focal distance. Now the focal length of the lens depends on the focus distance and the lens size on this f-stop parameter. As is my usual fashion I meticulously recreated someone else’s image, in this case Figure 14.2 in Shirley’s Realistic Ray Tracing 1st Ed.

That’s all well and fine. However, combining this efficiently with Keller’s “Strictly Deterministic Sampling” and path tracing forced me to implement deterministic ray trees with arbitrary depth. This was a bloody nightmare of brainstorming and code refactoring (which is still a mess to this day). Uhg. I think I spent like a week on that. But the pay off is huge in variance reduction when path tracing with a single explicit light sample and a large area light, thanks to maintaining sample stratification from path-to-path within a pixel.

The basic problem I was having was how to branch the ray tree arbitrarily but be on the same branch in a completely different path. The basic solution was to increment the ray tree dimension (d=d+1) each time I might branch, even if I don’t take samples from that branch. But don’t quote me on that… it’s in the Pane source. Which I will post sometime.

DOF w/Bokeh effect and chromatic aperture

Taking inspiration from SunFlow and Toshiya Hachisuka’s “Kitchen with Programmer’s Art”, I added simple n-sided-polygon Bokeh effect and hacked-up chromatic aberration to produce the above image (click for full size). You can see the lens shape and aberration clearly from the bright dot I added in the scene under “.25m”. Together these features add noise and a color shift so they are disabled (commented out).

More to come.

No comments