#### Archived

This topic is now archived and is closed to further replies.

# Ray tracing with triangles

This topic is 5456 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I was reading the nehe tutorial for collision, and it was using quads not triangles, anyone know where a good tutorial is for ray tracing with triangles? not quads?? thanks!

##### Share on other sites
Raytracing with triangles consists or either making a continuous surface approximation with bezier patches... or (more straightforwardly) phong shading the triangles to make a good approximation. So get to work with google... look up line or ray triangle intersection, and phong shading. Phong shading is quite straightforward, and can be simulated very well in realtime with a technique called "phong mapping," which also lends itself quite nicely to implementing bumpmapping with maps that are offsets in your phong map .

##### Share on other sites
I believe he is talking about ray-triangle intersection...

The nehe tutorial I believe only uses planes. And its not collision detection you want, its only intersection, because there are no moving objects involved when rendering a frame in a raytracer.

When it comes to polygon intersection, the technique is usually generic:

1. Intersect the plane the polygon lies on
2. If the plane is intersected, determine if the intersection point is inside the polygon by checking if the point is facing all of the polygon''s bounding planes (as many bounding planes as the number of sides, in the case of a triangle, this would be 3 :D).

Bounding planes are planes that are perpendicular to the polygon plane, they sort of form a 3D prism around the polygon. Of course this method only works with convex polygons, but triangles are always convex.

Looking for a serious game project?
www.xgameproject.com

##### Share on other sites
there is a faster way to do the 2nd part of ray-triangle intersection.

1. same as above

2. a) Project triangle and intersection point onto triangle''s
primary 2 axes (find largest component of triangle''s normal
and use other 2 axes). This is easy. It just means throw away one of x,y,z corresponding to largest normal component.

b) check if 2D intersection point is inside 2D projected triangle. This is just a matter of checking which side of each line the point is on. Point/Line (2d) is faster than Point/Plane (3d).

##### Share on other sites
google for fast ray triangle intersection

at normal days, the first hit is a quite fast piece of code.

If that''s not the help you''re after then you''re going to have to explain the problem better than what you have. - joanusdmentia

davepermen.net

##### Share on other sites
http://www.acm.org/jgt/papers/MollerTrumbore97/code.html

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
13

• 14
• 10
• 23
• 9
• 49
• ### Forum Statistics

• Total Topics
632638
• Total Posts
3007584
• ### Who's Online (See full list)

There are no registered users currently online

×