I have a tree model with multiple instances of the same geometry for the leaves. I have implemented hardware instancing to generate all my leaves in a single call, but I now want to multiply this by creating multiple trees in that same call.
Since VertexBufferBinding takes an array I thought I could do this;
// Set up the model instance buffer
VertexBuffer modelInstanceVertexBuffer = new VertexBuffer(graphicsDevice, SurfaceFeatureModelInstanceVertex.VertexDeclaration, modelInstanceToRender.Count, BufferUsage.None);
modelInstanceVertexBuffer.SetData(modelInstanceToRender.ToArray(), 0, modelInstanceToRender.Count);
// And the world instance buffer
VertexBuffer worldInstanceVertexBuffer = new VertexBuffer(graphicsDevice, SurfaceFeatureWorldInstanceVertex.VertexDeclaration, worldInstanceToRender.Count, BufferUsage.None);
worldInstanceVertexBuffer.SetData(worldInstanceToRender.ToArray(), 0, worldInstanceToRender.Count);
VertexBufferBinding bindings = new VertexBufferBinding;
bindings = new VertexBufferBinding(renderInstance.SurfaceGeometry.VertexBuffer,0,0);
bindings = new VertexBufferBinding(modelInstanceVertexBuffer, 0, 1);
bindings = new VertexBufferBinding(worldInstanceVertexBuffer, 0, 1);
However I'm not getting the results I expect (i.e. nothing is getting rendered to my viewpoint). There aren't any examples that I could find of multiple VertexBufferBinding being used to generate multiplier effects like this. I am suspecting that "it just doesn't work that way" and instancing can only be used once per call rather than combining and multiplying like I am trying to do. Could it be as simple as me not understanding the meaning of the instanceFrequency parameter ? for instance, would it be correct to say modelInstanceVertexBuffer has a count of 414 (leaves) and worldInstanceBuffer has a count of 400 (trees) so the instanceFrequency for modelInstanceVertexBuffer is "1" (i.e. render one SurfaceGeometry for each item in the modelInstanceVertexBuffer), but when it comes to the 400 worldInstanceVertexBuffer I would pass 414*400 as the instanceFrequency (this doesn't make sense to me).
Can any one help ?