   Multipass with octree
  Hi there,My engine uses an octree for clipping and then rendering is done in 5 passes for the terrain.  Basically my question is which of the 4 methods will be quickest?1.Clip octree once   Every time a segment needs to be rendered Set texture & renderstates    Pass 1 Set texture & renderstates    Pass 2 Set texture & renderstates    Pass 3 Set texture & renderstates    Pass 4 Set texture & renderstates    Pass 52.Set textures & renderstates   Clip octree once Every time a segment needs to be rendered    Pass 1   Clip octree once Every time a segment needs to be rendered    Pass 2   Clip octree once Every time a segment needs to be rendered    Pass 3   Clip octree once Every time a segment needs to be rendered    Pass 4   Clip octree once Every time a segment needs to be rendered    Pass 53.Clear dynamic arrayClip octree once   Every time a segment needs to be rendered add index to dynamic array.Loop through array   set rs & texture pass 1   set rs & texture pass 2   set rs & texture pass 3   set rs & texture  pass 4   set rs & texture pass 5}4.Clear dynamic arrayClip octree once   Every time a segment needs to be rendered add index to dynamic array.set rs & texture  loop through array pass 1set rs & texture  loop through array pass 2set rs & texture  loop through array pass 3set rs & texture  loop through array pass 4set rs & texture  loop through array pass 5I''m gonna try them all eventually but I just wanted to know if anyone else knew before I did.Thanksmatt 
  I would go for number 4. It minimizes state changes and you also go trough the tree only once. One little thing. When using array to store the nodes dont create a new one each frame and then delete it. Just reuse the one from the last frame.   You should never let your fears become the boundaries of your dreams. ;  What do you mean by that?I was going to use the dynamic array method by using the New and the delete method to create a new one and an old one.  Is this too slow?Should I instead make an array that''s a fixed size then have another integer which stores the number of nodes to be rendered so then the loop would look like:for (i = 0; i < number of nodes to be rendered; i++){   render node (dynamic array (i) )}Thanks ;  either use an array thats always big enough or stick with stl::vector. you might also try to build on top of that and sort things by renderstate/texture, but that depends on your situation.thinking about it i might add another probably silly idea. store your objects in a spatial tree like you already do, but also build a scenegraph-like tree by renderstates/textures. your objects would be stored in an array and both trees only contain pointers to them. then use a flag to mark visible objects when you travers the octree and to render you traverse the scenegraph, drawing all objects with a visible flag. that would mean traversing two trees instead of one but would be the cheapest way to get a decent renderstate sorting (at least the cheapest i could think of right now).   [edited by - Trienco on February 9, 2004 9:15:38 AM];  I get you but with the way things work it wouldn''t work in my engine.  The RS states and textures are changed then the entire terrain is rendered with the textures using alpha textures to blend out areas which shouldn''t be textured.That''s a nice idea though.I build in method 4 and it''s speeded things up a bit.  I''ve only got a small level to test it on for some other stupid reason...Thanks again everyone. 