Hello!
I’m creating a 2.5d shooter-esk game with 100s of enemies on screen. To create the enemies I’m using instanced meshes of a plane. I’m using instanceBuffers in order to update the UVs and animate the sprites. This ability came from this post and this playground.
managing, animating, and drawing all the mobs is working very smoothly, however I want to switch from camera billboarding to USE_POSITION, the reason being in VR the camera billboard is slightly nauseating, it doesn’t feel right. And yet the USE_POSITION is more natural in the 3d vr space. The mobs are more like cardboard cutouts turned towards you when billboarded with USE_POSITION.
When using USE_POSITION with instances it seems like the original mesh’s position is used and the same rotation is applied to all the children. Is this expected behaviour?
I’m asking is anyone more knowledgeable of instances, shaders, and instanceBuffers might know how I could change each instance’s rotation in order to point the plane towards the position of the camera.
Thanks!
Hello! Would you be able to share a playground repro so we can take a look? It doesn’t need to be your entire game, just a simple scene with the instances.
Certainly!
In the playground it seems the USE_POSITION is actually ignored.
Thank you!
So I have a CPU bound implementation similar to how TransformNode implements USE_POSITION. In fact I did a find-all in the repo and found it’s implementation in TransformNode that way
For 100s of sprites it seems to be okay, I don’t know if it can push 1000s or 10000s like a pure sprite or thin instance can but for my purposes it’s okay.
However! If anyone knows how to offload this from the CPU similar to how the raw mesh or thin mesh does it, that would be awesome!
Here is the updated playground. If there is any interest I can clean it up and post in the Tutorials/Tips section…
Just publish a fix for the mode Fix Billboard mode use Position by sebavan · Pull Request #11870 · BabylonJS/Babylon.js · GitHub
Also please note the mode is to apply on each instance but not the root or it would get double applied once the PR has been merged