Few Questions on Photon Tracing

Started by
2 comments, last by jbarcz1 16 years, 5 months ago
Hello! I'm currently writing a little Photon Tracer. Although I read many gamedev-threads on this topic, a few questions remain. 1. Cosinus Lobe I'm using a simple point-lightsource that is placed right under the ceiling of my cornell box. I then generate a random direction for each photon. Question: Has the energy of the photon to be scaled with the dot-product of the "down-direction" of the lightsource and the photon-direction? This would give photons that are almost parallel to the ceiling an energy close to zero. If I have to do so, has this to be applied to diffuse reflection as well? 2. Storing a photon For the sake of simplicity lets assume my scene is purely diffuse. I assigned each object a diffuse reflection coefficient of 0.7 (ranging from 0 to 1). The way I understood it, at each intersection of a photon with a diffuse surface, I store the photon with an energy scaled by 1-0.7=0.3. In other words, the photon just lost 1/3 of its energy. I THEN create a random number between 0 and 1. If it's <0.7, I compute a random direction. if it's >= 0.7, nothing happens (it dies). Is that right? 3. Accumulation of Ray Tracing Color and Photon Map Color Currently, I use an uniform octree to store photons. In the second pass (The Ray Tracing pass) I look up each point of intersection in the previously created octree. I then sum up every photon that is stored in this cell. I then divide the energy by the number of photons to build the average. I also compute the distance from the intersection point to each of the photons to give photons that are far away less contribution. Question 1: Summing up the photons in a single cell seems to be wrong. Instead, I have to search the k-nearest neighbours? Is it right to just sum up the energy and to create the average? Question 2: Is it right that I compute final color = ray_tracing_color + color_from_octree; At last an example of what I achieved so far. Photon Tracer
Advertisement

1. You can do that, or you can choose the photon direction with probability proportional the dot product, and not scale them. Doing the latter will let you get away with using fewer photons, while still getting more or less the same answer (in the limit).

2. If you kill the photon with a probability proportional to the diffuse reflectance, you dont need to scale it at all, you can just store it with its original power, kill it probabilistically, and then, if it survives, just send it off. You may still want to scale it to take color into account though.

3. You definitely want to be finding the k nearest photons. If you average the photons in a single cell, but dont take neighboring cells into account, you get artifacts like the ones in your image.

One more thing, In general, simply gathering photons at the pixel positions like you're doing will not give very pretty results (you'll get a lot of noise in the illumination because there aren't enough photons to properly sample the incoming energy). To get that to look smooth, you'll end up needing a ridiculously large number of photons.

Final gathering, with a high enough sample count, is much more effective at producing smooth indirect illumination while still using sensible numbers of photons.
Joshua Barczak3D Application Research GroupAMD
Quote:Original post by jbarcz1
Final gathering, with a high enough sample count, is much more effective at producing smooth indirect illumination while still using sensible numbers of photons.


Could you please elaborate a bit more on what final gathering is?

Final gathering means that instead of doing a radiance estimate at your shading point, you trace rays in the hemisphere above your shading point, and gather photons from the diffuse surfaces that those rays hit.

With final gathering, you get noisy monte-carlo-like lighting instead of the blotchy appearance that you get when you gather photons directly, but the noise is reduced as you increase the number of sample rays, and it will eventually converge to the nice smooth result that you want.

One important tidbit that I've found is that it's important to super-sample your pixels when doing final gathering. So, instead of shooting one eye ray and 8000 gather rays, its better to shoot, say, 8 eye rays with 1000 gather rays apiece. Shooting multiple rays per pixel helps to average down the noise.

Joshua Barczak3D Application Research GroupAMD

This topic is closed to new replies.

Advertisement