Jump to content
  • Advertisement
Sign in to follow this  
Stanza

Ray-Box Intersection, Williams vs Pharr

This topic is 4323 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was putting together an octree for raycasting, with a ray-box intersection test to determine which octree children needed testing. The problem I kept running into was that rays were often failing intersection tests with the AABB. My initial implementation used Williams's approach, exactly as described in http://cag.csail.mit.edu/~amy/papers/box-jgt.pdf After not finding any problems anywhere else in my code, I replaced that with the implementation described in Pharr/Humphrey's "Physically Based Rendering", and now everything works fine. Is there some gotcha or problem with Williams's approach? Does it require specific modes to be set for the FPU? Is there an assumption that rays are always being cast in a certain direction (one of x, y, or z always positive)? For that matter, is the direction vector supposed to be normalized? (I assume that one, but the doc doesn't mention it.) And for anyone who's gotten both approaches to work, is Williams's approach faster? It looks like it could, since it appears to have fewer conditionals.

Share this post


Link to post
Share on other sites
Advertisement
The main gotcha imho is the 'divide by zero' cases. You need to detect those, and deal with them appropriately. I haven't read the article, but maybe it's not handling those correctly.

I use a sort of similar algo, more based along the dimension reduction (3 1D tests).

In any case, there isn't 1,000 ways to do ray-AABBox intersections, they all do kinda the same thing, split the test along the three axes, and reduce it to 1D interval intersection. The only thing left really is the implementation and dealing with borderline cases.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!