3,000 Moving Objects at 60 FPS using Blitting!

33 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!

 
Flag Post

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

 
Flag Post

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

 
Flag Post

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

 
Flag Post

40 fps … suckas!

 
Flag Post

35-38 fps on my 6 year old toshiba satellite

 
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!

 
Flag Post

I’m happy with 2nd place.

 
Flag Post

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

 
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
 
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.

 
Flag Post

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

 
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.

 
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.

 
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.

 
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.

 
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 ==.

 
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.

 
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.

 
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.

 
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.

 
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.

 
Flag Post

I get 50+ FPS at 780MHz

Good job

 
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?

 
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.