Adaptive Binary Tree

December 28th, 2009 by

Ok, I did some testing with an Adaptive Binary Tree in my application. I wanted to test if our current not fully optimized octree implementation (but still very very fast) is able to keep up with a ABT. I used the article in Game Programming gems 5 as my main resource. I am not going to explain what an ABT is because you can find that by googling. I must note that we are currently only using these structures for static geometry. An ABT is especially useful for dynamic objects but I think a loose octree also has potential. For now however I limit myself to static geometry only.

I am currently constructing the ABT in maya using the all vertices approach. This approach will result in best ABT but it also is a very slow method. However for the sake of testing whether an ABT is usefull for our application I decided to use this method. After a couple of hours I was able to render the adaptive binary tree with the same result as the octree implementation. I did not implement all the stuff the octree can do but it was enough for testing purposes.

I benchmarked the application and compared the result with the octree implementation. Traversal of the ABT was significantly faster than the octree implementation because there are fewer nodes. I compiled the ABT this way on purpose. Rendering however was much slower even though the rendering code of the ABT is much simpler. I noticed that the ABT draws a lot of triangles that are not visible. This was pretty obvious, the ABT has fewer nodes so the nodes must contain more geometry. But when I increased the number of nodes of the ABT the traversal time increased.

After a lot of testing I concluded that the ABT implementation is in fact slower than the octree implementation. I think it has to do with the fact that our levels do not contain a lot of geometry. At the current time our engine simply does not require an ABT.

So I think I will go and combat the fragmentation of octree nodes now to see if I can maybe squeeze frametime there. :)

Octree – Cont’d

December 12th, 2009 by

After a day of staring at the octree rendering and export code I found two tiny little bugs that caused strange errors. One of the bugs I found was that when I did something like this

Vector3 a(reader->ReadSingle(), reader->ReadSingle(), reader->ReadSingle())

The components of the vector where read in a different order! I find it very strange that the arguments of the method are executed in a different order then specified. I solved the problem by first storing the components and then passing them to the constructor, effectively forcing the execution of ReadSingle in the right order.

I also added the drawing of the octree nodes in maya so you can see the result.

Octree

December 7th, 2009 by

I have partially created an octree implementation. It is now possible to write and convert a scene in maya into an octree. This file is then read by the engine and rendered. It works well except for a few things:

  • Performance drops to about 160 FPS with 80000 polygons. (It was 3000 before)
  • The export seems to have incorrect face winding with mirrored objects. (See the ceiling of the screenshot below)
  • I did not totally implement the octree so there is always one static light and one material.
  • Culling is not implemented. (But also not required for the scene below)

I will work on the implementation this week.