Been dabbling around with decals for a while. While it works like a charm with normal meshes, it doesn’t work with instanced meshes. How can I make it work with an instanced mesh? Does it require modifications to the source code?
I see my friend, that you really need solution of your problem…
Thing is, that probably nobody gives you one-liner solution of that. I think, good will be understanding of nature of instanced meshes. Then we understand that has to be:
Very complex.
Very bad for performance.
Each instance shares the same geometry and material but have different transformations (position, rotation, scale - (!) how many, possible calculations, you need to hit them) to minimizing the number of draw calls, and nature of decal is applying other geometry on meshes which doesn’t even fully exist (in this scenario), because only one exist (with its geometry) which is root of them, then even on first glance has to be hard to implement, at least for me.
If you put a gun to my head and I had to do it, I would try to do it with a custom shader, with the shape I’m interested in, and use Raycaster to detect intersections, and stick decal. Similar like in this example but, let say, shading shape, on instances. But I don’t even know if it’s possible or if it will work…
Hi @Lukasz_D_Mastalerz Thank you for your response. My requirement was very open ended, and this was one approach I had spent a good amount of time on. A custom shader on an instanced mesh was proving to be equally difficult.
Came across Troika’s InstancedUniformsMesh - Troika JS . Hopefully, this works well!