-
Notifications
You must be signed in to change notification settings - Fork 910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Importance sampling #74
Comments
Thst is a good point! Good catch thank you.
Not many people have made it that far— I’d enjoy seeing your pictures.
Pete
…On Fri, Oct 19, 2018 at 7:55 AM Adrian Roman ***@***.***> wrote:
Hi,
Thank you for the books, they were very helpful! I signalled an issue on
the blog, but you might not visit it often, so I'll put it here, too.
I implemented a ray tracer with help from your books and blog. I think I
found an issue with the importance sampling. I'll try to describe it here
in words.
The idea is that there is a list of objects that are 'important' (like the
light in your book). Now, the same object also exists in the scene. It
might happen that both the origin point and the generated target point to
be on the same object, which for a rectangle for example means along the
surface. But the pdf value for such a vector is zero, which means a
division by zero. In my code I just checked for such a case and tried
sampling again if that was the case, in a loop until success.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://github.com/petershirley/raytracingtherestofyourlife/issues/6>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACq6ipEeywl9Jdf6MXNWB7NiG7xBg57Sks5umdmygaJpZM4XwaB_>
.
|
I'll let you know when I'll put the code on GitHub. I still have some things to implement, right now I'm up to loading models from obj files, but no colours or textures yet are applied (from the obj file, of course I can set colours and so on on the composite object by coding). Here is one of the images I uploaded on facebook, it's the typical 'monkey' made transparent in a Cornell box: https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2FComputePhysics%2Fphotos%2Fa.583365435413199%2F583608115388931%2F%3Ftype%3D3 |
while not always it will be exactly zero, sometimes it may be some very small number, weighting sample up to thoundes of times more than any other, for me its usually means that there will be lots of overly bright pixels, and I could only get clear images once clamped Upd: found unrelated issue in my code that was leading to lots of bright spots. |
Depends on how you implemented it, I guess. I don't recall exactly the details, but for the case when the both the origin and the target were on the same rectangle, the Hit call probably in my case returned false and in consequence the pdfValue call returned 0. I think there might exist some issues even if you have the Hit test return true for such a case (but why? it's a ray that's parallel to the surface, it should not 'hit' the surface), because then you have the scalar product between a vector that is parallel with the surface and the normal to the surface (to get the cosine). That one will be zero and as such, you get a division by zero, this time in the pdfValue. See from line 64 in my code, here: https://github.com/aromanro/RayTracer/blob/master/RayTracer/Scene.h |
@pavlus Can you add any details about your "Upd: found unrelated issue in my code that was leading to lots of bright spots.", I'm having a similar problem bright pixels and non-convergence, and hope that your fix might help me too. |
Hi,
Thank you for the books, they were very helpful! I signalled an issue on the blog, but you might not visit it often, so I'll put it here, too.
I implemented a ray tracer with help from your books and blog. I think I found an issue with the importance sampling. I'll try to describe it here in words.
The idea is that there is a list of objects that are 'important' (like the light in your book). Now, the same object also exists in the scene. It might happen that both the origin point and the generated target point to be on the same object, which for a rectangle for example means along the surface. But the pdf value for such a vector is zero, which means a division by zero. In my code I just checked for such a case and tried sampling again if that was the case, in a loop until success.
The text was updated successfully, but these errors were encountered: