-
Notifications
You must be signed in to change notification settings - Fork 65
Ray Triangle Intersection
Given a triangle defined by points p0, p1 and p2 and a ray given by its origin o and direction d, the barycentrics of the hit point as well as the t-value of the hit can be obtained by solving the system:
Where:
This system can be solved by Cramer's Rule, yielding:
In the above, |a b c| denotes the determinant of the 3x3 with column vectors a,b, c.
Note that since the determinant is given by: , you can rewrite the above as:
Of which you should notice a few common subexpressions that, if exploited in an implementation, make computation of t, u, and v substantially more efficient.
A few final notes and thoughts:
If the denominator dot((e1 x d), e2) is zero, what does that mean about the relationship of the ray and the triangle? Can a triangle with this area be hit by a ray?
Given u and v, how do you know if the ray hits the triangle?
Don't forget that the intersection point on the ray should be within the ray's min_t
and max_t
bounds.
- Task 1: Camera Rays
- Task 2: Intersecting Primitives
- Task 3: BVH
- Task 4: Shadow Rays
- Task 5: Path Tracing
- Task 6: Materials
- Task 7: Environment Light
Notes:
- Task 1: Spline Interpolation
- Task 2: Skeleton Kinematics
- Task 3: Linear Blend Skinning
- Task 4: Physical Simulation
Notes: