   What do you want to BATCH today? (materials & vertices)
  Hi there,I''ve got a few questions concerning vertex batching for a dynamic VB.1) Is it possible to "over-batch"?==================================My current approach is to sort vertices according to their material. This is where my first question arises: What is a good material? Would you define materials with the same properties that only (!) differ in texture as seperate ones? (I mean, most of the renderstates would remain the same.. except for the texture that is..) Or would you classify it as some kind of a materialgroup?2) Let a material system take control?======================================Is it advisable to create a material system with an array of available materials that own pointer lists to vertex arrays, letting the system run through that array, setting renderstates according to the material and rendering the indicated vertices?If anyone has any experience with this, please let me know, I''d really appreciate it.    Nescis mi fili, quantilla prudentis mundus regatur 
  1)  Texture state switching is one of the more expensive state changes, next to FVF/shader switching (and maybe a few others).  So I''d consider it a separate group, even if other material properties stay the same.2)  What you''re describing is sort of like a factory approach, which some games use.  It''s one I''ll be testing out shortly.  The idea being that the material system will know best how to sort by minimal state changes, and the game will go through its gamestate and add buffers to the material factory, which at the end will begin drawing in best order while the game continues processing the next frame.  I like it, but don''t know if it''s the absolute optimal approach.   I like pie. ;  Thanks for your reply, RenderTarget.I guess that I''ll batch according to both material properties and texture then - though I''m still a bit afraid that this might cause more RenderPrimitive calls than it will save state change overhead (for ''rare'' materials) .. we''ll see As for the material factory pattern, the major inconvenience would be to grant the material system access to vital model data (such as position and vertices/indices).. but it might be worth it. Has anyone already implemented such a pattern? I''d love to hear of your experiences.So long,Jens    Nescis mi fili, quantilla prudentis mundus regatur 