SPS vs instancing

Hi,

I am creating a scene where I have repetitive quads scaling over the x-axis.

I am trying to use the best performant way of rendering these and tried both instancing and solid particle system. I am making the meshes stick to the y-axis when the camera moves by updating the position on camera move.

With the solid particle system I need to update the single SPS mesh position and all my particles move with it, but with the instances I update each instance position individually.

I initially thought instances would be the way to go here, but getting better performance results using SPS. My question is then two fold.

  1. When should I use instancing vs SPS?
  2. Is there a better way of updating the positions for all the instances that I am not aware of?

You can position SPS particles individually

See all SPS docs

Thanks for the reply. I am updating the particles positions when rendering them. My question is more towards moving them around when the camera moves. Moving the single SPS mesh seems like there better options for what I am trying to achieve. I am creating like a sticky header on the y-axis. I am more interested to know what are the advantages using SPS vs instancing? We have a bunch of repetitive meshes we want to render and initially thought to go with instancing, but the SPS is giving me better performance when moving them around.

When using regular instances, Babylon checks if each individual one is visible through the camera before sending all the visible ones’ vertices to the GPU (which costs CPU performance). SPS works as a single mesh, so all vertices are sent regardless of their visibility status (which could cost GPU performance if there’s a lot of meshes). So it will depend on where your bottleneck is. There is also thin instances: Thin Instances | Babylon.js Documentation (babylonjs.com) which are also all sent to the GPU regardless of visibility of individual instances.

Thank you that makes sense.

So between SPS and instances you’ll probably choose ThinInstances :sweat_smile:

2 Likes