Problems with Photon Mapping Implementation

I am currently working on a simple raytracer and so far I have successfully implemented several features such as anti-aliasing, depth of field and soft shadows with area highlights. An image representing my work could be as follows:


(no AA here)

The next step was to add reality to the rendering with some kind of global lighting algorithm, so I decided to go for the photon display method that seemed the easiest.

For this, I read several articles I found on the internet, for example: http://graphics.stanford.edu/courses/cs348b-01/course8.pdf
which is well written.

Now my program can shoot photons in the scene and store them after the first bounce (diffuse or specular), and then scale the power of each individual photon to LIGHT_POWER / PHOTON_AMOUNT. A direct visualization of this is presented in these images, where I shot 1000k and 50k photons, each bouncing 6 times, for a total of 5000k and 250k photons on the global map:

I thought the effect was right, so I moved on to the next part, the one where photons in a certain radius above the intersection of the ray beams are used to compute indirect lighting.

In my raytracer, I do the following:

  • for each pixel, I send a ray through it to traverse the scene and calculate the forward illumination (dot(N, L) * primitive.color * primitive.diffuseFactor * light.power)

    and specular term;

  • Here's the tricky part: I'm looking for the closest photons that lie on a disk with a fixed radius around the intersection point and sum up the light that each creates in this way:

    for each photon in the radius, calculate the light in the same way as for direct illumination (point (-photonDir, N) * primitive.color * photonColor) and sum everything.

  • Once each interesting photon has been processed and added to its final color, I divide it by an area on the disk that defines the search area.

The problem is that I am not getting the desired result, in particular the ceiling is very dark compared to the images I have found on the internet (I cannot figure out how the ceiling can be as bright as the floor if the latter has additional input from direct illumination and how it can be white if the photons on it are only red or green).

The image representing the problem is as follows:

This was done using 150k photons with 4 bounces each, and the direct illumination was split by PI.

Also, if you know how I can remove these ugly artifacts from the corners, please tell me.

+3


source to share


1 answer


First, thanks a lot for your help.

Secondly, I am here to announce that after some trouble and after a period of not touching the code, I finally got it.

I didn't understand what I was doing wrong, maybe an algorithm for getting a random direction in the hemisphere, maybe collecting photons ... The fact is that after reformatting the code bits (and after implementing the final stage of collecting and correcting the gamma diagram 2 2) I was able to display the following with 200k photons, 10 diffuse bounces, 20 counts for direct illumination, and 100 FG samples (taken at random - cosine weighted direction).

The final result



I am very happy with this as it looks almost the same as rendering a scene in a c4d path traced with V-Ray.

I still don't understand what the photon incident direction storage utility is, ahahahahahaha, but it works, so everything is fine.

Thanks again.

+4


source







All Articles