Re: some advice on muller trumbore code for ray-triangle intersection.



Ron Francis wrote:
if (*t>-DBL_EPSILON && *t<DBL_EPSILON )
Makes sense to me if you want to just determine if the origin is very close
to the triangle.

Right. However, the mathematical problem is of determining if there is
an intersection between a ray and a triangle and in this context the
test does not make sense.

One can parametrize a ray r with

r(t) = P + tD

where P is the origin point of the ray and D is a vector.

The domain of the function r is either [0, oo[, or ]0, oo[ depending on
if you count the origin as part of the ray or not. But clearly none of
the r(t) for negative t are part of the ray.

In my code I often need to find the nearest intersection in either direction
along a line, so negative values aren't discarded.
(I use a boolean parameter to determine if the vector direction is
relevant.)

*t<=0 is not a test for self intersection for two reasons.

The intent is not to test for self-intersection, but to catch the case
when a line corresponding to the ray intersects the triangle but the ray
does not.

Self-intersections enter the picture when one traces reflections or
refractions from a surface. If one considers the ray as not containing
its origin, then mathematically the ray should not intersect the surface
it is leaving from. However, because of roundoff this is often not the
case. This is usually solved by a hack by translating the ray an epsilon
off the surface. In my opinion the translation should not be part of the
ray-triangle intersection test, but rather done explicitly. Then the
test should be either *t <= 0 or *t < 0.

--
http://kaba.hilvi.org
.



Relevant Pages

  • Re: Fast hit-testing on a heightfield?
    ... Because it's a heightfield, I can't simply get the position of the mouse pointer transformed onto the plane as the mouse might in theory be intersecting many triangles. ... Testing all of the triangles in the heightfield would be major overkill, you should only need to test against a limited number of triangles that cross the ray under the cursor. ... You may further optimize this by testing against the heightmap first to determine areas of possible intersection, to which can avoid more costly ray vs. triangle tests in areas where there is no possible intersection. ...
    (microsoft.public.win32.programmer.directx.graphics)
  • ray tracing electromagnetic waves
    ... I'm actually trying to ray trace electromagnetic waves and the object ... intersection faster..The main objective is to calculate the total ... triangle to find the intersection point. ... multiple reflection? ...
    (comp.graphics.algorithms)
  • Re: pick closest mesh by mouse
    ... > closesthit.distance does indeed give you the distance along that ray. ... > intersection code isn't working at all. ... >>> be used to compute the distance to the initial ray of selection. ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: Mesh.IntersectSubset
    ... It will now successfully return the distance of the ray, ... intersection code I used was relative to how my culling was done. ... screen but in this case its literally the center of the viewport which you ... height variables set up when you created your directX object and scene. ...
    (microsoft.public.win32.programmer.directx.managed)
  • Re: Reflecting a ray off a line
    ... to find an intersection between a ray and a line you just solve this ... Therefor we rearrange ... there are cases in which a line and a ray don't intersect, ... then substitute t in the first equation. ...
    (comp.graphics.rendering.raytracing)