Material Plugin: Can I have different output for clones and instances?

PG:

So eventually I wanna have an edges rendering setup w/ material plugin like the wireframe plugin but controlling where the edges are.

But the thing is, I wanna have maybe different colored edges for materials and instances.

I initially thought I could use a uv buffer to store identity or config and just use that to show different stuff

for instances I thought instanced buffer was smth worth looking into.

But I’m confused on how I get from having an instanced buffer to accessing that in the mat plugin.

also for clones of meshes, the underlying geometry is the same => the buffer is the same => it can’t possibly have different uv buffer values for clones?

so is there a way I can have clones and instances of a mesh be different colors with the material plugin (using the same material)?

TYSM! : )

For clones you could do it like so https://playground.babylonjs.com/#METPQJ#1 But it feels wasteful because, I am guessing, makeGeometryUnique copies all buffers, not just the one you need.


FYI, I was playing around with the VertexBuffer class. No luck (https://playground.babylonjs.com/#METPQJ#2). But have a look at here: Babylon.js docs There is an index parameter. Maybe use can supply a larger ArrayBuffer and increment indices for each new clone/instance?


…meanwhile…

This should work Babylon.js docs :grinning:

1 Like

Yes, calling makeGeometryUnique duplicates all the geometry, so, in effect, the two meshes are not clones anymore.

For instances, creating a custom buffer as you pointed is the way to go, but note that you will be able to retrieve a single value per instance, not per vertex/per instance.

1 Like

Thank you so much yall are the best!! : D

got it working : )

2 Likes

but note that you will be able to retrieve a single value per instance, not per vertex/per instance.

noted o7 ty!