I would like to know how to optimise things, and first thing I would like to ask about are batches. As far as I understand for folowing pseudocode:
[source lang="csharp"] foreach (Model model in modelList) { foreach (ModelMesh mesh in model.Meshes) { //shader variables here foreach (ModelMeshPart part in mesh.MeshParts) { part.Effect = effect; } effect.Techniques[0].Passes[0].Apply(); mesh.Draw(); } }[/source]
mesh.Draw() is sending single btach to gpu right? Which means when my model, for instance a car, has many parts (like, wheels, doors, side mirrors) I send a lot of batches.
My first question is if I can put those parts together in the code(I would like to open doors, rotate the wheels so I don't want to export them from 3d editting program as one mesh)? We could use single batch for doors, body, hood and other body parts because they share same material, we set values in the shader once for all of those parts and send single batch so we save a lot.
Another question I would like to ask is how I can perform instancing in XNA? And again, by sending it in single batch(like for vegetation or decals).
I have read Batch, Batch, Batch:” What Does It Really Mean?" pdf but I am still confused
Aside from batches, I have another problem with culling. It's kinda working, because when i look camera the other way the object is positioned I see that fps go up. But when I go far away from objects (so far the object is behind far clip) fps doesn't change or change very little compared to simple if(Vector3.Distance(camera,object) < farPlane) continue; which works fine. Does it also has to do with batches? (which are send, even though they are not beeing drawn?). Also does sorting front to back gives a speed boost for opaque objects?






