How do I render an obj mesh in my Raytracer?

  • First, you need to parse an OBJ file to obtain the triangles, fortunately it's super simple and you can write your own in like 10-20 minutes.

  • You can get some obj files here: https://github.com/alecjacobson/common-3d-test-models/blob/master/data/xyzrgb_dragon.obj

  • Those obj files need to be edited a bit, since some of them are scaled small, some are too big. You can use Maya.

  • Each triangle is a Hittable, so a triangle mesh is a HittableList

  • The biggest problem is the performance, you will have so many triangles can't you need to implement BVH, so you need to implement one described in RayTracing The Next Week

  • After you implement the BVH, your raytracer will be still slow, so implement a multithread raytracing, this part is probably quite tricky to implement but there are many examples available using std::thread or std::future/std::async.

Good luck!

/r/GraphicsProgramming Thread