Skip to content
Möller-Trumbore Ray-Triangle
step 1/5

Reading — step 1 of 5

Read

~2 min readRay Tracing

Möller-Trumbore Ray-Triangle Intersection

The textbook ray-plane-then-test approach works but does two passes. Möller-Trumbore (1997) is the fastest known general ray-triangle intersection — it computes (t, u, v) directly using the geometric meaning of barycentric coordinates, with one cross, one dot, and a couple of conditional rejects.

Ray:       P(t) = O + t*D
Triangle:  V0, V1, V2

E1 = V1 - V0
E2 = V2 - V0
P  = D x E2
det = E1 . P
if |det| < epsilon: return MISS         // ray is parallel to triangle plane

inv_det = 1 / det
T  = O - V0
u  = (T . P) * inv_det
if u < 0 or u > 1: return MISS

Q  = T x E1
v  = (D . Q) * inv_det
if v < 0 or u + v > 1: return MISS

t  = (E2 . Q) * inv_det
if t < 0: return MISS                    // intersection behind the origin

return (t, u, v)                         // u, v are barycentric of the hit point on the triangle

Why it's fast: no need to compute the triangle's normal up front; the cross/dot algebra falls out of Cramer's rule on the parametric linear system. The early rejects (|det| < eps, u out of range, v out of range, t < 0) kill the common case before any further work.

Backface culling (optional): if you reject det < eps instead of |det| < eps, you only hit front-facing triangles — useful for opaque single-sided meshes.

Watertight variants exist (Woop, Benthin, Wald 2013) for numerically safe BVH traversal where neighboring triangles must not produce double-hits or missing hits at shared edges.

This routine plus a BVH is the engine of modern offline rendering: PBRT, Mitsuba, Embree, Cycles, OptiX all dispatch billions of Möller-Trumbore intersections per frame.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…