If I figure out my code correctly, in the case with direct lighting, when a ray hit the light source, I always reflect the ray i.e. never terminate the ray when the recursion depth is 1; when the recursion depth is 1, the ray should have been treated as a ray in direct lighting. This corresponds to (isDirectLighting == true && depth != 1) in line 362 for importance sampling and in line 487 for uniform sampling. Hope my code will solve your question.
Thank you for your comment. Since I implemented this long time ago, I forget the detail of my implementation. But as long as I see my code, what you pointed out seems to be true. There is the corresponding source code here.
nice work man. but how do you handle with a ray hitting the light source when direct illumination is calculated? cause if i just terminate the ray, i'm not able to get any caustics
If I figure out my code correctly, in the case with direct lighting, when a ray hit the light source, I always reflect the ray i.e. never terminate the ray when the recursion depth is 1; when the recursion depth is 1, the ray should have been treated as a ray in direct lighting. This corresponds to (isDirectLighting == true && depth != 1) in line 362 for importance sampling and in line 487 for uniform sampling. Hope my code will solve your question.
yiusay 11 months ago
Thank you for your comment. Since I implemented this long time ago, I forget the detail of my implementation. But as long as I see my code, what you pointed out seems to be true. There is the corresponding source code here.
me.berkeley.edu/~yasui/CS283/hw2/
yiusay 11 months ago