CS 563 Final Project
Damon Blanchette
-- Theme --
For my final project, I plan to combine two things I love: computer
graphics and quality craft beer. I'll be creating a render very similar
to this (low-quality) image I took with my phone:
All brews that Allagash release are fantastic (the Allagash Tripel is
a personal favorite), but this one, the Hugh Malone Ale, in particular,
is a limited edition that stands out.
I'll need to either scan that label somehow in high quality to get it in
my render, or maybe I could just email the brewery and see if they will
send me the image in large-format.
While this photo was taken in a kitchen environment, I plan on making
the setting for the render a bar or pub. I know I've seen somewhere
online a great panoramic image, that may have been HDRI, of the
inside of a pub somewhere. I had thought it was originally a light
probe image, but I couldn't find it on Paul Debevec's website. I will
continue to search for it.
Some inspiration for this image is from Josh Wills' winning image in
the 2003 UCSD Rendering Competition, which can be seen here:
http://graphics.ucsd.edu/~jwills/renders/mm.html.
His image is incredibly realistic, and it is something I hope to
mirror in my render, though
mine will hopefully be even better. My scene will differ in a few ways,
including just the look of beer as opposed to whiskey, the beer "head"
that will need to be included, and the surrounding scene.
I'll be using a few of the algorithms and effects from the class text
(Ray Tracing from the Ground Up by Kevin Suffern) to create the
render, including:
- Depth of Field.
- Texture Mapping.
- Some of the transparency code.
In order to create the render, there are multiple pieces of
functionality I will need to add to our base ray tracer, including, but
probably not limited to:
- Photon Mapping, for general realism and caustics.
- Environment Mapping, for realism.
- Beer's Law (aptly named) and Fresnel terms for realistic glass.
- Some kind of acceleration scheme (or I'll need to find a very fast
computer).
- A way to do the "head" of the beer: millions of tiny bubbles.
I plan to update this page as I'm doing the project, as a sort of
"work in progress" so you, the world, can follow my process.
-- Modeling --
This will undoubtedly be the easiest part of the entire project. I'm
going to model the bottle and tulip glass from scratch in Blender
and export them as .ply files for import into the ray tracer. The table
on which the glass and bottle stand will either be just a simple plane
or a table top also modeled in Blender.
Here are some screen captures of my work in Blender with modeling:
The above image is my bezier spline interpretation of the cross
section of the tulip glass. When you take that and rotate it around 360
degrees, you get this:
Below is a full screenshot of what the label looked like separated
from the bottle. I took the bottle mesh and cut out just the faces I
figured would make up the label, and then pasted
the label onto them with UV mapping.
-- References --
In addition to Josh Wills' image, I will be using a variety of
references:
- I found a paper by Paul Cleary et al about making the foam on top of
various liquids, which should help me with the beer head. Here's the
pdf:
ACM
link. The paper is about animating
the bubbles, but hopefully I will be able to simplify it for a static
image.
- This
page on our professor's own WPI site has a great explanation of
photon mapping.
- Global Illumination using Photon Maps by Henrik Wann Jensen -
the original paper introducing Photon Maps from 1996.
- Wikipedia article on Photon Maps - http://en.wikipedia.org/wiki/Photon_mapping
- kd-trees, which are used to hold the data from the two Photon
Mapping passes: http://en.wikipedia.org/wiki/Kd-tree
- I used this kd-tree library: http://code.google.com/p/kdtree/
- This google code ray tracer
by the same author as the kd-tree library.
- Focus on Photon Mapping by John Marlon. Amazon
- Realistic Image Synthesis using Photon Mapping by Henrik Wann
Jensen. Amazon
- Ray Tracing from the Ground Up by Kevin Suffern, the book we
used for the class. Book
Website
- This
page by Zack Waters about photon mapping.
- This amazing
page by Grant Schindler about photon mapping, complete with an
in-browser live demo.
-- Architecture and Updates for the Base Ray Tracer --
Here's a very high level class diagram showing pretty much all the
classes I'll be using, except for the utility classes (Ray, BBox,
Vector3D) which I won't need to change anyway. Classes I'll be adding
or changing from book's code are glowing orange. I'll probably need to
highlight or add more classes as I go on and figure out how exactly I'm
implementing certain features (especially photon mapping).
I'll need to basically create an entire class just for Photon Maps,
which is listed at the top. This will also entail creating the pieces
necessary for kd-trees, which will store the data, and
a data structure for a Photon, which is what gets shot through the scene
to make the maps.
I will most likely need to create a completely new Tracer (which I'll
call PhotonTracer) to be able to utilize the photon maps created by the
PhotonMap class.
The Dielectric material will need to be edited a bit to get the
Beer's Law equations in there.
The extra Mapping classes are for textures - Planar for the table,
Cylindrical for putting the label on the bottle, and Environment for an
environment map.
*Update* After a few weeks of actual work on the project, I found
that the classes I needed to change were different than I expected.
Here is a more accurate image of the class changes:
By far the biggest changes involved the World and PhotonTracer
classes. The World class now contains the new code (quite a bit of it)
for building both the global and caustics photon maps. It also
contains the new Photon struct, which holds the photon's power,
direction, and position. The PhotonTracer class is completely new, and
has all the code for doing normal ray tracing and also reading
through the photon maps for determining illumination.
The Ray class was changed to add variables pertaining to photons.
Small changes were made to the Light class (and subclasses), the
Material class (and subclasses), and the ThinLens camera class. All
changes involved adding functions so that they would work
with photon mapping.
-- Performance --
Test renders were created fairly quickly, on the order of anywhere
between 2 to 30 minutes. Render times were obviously very much affected
by multiple variables, including: number of samples per pixel,
number of photons fired into the scene, maximum depth of the rays and
photons, size of the final image, and number of photons gathered for
pixel light contribution. Increasing the values of any of these
variables created render times in the hours.
-- Concerns --
There are a few concerns about doing the project as I've conceived it
in my head:
- Photon mapping will require some rather large changes to quite a few
parts of the base ray tracer. This is my single largest concern. I
don't know exactly how big or what
changes will need to be made (yet), but I'm thinking it will not be all
that straightforward.
- Beer's law, Fresnel terms, and advanced transparency. I don't
exactly know yet how difficult it is to add these advanced transparency
effects to the ray tracer.
- Will this take a week to render?
- The head of the beer is a big question mark. If it turns out to be
too much to create actual super-realistic foam bubbles, I may just fudge
it with a lot of tiny semitransparent
spheres or even a texture if all else fails (or I run out of time).
-- Timeline --
- Week 1: Modeling, set up scene and camera, start on photon mapping.
- Week 2: Continue photon mapping, start advanced transparency (Beer's
Law, Fresnel)
- Week 3: Finish up advanced transparency, work on beer head, tweak
settings for realism.
- Week 4: Test, tweak, and render.
-- Updates --
- Beginning of Semester to 3/29/10:
Two parts of the ray tracer that I'll need are fairly well complete -
texture mapping and fresnel terms for the glass. Here are a few images
rendered as tests...
This is some clear glass, with fresnel reflections and transmission,
which will work well for the tulip glass holding the beer:
Here is the same image, but with brown colored glass, which (when made a
bit lighter) will work great for the bottle next to the glass:
And, here's my first shot at an actual cup-shaped object made out of the
same glass material as the bunnies. It's obvious I need a better mesh!
The top of that glass is totally messed up.
Allagash came through! What an awesome brewery. Here's one of three
images they sent me, and this one is absolutely perfect for what I need:
- 3/30/10:
I worked a while in Blender and created a fairly good model of the tulip
glass, which I brought into the ray tracer and rendered with a clear
glass dielectric material. Looks pretty good for a first
try if I do say so myself!
The model itself needs work - all those wavy lines at the edges and the
wavy specular highlights are almost certainly due to the way the
triangles are arranged. I'm going to try increasing the number of
triangles and that should smooth things out a bit.
Another thing - this image with 25 samples per pixel took 32 minutes to
render! That's just one glass, with no global illumination. I'm really
going to need to figure out some kind of acceleration scheme,
or get a faster computer!
- 3/31/10:
I very much increased the number of triangles in the mesh (to about
230,000) and ended up with a still not perfect but much better image:
Looks like I'll still need more - the edges and the specular highlights
are still noticeably wavy.
- 4/4/10:
Got the Allagash bottle pretty much done, along with the label (which is
put on a half-cylinder shape with UV coordinates), and a wooden table:
- 5/4/10:
In the last month much has happened. Photon mapping took BY FAR the
most amount of time for me to get working – as I'd say about 95% of my
time was spent on it (hours every night for the entire
month). I went through many, many iterations and trials attempting to
get good looking images with photon mapping. Here are just a few of the
test cornell box images I ended up with
in the process:
Here's photon mapping working (for the most part):
Somewhere around this point I got sick of cornell boxes and decided to
work on the final image, using photon mapping:
The last one here is the most recent image I've come up with, rendered
today, May 4th, 2010. The caustics are (basically) working, sort of.
The beer looks ok. The glass is a bit bright, on both the bottle
and the tulip glass. The bubbles, which consist of 30,000 tiny matte
spheres, are certainly lacking. I plan on rendering a higher quality
image, probably overnight tonight, since it will take a long time.
This image only has 10 samples per pixel and gathers only a minimum of
20 photons per pixel. The background is gone because it completely
messes up the other textures (see image above this one).
This project was severely hindered by problems with photon mapping. I
put the blame on my own lack of programming experience, lack of
sufficient time, and it is also my opinion that the ray tracer
we were using was ill-suited for the addition of photon mapping.