Hi there, is it possible to perform hardware instancing with more than one material for a mesh?
Thanks in advance.
Hi there, is it possible to perform hardware instancing with more than one material for a mesh?
Thanks in advance.
Hi @yaswanth,
Yes, it’s definitely possible. HW instancing works on a draw call level, that is a combination of a mesh instance and a material.
So you can iterate in the mesh instances array of your mesh and prepare and set instancing on each.
Thanks for your reply.
So, we can have 3 materials for a mesh and can have n no of instances with each instance having 3 materials applied right?
Have a look at the example here: PlayCanvas Examples
It gets a mesh instance and sets up instancing for it this way:
const boxMeshInst = box.render.meshInstances[0];
boxMeshInst.setInstancing(vertexBuffer);
You’d need to replace this by a loop and set up instancing for all mesh instances.