3,000 Moving Objects at 60 FPS using Blitting!

Subscribe to 3,000 Moving Objects at 60 FPS using Blitting! 33 posts

avatar for RTL_Shadow RTL_Shadow 1023 posts
Flag Post

So I’ve been studying blitting lately, just to see how far I can push it. So far I’ve got 3,000 moving 16×16 balls at 60FPS flat- I could probably get it faster as I wasn’t aiming for optimization. Here is the demo.

For some reason if I run it straight from FD it stays around 30FPS, it only stays at 60 in browser!

 
avatar for BobTheCoolGuy BobTheCoolGuy 3754 posts
Flag Post

Post your code maybe? Then we can suggest speed improvements. :^)

 
avatar for alecz127 alecz127 817 posts
Flag Post

I’m getting 10 to 20 FPS from that link.
Maybe its just my browser though.

 
avatar for UnknownGuardian UnknownGuardian 8136 posts
Flag Post

20-25fps on my low-end (modern) laptop. Not bad.

 
avatar for BigJM BigJM 468 posts
Flag Post

40 fps … suckas!

 
avatar for FlashGrenade FlashGrenade 244 posts
Flag Post

35-38 fps on my 6 year old toshiba satellite

 
avatar for RTL_Shadow RTL_Shadow 1023 posts
Flag Post

I guess my comp’s just better than yours :P just kidding. But seriously. I get 60 fps :P

I’ve uploaded the project and it’s files here!

 
avatar for BigJM BigJM 468 posts
Flag Post

I’m happy with 2nd place.

 
avatar for Aesica Aesica 951 posts
Flag Post

Solid 60.0fps and I’m using bloatfox. /kicks AS2 in the junk for being so terrible.

 
avatar for BobTheCoolGuy BobTheCoolGuy 3754 posts
Flag Post

50fps running on the Debug player? Do I win? Or lose? :D


One tip anyone RTL:

Instead of doing list[i] all the time, just store a reference to it.

var myItem:MyClass = list[i];
myItem.//whatever
 
avatar for RTL_Shadow RTL_Shadow 1023 posts
Flag Post
Originally posted by BobTheCoolGuy:

50fps running on the Debug player? Do I win? Or lose? :D


One tip anyone RTL:

Instead of doing list[i] all the time, just store a reference to it.

var myItem:MyClass = list[i];
myItem.//whatever

I did that earlier- really seemed to do nothing for performance- but I’ll do it definitely. Thanks.

 
avatar for alecz127 alecz127 817 posts
Flag Post

Bob quick question. Does that improve performance or is it just cleaner?

 
avatar for qwerberberber qwerberberber 508 posts
Flag Post
Originally posted by RTL_Shadow:
Originally posted by BobTheCoolGuy:

50fps running on the Debug player? Do I win? Or lose? :D


One tip anyone RTL:

Instead of doing list[i] all the time, just store a reference to it.

var myItem:MyClass = list[i];
myItem.//whatever

I did that earlier- really seemed to do nothing for performance- but I’ll do it definitely. Thanks.

referencing directly is faster than vector access.

 
avatar for RTL_Shadow RTL_Shadow 1023 posts
Flag Post
Originally posted by qwerberberber:
Originally posted by RTL_Shadow:
Originally posted by BobTheCoolGuy:

50fps running on the Debug player? Do I win? Or lose? :D


One tip anyone RTL:

Instead of doing list[i] all the time, just store a reference to it.

var myItem:MyClass = list[i];
myItem.//whatever

I did that earlier- really seemed to do nothing for performance- but I’ll do it definitely. Thanks.

referencing directly is faster than vector access.

I knew that. I guess I just mean’t no big noticable difference.

 
avatar for Senekis93 Senekis93 4090 posts
Flag Post

Do ++i, not i++.
Cache canvasBMD.rect.
Cache item.width and item.height or the result of STAGE_WIDTH/HEIGHT minus half those values.
Move the logic of item.render to the actual loop.

