4

I'm raytracing and would like to speed it up via some acceleration structure (kd-tree, BVH, whatever). I don't want to code it up myself. What I've tried so far:

  • Yanking the kd-tree out of pbrt. There are so many intra-dependencies that I couldn't succeed at this without pulling all of pbrt into my code.

  • CGAL's AABB tree. Frustratingly, this seems to return only the point of intersection. Without knowing which triangle the point came from, I can't efficiently interpolate color over the triangle. I'd love to just extend the notion of "Point" with color, but this doesn't seem possible without writing a lot of template code from scratch.

  • Writing my own. Okay so I wrote my own grid acceleration class, and it works, but it's nasty and inefficient.

So, if anyone can suggest a simple library that I can use for this purpose I'd really appreciate it! All I need is given a triangle soup and ray, find the closest intersection and return the index of that triangle.

Meekohi
  • 10,390
  • 6
  • 49
  • 58

2 Answers2

2

Jaco Bikker wrote this series of tutorials: http://www.devmaster.net/articles/raytracing_series/part7.php

They're very helpful and he includes code at the end for a ray tracer using a kd-tree.

You might be able to use that.

fluffels
  • 4,051
  • 7
  • 35
  • 53
  • 2
    Well I ended up writing my own from scratch but this looks like a good reference. Thanks! – Meekohi Aug 14 '10 at 09:29
  • 1
    For interests sake: did you implement a k-d tree? What were your results? – fluffels Aug 14 '10 at 10:00
  • 2
    Nope, it's more like a 'slightly smarter' grid that leaves out some code because I always start inside the grid for my application. It gave a 20x speedup or so compared to brute-force in the best case, but is very sensitive to the size of the grid cells. – Meekohi Aug 17 '10 at 13:16
  • 1
    That is generally a problem with the grid-based approaches. Well done, though! – fluffels Aug 18 '10 at 00:51
1

The G3D engine has a ray tracing implementation. Not sure how efficient it is though. It shouldn't bee too much trouble to use the Tree implementation without the rest of the library.

namespace sid
  • 1,816
  • 1
  • 11
  • 5