I’m trying to optimize the scene of my game, for older mobiles.
I have a number of 3D objects in my scene ( cards ), and am now trying to share a textured material between them, in order to reduce the draw calls.
Each material has a different offset and tiling into the texture.
As it stands, the draw calls are around 40;
If I batch group the meshes, and assign the same material to all the objects ( same offset, same tiling ), I see the draw calls drop a lot - to 13.
var vec4 = new pc.Vec4(1, 1, 0, 0); //tileX, tileY, offsetX, offsetY
model.meshInstances[0].setParameter('texture_diffuseMapTransform', vec4.data);
If I then try to change either the tiling or offset for each object, the draw calls revert back up to 40.
var vec4 = new pc.Vec4(Math.random(), 1, 0, 0); //tileX, tileY, offsetX, offsetY
model.meshInstances[0].setParameter('texture_diffuseMapTransform', vec4.data);
So - should it be possible to have different meshes use the same material but with different offsets and tilings, and get drawn with a single draw call?
It’s like using a texture atlas, but on 3D models rather than sprites.