I've taken a break from The Dark Room in the last week or so, to refresh myself on the Hyperion render engine project. I've decided to tackle a couple of things with this engine to see if I can bring it up to speed. Literally.
My engine started as a simple ray caster. They all do don't they? Everything starts by rendering with brute force. After a while, I built my own caching structure, which I talked about previously here. On longer renders with many passes, it's faster. But it's slow to build. So I removed this structure and attempted to build a second one instead. I don't know what it's equivalent to. A K-D Tree? R-Tree? BVH? A combination of them probably.
It took quite some time to add in the structure to the code. Once you start building code and it gets fairly busy, it can be tricky to add in a new data object that needs a lot of attention in places. So it took a while to get something working. But alas, where here, so lets take a look.
The render engine now has a new acceleration structure. And it has sped up rendering quite a bit. I managed to get it faster by a factor of 13.9x. Let's start with a benchmark render.
The image above is a one pass render of the Stanford Dragon, with a white light pole through it (not shown very well in this image). This version of the dragon has around 47,768 polygons, so it's a good object to test with. A single pass with no acceleration structure took 13 minutes and 44.3 seconds. I believe the depth was 15, not 5, but it won't have made much difference in this case.
Now, here's a one-pass render with the acceleration structure in place:
As we can see, the renders are virtually the same. Apart from colour, which doesn't affect the render times itself. The render with the acceleration structure took 59.3 seconds to complete. That's a significant drop in render time.
I decided to let one render go for a while. Here's what a 150 pass render:
Conclusion
There's not doubt the acceleration structure has improved the performance of the engine. It's significantly faster to render. With a bit of tweaking, it may be possible to get the one-pass time down even further. It's worth trying to squeeze as much as you can out of it, because over long renders small improvements can add up to larger time drops.
I have an idea that I may be able to use the original cache design, in tandem with the new acceleration structure. It might make a difference on longer renders with many more passes, which is what the original cache design was for.
I don't think I could use these systems in a real-time environment. But I'm not worried about that. I really want this for offline rendering, which is the sole purpose of Hyperion.
Update
I've managed to improve the render times even further with some additional functions that help make the acceleration structure, and the rendering of the structure, more efficient. I was going to post some results here, but it really needs it's own separate post. We'll talk about this more in the next post.