Efficient way to render an octree

Started by
0 comments, last by python_regious 19 years, 8 months ago
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?
Advertisement
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...
If at first you don't succeed, redefine success.

This topic is closed to new replies.

Advertisement