Thin Instance node material - instance position?

Hi,

I have been investigating Thin Instances (love 'em) and am wondering if we can get the instance position in the node material, ie not the vert positions? I am using the output slot of the instance node to transform the mesh.position which gets me the world position of each vertex but I am wondering if I can also get the world position of the instance? Reason is that I want to move the instance in the node material as a solid object, ie move all the verts by the same amount (which is computed by the instance position). I will see if I can setup a node material to show what I mean but thought someone might have some initial ideas.

ahh, lightbulb moment. I was able to do it by using the color buffer (which I wasn’t needing). I can encode the information I need into a color channel :slight_smile:

You can also multiply your world matrix with (0,0,0,1) to get the translation part of the matrix, which corresponds to the instance position:

https://nme.babylonjs.com/#UG6JUE#1
https://playground.babylonjs.com/#FPU8ZX

3 Likes

Thanks @Evgeni_Popov that works too and is probably a better solution as it doesn’t waste my color buffer in case I do need it in future.