I recently found this website and wrapped up the obj reader I found there for use in my raytracer. In order for this to work, I had to re-implement (or at least refactor) my bounding volume hierarchy code and get it working in my new raytracer. Once I did that, I verified that it still provided the speedup I had seen before by testing it on a sphereflake. It still worked. So then I implemented another subclass of my GeometricObject type and used my BVH class inside of it to efficiently hit the many triangles that make up the model.
The image below depicts a model with roughly 16,000 triangles and facet normals.
Here it is up close, again with 16,000 triangles, facet normals, and 1 ray per pixel. The image below took about 2 or 3 seconds to render.
Ok, now I'm rendering the "smooth mesh" model with more like 64,000 triangles, still using facet normals, and 1 ray per pixel. This image took more like 5 seconds to render.
Finally, below you can see the model with 64,000 triangles, facet normals, and 25 rays per pixel. This took about 2.5 minutes to render, and almost 15 million rays were generated.
Below is my glass version of the model, with 64,000 triangles, facet normals, and 25 rays per pixel. It took my raytracer over 9 minutes to render the image. I'm kind of disappointed with the results, I'm not sure where all the black lines and patches are coming from.
The soccer ball model looked a little better as glass, but not much.
I think if I use the vertex normals provided by Nate Robins' excellent sample code, then maybe even interpolate those across each triangle using barycentric coordinates, some of the mess might get cleaned up.
Still, it's kind of cool to be able to raytrace obj files now, and it's pretty neat to see them as glass, or at least a little like glass.
No comments:
Post a Comment