InstancedMesh shared UV

Hello,
I have a lot of identical objects but with just a different image showed on them.
To make it more performant i wanted to use instances and sprites
but now i am stuck as i don’t see a way to use instance buffers with UV mapping. I tried standard and pbr material
Anybody knows if this is even supported

Here is a small demo
Switching withBuffers toggles between shared uv mapping from initial object vs trying to use the same config but just defined per object

Thanks for any help! :slight_smile:

1 Like

Hello @Daniel_Wagner , how are you doing? Welcome to the Babylon Community!

I don’t think this is supported. But I will ping @RaananW just to be sure. Adding UVs for each object would be different from adding color (the example in the documentation about using custom Buffers). Custome buffers can be used if you want a single value (like color or position) to be used when rendering a instance (been able to be set individually by instance).

UVs on the other hand are values that must be set per vertex, per instance. Which would be completely different things in the shader.

2 Likes

Yep :slight_smile:

It’s not supported in code. Only primitive types and vector/color/matrix are supported.

Hey there. :slight_smile: I think what you’re after is a way to use a different part of the texture for each face of each instance?

Here’s an example that uses a simple material plugin (docs) to add support for a uvOffset attribute. Then the first instance uses the first row of 6 images and the second instance uses the second row of 6 images.

4 Likes

Thank you all!
Thanks for confirming my doubts - i am still learning shaders so wasn’t sure

and thanks @Blake this looks exactly like what i was looking for. Second, shader plugins looks like perfect way to mess with shaders without having to rewrite them completely - new to me too.