   Merging static buffers to improve batching
  Hi gals, I have a number of shaders with a lot of constants and textures which need to be changed for different objects. I'm trying to group the objects with the same parameters together to reduce shader/constants/texture changes. For exampl, static objects with the same material properties are merged in one vertex buffer.  But all these things do not really matter for shadowmap pass. In this pass I only need to quickly render static objects casting a shadow. So I'll have to do a lot of VB switches or just render another chunk of the same VB (changing offset + length).  So how do you handle this? Is it better to try and arrange these shadow casting objects together or just render a lot of small objects for this pass, having less batches when doing diffuse pass? I think the same question would arise for the reflection pass, but this time shader management would already be crucial, though not all the objects need to be rendered. Looks like some of the requirements are contradicting. So how do you think would it better to arrange/sort static objects to improve performance?Thanks!   
  There are basically two approaches that I have heard of - either batching everything into a single buffer, or doing a bunch of small batches.  If you already have the machinery available for batching, why not copy everything to a single dynamic vertex buffer and render from there?Also, it might make sense to run some benchmarking tests with your intended hardware and scene types.  It may turn out that you are not CPU bound at all, and could then use the small batches for simplicity without any speed penalty at all.   ;  > If you already have the machinery available for batching, I'm trying to resurrect my old engine and don't have everything working yet (hence my question). But in the old days batching by textures and render states did the trick for me. And I had separate VBs for different batches.> why not copy everything to a single dynamic vertex buffer and render from there I'm trying to use static buffers for static geom, so that they reside in the  video memory all the time. As with a single VB I still think it's prefereable to have 16bit index buffers and 1 VB for everything will hardly be enough. Plus docs state that switching VB is not too expensive.> It may turn out that you are not CPU bound at all, and could then use the small > batches for simplicity without any speed penalty at all. Sure, but I'm trying to think ahead and educing batches and increasing their size can never make it worth anyways 8)   ;  I think that's what instancing was invented for, if you render several times the same object, just placed somewhere else.http://msdn.microsoft.com/en-us/library/bb173349(VS.85).aspx;  For static geometry I use one vertex buffer per material. Every object of a specific material has a number of vertices and an index of its first vertex in this buffer.Thus, only indices reside. I set them dynamically in RAM, not using index buffers, so I can batch series of objects of the same material/matrix in one draw call, culling, sorting them etc. as I want.   ;Quote:Original post by Krypt0nI think that's what instancing was invented for, if you render several times the same object, just placed somewhere else. I was talking about arbitrary geometry sharing the same material not just cloned props scattered around the scene.Quote:Original post by KRIGSSVINThus, only indices reside. I set them dynamically in RAM, not using index buffers, so I can batch series of objects of the same material/matrix in one draw call, culling, sorting them etc. as I want.Could you please explain it in more details. Are you using separate vertices and draw them as a triangle strips? How else can you render without the indices. I'm slightly confused.   