
Program usage:
Compile project
file in visual studio 2005 (preferably)
The program consists of several modules: the file parser, the raytracer class, and the photon map class and photon data structure
The file parser is the one used from the cs480 ray tracing assignment. Model's adhere to the guidelines setup in
http://www.cs.bu.edu/fac/sclaroff/courses/cs480-05/p4/model_file_format.html
The raytracer that I am using works with quadrilateral models , but not csg models and it has trouble with spheres of certain sized radii.
The raytracer class was adapted to handle the photon mapping involved by adding 2 functions: emitPhotons and TracePhotons which both referenced a photon map which was added to the private data members of the ray tracer class. The ray tracer supports diffuse and reflective surfaces, specular results are not supported.
The photon and photon map data structures follow the format as those as laid down by
Jensen, Realistic Image Synthesis Using Photon Mapping ,.
The photons are defined
as:
*/
//**********************
typedef struct Photon {
//**********************
float pos[3]; // photon position
short plane; // splitting plane for kd-tree
unsigned char theta, phi; // incoming direction
float power[3]; // photon power (uncompressed)
} Photon;
The photon map holds all of the photons that are absorbed and places them into a kd-tree.
Also the light source in the scene is considered as a diffuse point light at the top of the cornel box. One could try to define a box light using a series of diffuse point lights but being how long it took to render a scene with one light , not to mention that the way the program is currently setup it would emit the number of photons per light source, so if you're emitting 500,000 photons from each light it would be very costly in terms of computation, not to mention all the vector reflections random number generation that would need to occur. Hence the program right now presumes there is only one light source, which seemed to provide adequate lighting.
And a second scene in which the boxes had surfaces with a reflective and diffuse coefficient.
mat ID 4 0.5 0.5 1 0.3 0.5 0 50 0 0.3 0
I rendered the scenes
using in my irradiance estimate a search radius of 15, a density estimate
of 500, and varying the number of photons as emitted using levels of 50,000
, 250,000, and 500, 000 respectively. I found that 50,000 photons was not
enough to properly light the scene. Also, the image quality did not increase
when the emitted photons were increased from 250,000 to 500, 000 by any
noticeable degree. I did try one render at 1,000,000 photons but ended
up getting lots of noise.
Updated (4/11/06): The noise problem has been corrected, I had forgotten
to set a cap on the RGB values at one point in my code.
No more oversaturation now.
Also, though the procedure appears to be working over all I suspect that the reason for the lack of accuracy in my renders is either my choices involving my search radius and density estimate or that perhaps I forgot to normalize a vector somewhere.
Standard Cornel
Box with just Ray Tracing |
Ray Tracing and
no shadows |
50,000 |
250,000 Photons
with no shadows |
250,000 Photons |
500,000 Photons |
1 million photons!!! |
Same scene but
boxes that have ambient and reflective coeffcients 50,000 Photons |
250,000 Photons |
500,000 Photons |
thods for Light Transport Simulation The Cornell Box Photon Maps An Investigation Into
Source Code:
raytracer.rarMajor thanks to Jonathan Fung for letting me use his
ray tracer code from his cs480 project. Also for other references to the
nature of photons / coding ideas see the following sites:
Realistic
Image Synthesis Using Photon Mapping
Photon Mapping - Zack Waters
Robust
Monte Carlo Methods for Light Transport Simulation
The
Cornell Box
Photon
Maps
An Investigation Into Lighting in Computer Graphics: PhotonMapping