Efficient way to render an octree
I'm coding a 3D engine based on octree.
For now, to render an octree, I just traverse each node, I determine whether it's visible or not, and then, I draw it. But this is not very efficient.
So, I thought to store a vertex buffer in the root node, for each texture, which contains all the vertices of the same texture. In my node, I just store vertex indices. To render it, when a node is visible, I 'memcpy' vertex indices of the node into a larger 'index buffer'. Once all the nodes have been traversed, I render the octree using the new index buffer, for each texture (calling glDrawElements).
But this is not yet very efficient :(
It is because I use memcpy? or because, when I call glDrawElements, there are vertices in the vertex buffer which don't need to be here (invisible vertices)?
How do you render efficiently your octrees?
One method is to use a render queue. When you find a visible node, add it to a list of things to render. The render queue is then sorted, based on shader/render states and so forth, and flushed. I've found it to be quite an efficient method...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement