I’m trying to understand how to best optimize assets for an engine that batch renders per material.
Basically I have two buildings that could use the same materials. They share the same floor, roof, walls, and trim materials, but I want to add a unique AO texture to each building. Which means I have to split my materials off into two separate materials. Each material is almost identical save the introduction of the unique AO texture, but they are two separate materials none the less.
My question is how does this affect performance in most game engines, or is this something too specific to generalize? Am I creating two separate batch passes by creating two separate materials, or is that not how it works?
EricChadwhick helped me answer this question:
"If the meshes use the same material, they can be rendered in the same batch. If they use different materials, no. Different textures = different materials.
However you could pack those AO maps into a single big AO map, and then use the same material on each house, just offsetting the UVs to match. That would batch all as one.
However… your engine has to be written to support batching in the first place. Talking to your rendering/graphics programmer is a good habit to get into in general. I’ve learned so much from the ones I’ve worked with."
When people talk about batching, is it that you allocate an array and send off the geometry to the graphics card in a single drawcall and render them all with the same renderstates and texturestates in the shader. Or is it still separate drawcalls per mesh but with same renderstates for them all?
When people talk about batching, is it that you allocate an array and send off the geometry to the graphics card in a single drawcall and render them all with the same renderstates and texturestates in the shader. Or is it still separate drawcalls per mesh but with same renderstates for them all?[/QUOTE]
A traditional batch is all one draw call, so it’s a single vertex buffer and single material / texture state. So “batch” describes it very well. You “batch” up your geometry on the cpu and then send it as one big chunk to the GPU with a single draw call.
Also the overhead CPU/GPU costs of batches can depend on platform and to confuse things not all batches are equal, smaller state changes like a different texture cost less. Yes its good to batch when possible and as long as you are not including geometry off-screen that is still vertex processed.