For performance reasons, I am currently deepdiving into thin instances.
I did follow the pirate tutorial and was amazed by what the NME can do for you.
Now I played around with radial instance arrays and got stuck with the orientation
of instances. I already figured out the general rotation, but unfortunately don’t know how
to connect the instances to the rotation part in order for all of them to look at the center
of the circle that they are forming. Does anyone have an idea??? Thank you!!!
Hey Evgeni!
Thanks a bunch. This is exactly what I was looking for.
Unfortunately, I couldn’t create this matrix by myself.
I think it will take me the weekend to get through the code
to completely understand it.
Cheers!!!
Hey Engeni!
One more question regarding thinInstances. I am trying to change colours and scaling of the instances, using shaders. I already had a look at the forum where you have been commenting on thinInstances and shaders. What I now tried was your shadercode with the includes, but unfortunately without any luck. Do I need to use different includes if I have an array of matrixes?
Hey there, the Matrix.Compose function can be used to easily set the scaling, rotation, and position of the matrix, like on line 75 in the updated PG below, and for the color you can register and set a custom attribute like on line 93.
And it’s prob good to note, depending on what you’re after, that you could comment out the shader and just let the default material work it’s magic (which supports the color attribute), like this PG.
Also, the thin instances documentation has more info and example playgrounds.
Hey Blake!
Thank you for your quick reply. It does make sense, and I already got a single color working.
I didn’t know that one has to create a buffer. Now that I know, it starts to make more sense.
However, what I am eventually after is the following PG, where I can use a shader to generate
dynamic movement, scaling and colours of multiple instances. https://playground.babylonjs.com/#CSMDRY#43
Ooh, that is a bit different, using NME instead of ShaderMaterial. Unfortunately I haven’t used NME much so IDK how to add a custom attribute to that NME material, so I’ll leave that for someone experienced with NME to answer. As for setting the colors thou, it might be easier to set them one at a time like this for example.
Hey Blake!
OMG, thats a very clever solution. Regarding the NME vs Shader, I would like to use a shader in the end.
The NME was only for showing what I want to achieve. The following example already shows one row of instances with a shader material, but I am still missing the other 4 rows. Do you have an idea? https://playground.babylonjs.com/#MT2SFV#11
Holy Moly, So much to learn… Thanks again Evgeni for your clear and prompt answer.
But Instances and Martices are a hard thing to get my head around. Good that
Jedi Masters like you are around to help the young skywalkers to find their way in
the Babylon Universe.