When an instance is scaled negatively, the instance buffer stops functioning correctly

We are developing a selection system to highlight individual meshes with custom colors. To handle instances, using instanced buffers, but encountering an issue where instances with negative scaling behave unexpectedly.

Below are playground examples

With a custom shader

Material Plugin

Any workaround may also help.
Thanks

When not all the instances share the same determinant (so scale sign is different), Babylon HAS to split them into multiple draw calls as they do not share their winding order anymore.

What should I see in your first PG? what is wrong?

1 Like

okay, I understand Babylon has to render in diffrent draw calls in case not share same determinant.

Is there any way to still highlight it ? Like in first PG, if I applyed -ve scale, instead of rendering red its rendered black. Is there way to render mirrored instance with red color ?

Same with PG-2, highlight green color not applied when scaling.x = -1.

The third cube is not rendered as an instance thus it doesn’t receieve the instancedBuffers neither the highlight color vector4.

One solution is to do a clone for the negative scaled mesh and create it’s instances to make it working:

Your PG:

Modified PG:

1 Like

thanks @roland, I think this will little complex to manage :slightly_smiling_face: for large projects, although trick will work for this issue.

1 Like

I was thinking about such stuff but it was only a guess, I could not be sure… Thanks for confirmation ! :grin:

1 Like