Shader Material doesn't work with instances

Shader Materials don’t work with instances. Even after including instancesDeclaration and instancesVertex, the material doesn’t work because its missing the attributes “world0”, “world1”, “world2”, “world3”. I have fixed it by adding them in the materials instance, however during the process I found out that the code for it was there yet it didn’t work. The problem is in :

MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
if (defines[“INSTANCES”]) {

More exactly the if (defines[“INSTANCES”]) is never true, seems like the value isn’t “INSTANCES” but “#include INSTANCES”.

The test has been done with BABYLON 4.0.


When creating your shaderMaterial using the constructor you can just add the defines your want. Just include INSTANCES in the list of custom defines.

If this does not work, please create a PG as this is supposed to work