Hardware instancing with multiple materials?

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?

1 Like

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];

You’d need to replace this by a loop and set up instancing for all mesh instances.