I am working my way through my first path tracer and I am currently designing how to deal with area lights. I have two questions:
Each object in my scene can have a Light attached to it, this is how I represent Area Lights. Given this I have two questions:
1) Shadow ray: When doing shadows, if I use a blind
IsOccluded function that I use successfully for point lights, I will obviously have always an "occluded" result, as the light vector by construction ends up at the light source itself which is an object in my scene and therefore will be hit by the shadow ray.
To rephrase, how do I deal nicely with the light being an object in my scene when casting the shadow ray for that light?
I would like to keep my
IsOccluded function simple, returning only a boolean and not a position/interaction record. At first glance PBRT manages to do so, but I don't understand how they get around the problem. Am I forced to use a different scene intersection function? If so, what is the most graceful way to solve the problem?
2) Secondary rays: If I have more than one bounce, I often see this black dots appearing (even if I disable shadows). I know this is hard without more context, but I wonder if someone has encountered something like this or can guess:
With multiple bounces
With only first hit
I thought it could be related to the way I sample the sphere, but if that was the case, shouldn't I get black dots even with only one event? I think these are NaNs, will double check, but if you know common scenarios when this happens it'd be appreciated. I am guessing I am trying to lit the light with the light itself, causing a NaN that gets then propagated. Does it make sense? I am more interested to understand the cause than how to fix this.
3) Bright pixels: Somewhat unrelated? (I can open separate question), but I get lots of unnaturally bright pixels all over the place if I have more than 2 bounces. What is the cause of this? How do I fix this?
Also, do you have any suggestion on how to handle area light sources that I am clearly missing here?
Thank you and sorry for the probably confused question, I am happy to edit it if you have suggestions.