1
$\begingroup$

I'm implementing Peter Shirley's "Raytracer in a Weekend: The next week" and I'm having some trouble with rendering a scene with a light. I'm not sure if the issue is the background color or the light itself but the raytracer seems to be working fine in any scenes that have no lights.

The image rendered is supposed to be: enter image description here

but it actually turns out as: enter image description here

When I try to troubleshoot and change the background color to blue the image is: enter image description here

Hopefully someone who has implemented this raytracer before or who has intuition about raytracing has an idea why this might be happening??

$\endgroup$
  • $\begingroup$ Are you using bvh? If you are, can you try disabling it and see what you get? $\endgroup$ – lightxbulb Aug 29 at 10:54
  • $\begingroup$ @lightxbulb thanks for the reply! I was not using BVH for this example, but tried to disable it from the project anyways and it didn't make a difference in the rendered output... $\endgroup$ – Jackie Aug 29 at 14:31
  • $\begingroup$ I looked through your code, and nothing struck me as wrong at first glance, that's why I suggested testing without a bvh. Currently my only guess is that it could be an issue due to self-intersection, since the lighting seems to fail at angles that are more shallow. I would suggest trying to change: if(!scene.hit(r, 0.001, infinity, rec)) to if(!scene.hit(r, 0.01, infinity, rec)) and see if that changes anything. $\endgroup$ – lightxbulb Aug 29 at 16:03
  • $\begingroup$ @lightxbulb hmm.. this still didn't change how the render looks. But thanks for the help and direction! I will keep troubleshooting and if you think of any other ideas, let me know :) $\endgroup$ – Jackie Aug 29 at 21:42
  • $\begingroup$ I just had a quick browse through your code. In Lambertion::scatter there is a comment about attenuating light based on distance. For a raytracer this is not required as the distribution of rays themselves cause attenuation over distance. Typically albedo values get multiplied by the current paths attenuation (an exception would be importance sampling as that uses weighted samples) I didn't check the whole project source so I'm making a bit of a guess. $\endgroup$ – PaulHK Aug 31 at 7:21
0
$\begingroup$

In Lambertion::scatter there is a comment about attenuating light based on distance.

For a raytracer this is not required as the distribution of rays themselves cause attenuation over distance.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.