23 FPS on my machine. Way better than a lot of games that I’ve played here, most of which don’t render more than a couple dozens of objects every frame.

 
avatar for sHTiF sHTiF 23 posts
Flag Post

3000 is not that many actually I remember running couple of thousand with all of them colliding with a ground with pixel perfect collision at the same time at 60FPS.

Senekis93 +1 is no different than i+ in AS3 but nice to see someone from C background here :D
No need to cache canvasBMD.rect either, first its not being recalculated and secondly its called just once.
Definitely move the render logic to the loop or inline it in the latest Flash compiler.

The problem with blitting is its rather limited fillrate so its great for many small objects but once you get larger objects its not so much fun. Its nice to see someone still plays with blitting when Stage3D is out there but whats the reason? Flash 9-10 compatibility seems like the only sensible answer.

 
avatar for qwerberberber qwerberberber 508 posts
Flag Post

Flash 9-10 compatibility seems like the only sensible answer.

Unless you are releasing your Genome stage3d engine, writing less code is also a reason ==.

 
avatar for sHTiF sHTiF 23 posts
Flag Post

qwerberberber I explained the reasons for not releasing code at the moment many many many times not going to repeat myself. :) BTW parts of the code will be released with 0.9.3.

Anyway whats stopping you from using it? Or even other Stage3D frameworks if you want open source right away, I mean you can “emulate” low level draw calls even there probably. As there is no real blitting in GPU you always need to construct geometry and draw it through that thats what I do in G2D.

And since when writing more code is a reason not to have best perfromance possible? I mean lets draw 200 000 images using Stage3D or 3000 using blitting? ;) As I said the compatibility is the main reason and trying to avoid direct wmode although that seems no longer be such an issue as almost everyone supports it.

 
avatar for Drakim Drakim 1140 posts
Flag Post

You do lose some flexibility and control over the drawing proccess when using Stage3D. Stage3D is better at pushing plain sprites, but if you are going to do anything cool or fancy as you are drawing I think you will run into roadbumps. A raycaster or mode7 like pseudo3D stuff would be very problematic for instance.

 
avatar for sHTiF sHTiF 23 posts
Flag Post

Drakim yep you are right there are very specific limitations to Stage3D for example pixel perfect collision is a no go at reasonable performance. At the same time though there are things that can be done reasonable faster in Stage3D beside the drawing itself like color manipulation, postprocessing etc. At the end its up to the specific use case.

 
avatar for Ace_Blue Ace_Blue 1082 posts
Flag Post

I’m averaging 59.5 fps with Chrome. I haven’t seen a 60.0, so I guess without the fps counter in the corner I would be fooled into thinking I have no lag.

 
avatar for Drakim Drakim 1140 posts
Flag Post
Originally posted by sHTiF:

Drakim yep you are right there are very specific limitations to Stage3D for example pixel perfect collision is a no go at reasonable performance. At the same time though there are things that can be done reasonable faster in Stage3D beside the drawing itself like color manipulation, postprocessing etc. At the end its up to the specific use case.

A different possible path would be to use the secret alchemy op-codes to treat the image data and blitting, outputting it all to a bitmapdata at then end of each render (since you can’t show a bytearray directly on the screen). I’ve used this and gotten some pretty good results, even with my own custom rotation and scaling for the sprites.

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

I get 50+ FPS at 780MHz

Good job

 
avatar for BobJanova BobJanova 856 posts
Flag Post

40 fps for me. The BitmapData stuff seems to be pretty fast, I’ve got some textured lightmap code and it’s basically as fast as cel shading.

How flexible is this? Can you draw an animated or shape-changing object?

 
avatar for Drakim Drakim 1140 posts
Flag Post
Originally posted by BobJanova:

40 fps for me. The BitmapData stuff seems to be pretty fast, I’ve got some textured lightmap code and it’s basically as fast as cel shading.

How flexible is this? Can you draw an animated or shape-changing object?

Making it animated is pretty trivial (and really shouldn’t affect performance much), but I’m not exactly sure what you mean by shape-changing object.