thinInstanceCount doesn't seem right when creating with mesh.thinInstanceSetBuffer

Potentially an unintented regression from here, or potentially something different.

This PG - Space-Truckers: The Scene Optimization! | Babylon.js Playground (babylonjs.com) - shows via console log output what I’m seeing.

I initially specify 15000 asteroids to be created. Unless I got some array math wrong (not unlikely), I’m getting 4x the number of TI that I asked for - 60000! As part of what I’m working on, the thinInstanceCount gets changed by a custom SceneOptimizer until FPS hits 60. Here’s a sample output log:

creating count of asteroids 15000
loaded HDRCubeTexture
ready scene
Instance count before optimizing 60000
Reduced asteroid thin instance count
Instance count before optimizing 48000
Reduced asteroid thin instance count
Instance count before optimizing 38400
Reduced asteroid thin instance count
Frame rate stabilized at 60 with 30720 asteroids

Normally I’d be the first to ask what I’m doing wrong here, but @RaananW at some point in the past gave me permission to question if it’s something in the engine :slight_smile: :sunglasses: :heart:

P.S. - Not that I’m objecting to being able to display 60k asteroids, just have no idea where or why that figure is arrived at!

1 Like

Heya, it looks like the problem is on line 242 where the size of the matrix array is set to numAsteroids * 64. Since each matrix is size 16 floats, then the size of that array should be numAsteroids * 16. :slight_smile:

3 Likes

Well gee, I suppose that might have something to do with it! Thanks @Blake - I’d convinced myself that there was somehow a reason for it being 64 but now you mention it… yeah.

2 Likes