Combining meshes without drawing them and performance issues

Another tip for reducing vertex count. Using the inspector in this Babylon.js Playground

You see that the vertex count for cyl is 16 and for polygon is 12 a difference of 4, so with 10K tubes that’s 40K vertices less.

Note that forceSharedVertices is also used to reduce the vertex count in both meshes. Removing this swaps the vertex count benefit cyl 30 and polygon 36. A disadvantage of forceSharedVertices is the look of the material. Comment out the wireframe lines and then in turn the forceSharedVertices lines and you will see what I mean.

Also disadvantages of using polygon are that for non PG projects Earcut needs to be loaded as well and as you can see from the small box the local center for the polygon is not in the middle. You can overcome this using a baked translation. However if you really want to reduce the vertex count then polygon with forceeSharedVertices is the way to go.

1 Like

still buggy about the ringX positioning regarding their scalings but almost done : https://www.babylonjs-playground.com/#PN6F08#5

1 Like

works fine with 10K tubes of 5 rings : https://www.babylonjs-playground.com/#PN6F08#6
now, trying to fix the scaling/positioning bug in the parented particles …

[EDIT] there’s probably also an error in the particle number because it remains at least one in the center of the screen

1 Like

Using polygon method with forceSharedVertices vertex count for SPS drops from 690000 to 300000 https://www.babylonjs-playground.com/#PN6F08#8

1 Like

it works even with 16-tessellated cylinders and 10K tubes here : https://www.babylonjs-playground.com/#PN6F08#9

[EDIT] so this answers the initial post : you can display 10K tubes (of 5 rings) with a SPS in one draw call

2 Likes

Unless there’s a bug in the SPS parenting, there’s still a bug in my PG (or there are bugs in both :smile: )

[EDIT] I have a lead about the remaining central particles : there aren’t 10K tubes in the screen for now !

1 Like

Ok fixed for the tube number (so the remaining central particle) : https://www.babylonjs-playground.com/#PN6F08#10

still the parenting/positioning bug to solve

[EDIT -no more self reply allowed-]
fixed (I hope) : https://www.babylonjs-playground.com/#PN6F08#13
The error was in the initial baking

So 10K tubes of 5 different rings (size and color) at 60 fps.

[EDIT 2] can’t stop playing : https://www.babylonjs-playground.com/#PN6F08#15
50K tubes of boxes

then 80K : https://www.babylonjs-playground.com/#PN6F08#16

and finally 100K at 60 fps with no browser crash here : https://www.babylonjs-playground.com/#PN6F08#17
I suppose it’s enough for your initial need :wink: The SPS can be a strong boy sometimes.

More seriously, you’ve just to adapt this example to your own need, what seems actually easier to manage : one white tubular axis as ring0 and some other colored rings (only you know how many) all parented to every ring0.

4 Likes