A little modify about sphere sample.

5 views
Skip to first unread message

tomwindcloud

unread,
Nov 18, 2009, 12:23:36 PM11/18/09
to pbrt
Hello,

In pbrt book p707, the code is:

if (!Intersect(ray, &thit, &dgSphere))
ps = Pcenter - radius * wc;
else
ps = ray(thit);

I think it can be more better like this:

if (!Intersect(ray, &thit, &dgSphere))
{
thit = Dot((Pcenter - p), Normalize(ray.d));
}

ps = ray(thit);

In pbrt book p706, it wrote:
"Note that we must be careful about precision errors here. If the
generated ray just grazes
the edge of the sphere, the Sphere: :Intersect() routine might
unexpectedly return
f al se. In this case, the implementation arbitrarily chooses to
return the point on the line
between the shading point and the sphere center. This very slightly
biases the sampling
routine, although the error introduced by this bias is extremely
small."

Now, the precision error is removed. I'm right?


Matt Pharr

unread,
Nov 30, 2009, 5:56:54 PM11/30/09
to pb...@googlegroups.com
Nice fix, thanks! That is just in time to be fixed in the second edition of the book.

Thanks,
-matt
> --
>
> You received this message because you are subscribed to the Google Groups "pbrt" group.
> To post to this group, send email to pb...@googlegroups.com.
> To unsubscribe from this group, send email to pbrt+uns...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pbrt?hl=.
>
>

Reply all
Reply to author
Forward
0 new messages