Mixing a shared buffer and unique ones? Instance like deployment?

So how what would be the best way to have lets say 1000 nodes all with the same geometry buffer, all using the same material, all have different transform matrices, and a different uv2 buffer.

I have a couple ideas I want to try, but figured the greater good might have a better idea then me. Was thinking I might have to make my own shader that has the uv2 buffer just stacked on itself for all the nodes and then have an id and a stride offset for each mesh so I can associate the correct uv2.

Basically we are trying to solve this:

Another thing I was thinking was that the SPS could handle it, or perhaps a extension of thin instances.

I do not think there is a nicely working way to do that.

Are the UVs more like an atlas so only scale and offset is changing or are they completely different ?

Its for a lightmap so I think its like an atlas, are you saying use a custom shader that offset and scales the uv on the vertex the passes that as the uv2 to the fragement? Oooo dude I think you nailed it.

1 Like

so basically you ll only need one more instance buffer to specify the texture offset scale matrix for each of the model

1 Like

:point_right: :point_left: :sweat_smile: could you pretty please show me a small example of how I would go about that? I think I know but honestly am drawing a blank on if I should do it as a custom material or use thin instances or SPS.

Normally Id dive in on my own with this but I’m running mental blanks at the moment. So even a pointer to the right docs would help.

I d go with thin instances Thin Instances | Babylon.js Documentation and a NME material.

I think @Evgeni_Popov as an example of such case ?

I’m not sure I understand correctly…

If your uv2 are completely different from one instance to the other you will have to put all the uv2s of all the instances in a texture and use an attribute to indicate the offset in this texture to start reading the uv for each instance.

This may help: Separate value for each vertex for instances? - #2 by Evgeni_Popov

If your uv2 can be deduced from the uv by a simple offset + scale you can just pass this offset + scale as two instance attributes, but I doubt you are in this case.

So off reading that thread I think there is all the info needed.

1 Like