Playing with Instances and ThinInstances


Just want to share two PG exercices I made to test Instances and ThinInstances :

Instances version :

And ThinInstances version (do not try PRECISION = 1 if you do not have a really powerfull CPU) :

BTW : I got a really strange behaviour with thinInstanceBufferUpdated , it simply didn’t work, so I have to update my buffer by using thinInstanceSetBuffer; an idea ?



The doc is wrong regarding the updateable buffers with thin instances (the buffers are static by default, meaning updating them won’t work). This PR will fix it:

Updated PG:

Note that when you use thinInstanceBufferUpdated, the bounding box is not recalculated. That’s why I set boxModel.alwaysSelectAsActiveMesh = true; line 20.


Ok thanks.

And thanks too for the “ready” boolean addition you made, I was lazy at time of writing the thinInstance version and my implementation was a little bit “dangerous” or “optimistic”.

I’ll look at other features I can show to my students now, bye.

1 Like

Does thinInstances work good for objects like spinning coins in the game? I have 40-50 coins(and others obj too like logs, planks, gems etc…) and I need to spin it around Y axis.

Currently I’m using Instances but I have 200-300 active meshes and it doesn’t scale well if I want to add more objects.

Yes, using thin instances instead of regular instances will probably be better for performances. If a lot of instances are not visible in a given frame (coins are scattered throughout the level), you may want to create multiple meshes, each with a subset of the (thin instance) coins, so that some of the meshes will be culled by the frustum culling test.


What to add ? If all coins are the same thininstances are fine, i got some problems with rotation and scaling, maybe it was beginner errors, I need to try it again.

Good luck with your game dev.

Can you share a repro @Olivier_Arguimbau ?

Hi !

Like I said it was a beginner mistake, I try it just right now and it’s working :

Translation + Rotate + Scaling

I didn’t try with buffers but I suppose it’s working too.