# ray tracing/octree

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

## Recommended Posts

Hi, I am implementing an octree acceleration structure for my triangle based ray-tracer. I use the algorithm described in "Advanced Animation and Rendering Techniques" by Alan and Mark Watt. Background: Basically, for a ray, I find which leaf voxel the ray origin is in. Then I test the ray against all triangles in that voxel. If no intersection occurs inside the voxel, then I move the ray position such that it now barely lies in the next voxel in the ray's path. This continues until an intersection happens or the ray exits the root voxel volume. Problem: The ray position lies on the boundary face of two voxels (see http://img218.imageshack.us/img218/4563/octreevb5.jpg). Thus when I do the query to see which voxel the ray position lies in, only one of the two voxels is returned, namely Q3 in the figure. This is a problem if the ray aims inside the other voxel, as the RayAABB(ray, Q3) test will turn up empty, thus causing my code to think the ray has exited the voxel space of the root. You might say that the ray intersects Q3 at t = 0. But I made my ray intersection code to only look for intersections in [t_min, t_max] to avoid self intersections and such. So the t = 0 intersection won't be caught. Any nice ways to handle this situation?

##### Share on other sites
Quote:
 Original post by QuatHi,I am implementing an octree acceleration structure for my trianglebased ray-tracer. I use the algorithm described in "Advanced Animationand Rendering Techniques" by Alan and Mark Watt.Background: Basically, for a ray, I find which leaf voxel the rayorigin is in. Then I test the ray against all triangles in that voxel. If no intersection occurs inside the voxel, then I move the rayposition such that it now barely lies in the next voxel in the ray'spath. This continues until an intersection happens or the ray exitsthe root voxel volume.Problem: The ray position lies on the boundary face of two voxels (seehttp://img218.imageshack.us/img218/4563/octreevb5.jpg). Thus when I dothe query to see which voxel the ray position lies in, only one of thetwo voxels is returned, namely Q3 in the figure. This is a problem ifthe ray aims inside the other voxel, as the RayAABB(ray, Q3) test willturn up empty, thus causing my code to think the ray has exited thevoxel space of the root.
I dont really understand why this happens, 'cause after your code assumes it does not hit anythin int Q3 it should
Quote:
 If no intersection occurs inside the voxel, then I move the rayposition such that it now barely lies in the next voxel in the ray'spath.
so the next query should lie in Q4 and everything should workout. Am I missing somethin?

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 29
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631740
• Total Posts
3001964
×