Restart
With the knowledge gained from implementing a simple path tracer, surfing the internet and watching lectures about global illumination on YouTube (http://www.youtube.com/playlist?list=PLslgisHe5tBPckSYyKoU3jEA4bqiFmNBJ), I decided to start over with an empty project and set up a clean code structure.
Current state
- Working indirect illumination. Taking things, such as the BRDF of the material and probability of sampling a given ray, into account
- Cosine-weighted sampling for diffuse materials
- Anti-aliasing
This means that I'm pretty much just as far as I was before, but now with cosine-weighted sampling.
Direct lighting
I'm currently trying to implement a direct lighting approach. At every ray-object intersection point p, I sample a random point on each of the lights and calculate their contribution to the lighting of point p. Given that I have not implemented any kind of fall-off of a light's intensity over distance, an image generated with just direct lighting appears far too bright. As such, the combination of direct and indirect lighting at every intersection is heavily dictated by the (incorrect) direct lighting. This can clearly be seen in the gallery album included with this post. Or, at least, I hope so. Since I've never uploaded one before.
However, I'm wondering if implementing fall-off of the light's intensity will "fix" this. Since it will make the indirect lighting image even more dark, making it contribute even less compared to the direct lighting image. But I guess we will see how it all works out.
An optimization to reduce noise might be to sample the light's shape projected onto the unit hemisphere around the normal, instead of sampling just some random point on the light's shape. Since for a point p, a large fraction of the points on, for example, a sphere are occluded by the sphere itself. This would lead to a whole lot less samples that lead to no contribution.
CUDA
After direct lighting is fixed, the next thing on the agenda is... CUDA! In the next entry, I'm hoping to show off some slick videos of how awesomely fast and interactive our path tracer will be. Stay tuned!
Congratulations on the project being accepted, working on a fun project which counts towards two courses simultaneously is pretty cool!
Yes, you will want to add falloff to the light. Since you are directly sampling the light source, you actually sampling a projected area rather than a solid angle on the unit sphere, which means you must divide by the distance squared to get the proper probability distribution. This doesn't happen during a random walk since you are sampling directions, not physical areas/points in space. And sampling uniformly over the light source's projected area definitely helps.
Looking forward to reading more