What is the limiting case of ray-triangle intersection?

image
Hello! I know that RT cores perform a ray-triangle intersection test to see if a triangle intersects a primitive. I launch a set of parallel rays (perpendicular to the page, represented by dots) spaced s apart, and I have a right triangle with two sides of length 2s as shown in the figure. Do the six rays enclosing the right triangle intersect, or do they not intersect the triangle? How does OptiX define this extreme case?
Any suggestions is appreciated. Please let me know if there is any relevant documentation explaining this issue. Thanks in advance.

Hi @thiltuiv,

Very interesting & good question,

The OptiX Programming Guide doesn’t really document the rules for rays that graze edges or vertices, but the DirectX specification does [1] and you can assume that OptiX follows the same convention. Raster typically has a screen-space (2d) ‘top-left rule’ that is designed to achieve watertightness, meaning that when rasterizing a connected mesh, you don’t get any spurious unfilled pixels between triangles that share edges or vertices. Since ray tracing is typically 3d and not 2d, the idea of the top-left rule has to be generalized in order to provide watertightness.

So in your example if you add another triangle, the RT cores will try to guarantee that along the shared (red) edge, a ray will not miss and will hit exactly one of the two triangles:

image

Whether or not rays hit the outer (blue) edges is going to depend on the orientation of your camera & scene, as well as how the watertightness rule is implemented, among other things, but you might expect in a very controlled test like you described that for rays aimed exactly at the boundary, half of the rays will miss and half will hit.

Let me emphasize that the RTX goal (in both OptiX and DX) is to guarantee watertightness, and the example 3d version of a top-left rule shown in the DX spec is only an example, not a definition.

If you don’t need watertightness and really do need to know which edge or vertex will result in a hit, I think the answer is that it’s implementation defined and not guaranteed, so it could theoretically change depending on which API you use, which driver, which GPU, etc. In that case it might be advisable to use a software intersector where you can implement your own form of top-left rule and control it to your own specifications.

[1] https://microsoft.github.io/DirectX-Specs/d3d/Raytracing.html#fixed-function-ray-triangle-intersection-specification


David.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.