OpenCL - ray-triangle intersection

Practical and theoretical implementation discussion.
Post Reply
Posts: 2
Joined: Sat Feb 01, 2014 12:14 pm

OpenCL - ray-triangle intersection

Post by martijnhh » Sun Feb 02, 2014 11:36 am

Hi there,

I've started work on a small 2d physics engine using OpenCL, where the bulk of work is in continuous collision detection between moving line segments. I have implemented this by testing the vertices of line segments for intersection with the line segments of potentially colliding objects. The technique i use is based on representing the points as 3d line segments (movement in time), and the line segments as 3d quadratics (movement in time). The problem is then to find the point of intersection between a ray and a quadratic in the interval [0..1]. To simplify this i split the quadratic into two triangles and test the ray with both triangles.

Since bruteforce doesnt scale, I implemented a broadphase to cull the potential colliding objects (much like a Kd tree, actually im using an uniform grid). This helped a lot, but still after profiling the ray/triangle intersection takes up a significant amount of time.

I googled for some references on how to speed up the ray-triangle test and there are plenty of techniques to be found:
-Sven woop
-Projection tests

But im not sure what the most efficient is for a gpu architecture. There are some papers comparing technqiues, but most of them seem to be outdated and are available when you have a subscription to the journal only.

Since this problem is so essential for raytracing, and you guys have done a lot of research & work on this problem, i was wondering if someone can point me to the current state of art for implementing this as efficiently as possible on a (current) gpu architecture.

Any help is greatly appreciated!


Posts: 167
Joined: Mon Nov 28, 2011 7:28 pm

Re: OpenCL - ray-triangle intersection

Post by graphicsMan » Wed Feb 05, 2014 8:32 pm

I found "Ray-Triangle Intersection Algorithm for Modern CPU Architectures" to provide a really fast, and fairly robust ray triangle intersection. I found that MT is more robust and requires less storage, but Shevtsov's intersection test was faster for me (especially on GPU). Warning: I did this evaluation more than 5 years ago :)

Posts: 382
Joined: Wed Nov 30, 2011 2:27 pm

Re: OpenCL - ray-triangle intersection

Post by spectral » Wed Feb 05, 2014 11:02 pm

There are several factors in this problem
1) the accuracy : do you need very accurate test or not ?
2) the memory usage : is it important for you ?
3) the speed : is it so important

In this problem you have to find the exact match for you.

By example you can use the ward method, it seems to me very general one.
You can use the sven woop for fast one.
And the pluecker version for accuracy.

So, if you just start maybe start woop version... And if needed you can switch to another method.

Hope it helps

Posts: 2
Joined: Sat Feb 01, 2014 12:14 pm

Re: OpenCL - ray-triangle intersection

Post by martijnhh » Tue Feb 18, 2014 9:30 am

@spectral, you're right spectral about matching the method with the specific goals, for now it remains speed, but the nice thing about this approach is that I can always swap the method and gain accuracy for example.

@graphicsman: I did some more digging and found a more recent analysis for current state gpu's:

Funny thing is that plain Moller-Trumbore ray triangle checks seem to perform best on current state gpu's.

Thanks again!


Posts: 22
Joined: Tue Apr 03, 2012 1:42 pm

Re: OpenCL - ray-triangle intersection

Post by toshiya » Tue Feb 18, 2014 10:37 am

I've also found that the Moller-Trumbore test is the fastest on GPUs. The Woop test (or perhaps a slight variation) is the fastest for me on CPUs, but because of the additional storage-related cost, it is slightly slower than the Moller-Trumbore test on GPUs in my experiments. Plucker is definitely slower albeit the most robust one. Projection test is probably not good anymore today, though it could have been the fastest without SIMD. I however think that you should see very minor differences in performance once you improved your acceleration data structure. I might be very wrong, but my two cents.

Posts: 29
Joined: Sat Aug 17, 2013 8:46 pm

Re: OpenCL - ray-triangle intersection

Post by ziu » Tue Mar 11, 2014 6:14 pm

I use the Möller-Trumbore algorithm too. There are faster algorithms for computing if there is an intersection but most of the time you will want to compute the intersection point. There are other algorithms which cache values and require less mathematical operations to compute an intersection but they use more memory, when GPUs have limited amount of DRAM and no virtual memory, plus you get more cache trashing with those algortihms.

So Möller-Trumbore it is.

Post Reply