Performance doubts(commercial project)

i meant more like json generated by TexturePacker - Create Sprite Sheets for your game!, and just use it via simple API i.e let sprite = createSprite("my_spritesheet/test_frame.png").

Anyway guys, thanks a lot for you help!. Really appreciate it. After weekend i will start working on some PoC but seems like i can adapt babylon to my needs.

Have a nice weekend guys!!

1 Like

That makes me happy :slight_smile:

1 Like

The concept of “Loop Damper” was a big performance optimization for our project.

Also this example shows 3 concepts within a pattern we call: AnmLoopz.

AnmLoopz: Damper, Removal, and Routing. : )

var alpha = 0;
scene.registerBeforeRender(function aLoop() {
    if(config.stopLoop){  scene.unregisterBeforeRender(aLoop); return;  } //AnmLoop Removal-.
    
    config.mesh.position.y += 0.01 * Math.cos(alpha); //Example: hoverAnm-.

    if(++alpha%2===0 || alpha%3===0){return;} //AnmLoop Damper-.
    
    //other lesser performant anmz.

The loop above only animates on ODD frames NOT divisible by 3. Eg. 7… etc. Output dampened.
You can also use that to easily animate many things simultaneously. Routing Frames.

   //AnmLoop Routing Pattern-.
   if(++alpha%2===0){  /*anm path 1-.*/   } 
   else if (alpha%3===0){  /*anm path 2*/ }
   else if (alpha%5===0{ /*anm path 3*/ }
   else { return } 

Techniques like that, is how we keep (commercial project) at 60 FPS.

:slight_smile:

3 Likes

@gao

TexturePacker looks interesting and I am going to have a go at adding a method of using it in sprite creation. To keep existing methods and effects on these sprites it will probably look something like this

(.ext means .jpg, .png etc)

var spm = new BABYLON.SpritePackedManager("name", url); // url will point to packed image as filename.ext and JSON will be filename.json;
var mySprite = new BABYLON.Sprite("name", spm);
mySprite.fileName = "individual sprite filename"; // eg spriteName.ext

//also have
mySprite.cellIndex = number; //relative to the place sprite added to packer, eg second sprite added will be 1;

Cannot guarantee it will be done or how long it will take so you still need to rely on your adaptation of Babylon. I will keep you informed.

2 Likes

@JohnK thanks, that’s awesome news :slight_smile:

Different size sprites texturepacker format now available

Docs on their way

5 Likes

Regarding point 3, it sounds like you are asking about spritesheet support at an actual mesh level (3d mesh), in which case, unless I’m missing something, Babylon still does not support yet with instanced meshes. I.e. Spritesheet support for instanced meshes take 2 – Unless I am misunderstanding, or unless you are looking for 2d only (in which case sprite manager should work fine).

I’d still kill for instanced mesh sprite support built into the framework @Deltakosh :slight_smile:

You can provide your own renderLoop and decide to skip one frame every two frame

Can you please show me a example render loop to skip all odd frames? =) Thank you!

let odd = true;
engine.runRenderLoop(() => { if (odd) scene.render(); odd = !odd; });
2 Likes

Oh no. it’s embarrassing. :upside_down_face: the solution is so simple :smiley:
Thank you @JCPalmer