Final Report
As proposed before (proposal at bottom) I implemented a ray tracer with photon mapping.
- First Pass send a packet of photons from the light source and make a cache for results (photons eliminated using Russian Roulette) Cache modeled as a KD-tree.
- Second Pass calculate indirect illumination using photon map. Using KNN algo.
Extra Credit- Did a twist on photon Mapping, treating stored photons as indirect light sources of bi-directional path-tracing.
Photons store an extra field that is light ray-depth when it was cached
Shadow rays are used to these indirect lighting sources just like direct lighting.
It uses the formula
(photonMap[i].depth < (total_depth - eye_depth))
to select which photons are used as sources at current camera ray depth- Individually it isn't perfect but adding it to forward path-tracing in-direct light can provide a way to get light from small windows.
Building instructions
fully same drill as asst3 to make
code at /afs/cs/academic/class/15462-f15-users/dsaksena/asst5
cd build
cmake ..
make
make install
./pathtracer -s 64 -t 8 ../dae/sky/CBspheres.dae
best results for 10,000,000 photons and k-NN (k = 64)
Over assignment 3 key controls we have also new keys in RENDER mode (should've pressed R)
Key | Effect |
---|---|
n/N | Decrease k or radius |
m/M | Increase k or radius |
l/L | num_photons/10 |
;/: | num_photons*10 |
j/J | num_photons*2 |
k/K | toggle k-nn/fixed radial search |
p/P | toggle bi-directional |
- For bi-directional it takes A LOT of time because of the million-photons, suggestion to go to pathtracer.h and make int num_photons = 1000
Results
As can be seen below i get as better results than forward path-tracing as we have better caustics from the Glass ball now than path-tracer
Rendering by Photon Mapping using 4,000,000 photon kd-tree and 32-NN
Rendering without Photon Mapping
Photon Visualization
Design
Photons are stored like primitives in a std::vector
We use std::sort to make the kd-tree and a short flag field in photons to mark the next dimension of split
Leaf size is 1
kd-tree gives logN complexity, shot render time of 1,000,000 photons from 5 hours to 2 minutes
Improvements to be made
Definitely could adjust the brightness of photon-map calculated radiance, I am using a constant (7) now to multiply to it but would like to fix the math bug behind it.
Lack of blue and red wall reflection, we can get some in CB_spheres_lambertian, but not much
Lambertian surfaces need a lot more photons, results different with same photons and rendering is much slower. Exploration required. More photon requirements lead to artifacts even in million photon renderings like below.
Hacks
1) Magic Constant PHOTON_MAP_BOOST used to correct the low radiance given by photon-map
2) For faster collection of photons russian roulette skipped for MIN_PHOTON_BOUNCES could contribute to above low radiance but not the main factor already checked
Image perturbed by magic constant:
Proposal
- I will be working alone, focusing on implementing Photon Mapping in option F: Advanced Monte Carlo Rendering. Reading the wiki I expect it to be a 2 step process. My extension will be implementing these 2 steps fully.
- First Pass send a packet of photons from the light source and make a cache for results (photons eliminated using Russian Roulette) Cache modeled as a KD-tree as proposed by wiki.
- Second Pass calculate indirect illumination using photon map. Using KNN algo.
If instructors agree I will have full credit on implementing photon mapping correctly and then I would like to work on extra credit (because I need it and want it :) )
I will firstly work on bidirectional path tracing as extra credit.
Secondly, since I was a 418 student, I shall like to implement Efficient BVH Construction via Approximate Agglomerative Clustering for more extra credit.
I really don't expect to reach here but if I do I like Option I: kPhone 869 (15-869 Assignment) especially since I will join Apple GPU Compute team to work on Iphones. More extra credit I hope.
If the instructors agree to this proposal great, otherwise if they feel photon mapping is not enough workload I can do bidirectional path tracing or Efficient BVH Construction via Approximate Agglomerative Clustering for normal credit as well.