[UPDATE]
As it stands, these are the fastest ways to draw many squares:
1. Particles with a square texture
2. many Pixels
3. A single Mesh with many vertices
4. Many shapes
5. Many meshes
6. Many bitmaps (very slow)
Animation is fastest without using a tween library, such as MovieClip or GTween.
[/UPDATE]
Quick question: I want many moving squares on the screen at once. Which would be more efficient?
1. Square bitmaps loaded from a spritesheet
2. Square shapes created at runtime
3. Something else?
I'm betting on 1, but there may be a better option?
Comments
Will test this.
http://giderosmobile.com/forum/discussion/comment/31638#Comment_31638
Since hgy29 rewrote part of the engine I am not sure this still applies, please let us know your findings.
I can tell you that in my game on 2015.09 is much faster to place many bitmaps (with the same texture) than drawing the same number of shapes, but I didn't try it with meshes.
Thanks @pie. Ok, the results are in.
This is the test scenario, based on my requirements:
- 1000 constantly animated objects of the same size
- Each object has a random transparency and colour
I tested this with Gideros v2015.09 player on an iPod Touch 5th Generation (one of my slowest test devices).
Average fps across four devices:
Shape: 34.75
Mesh: 34.5
Bitmap: 28.75
Shape wins overall, with Mesh good second and Bitmap slowest.
Bitmap: 26fps
Mesh: 29fps
Shape: 29fps
thknoman was right, mesh is the best option. Thank you both for undermining my certainties
In the past I changed shapes with bitmaps in my game because they were providing a better performance, maybe it depends on the setup, but now I have to test it again..
I added two lines to know how much time they take to be placed, but it's not so different since we're speaking of ms.
I run different tests and wrote down the lowest and highest values I got.
Ah you're right! I trusted you... so mesh is still the best performer
bitmap 36-48 fps and 480-490kb
objects placed in 0.16-0.20
mesh 39 - 53 fps and 570kb
objects placed in 0.14-0.22
shape 34-53 fps and 580 kb.
objects placed in 0.24-0.28
In my test it's pretty even, but Shape has the slight edge. Can you verify Mesh is faster in your case?
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Shape: 34.75
Mesh: 34.5
Bitmap: 28.75
Nexus 6 (Android) is performing very poorly. Any ideas why it differs so much from its iOS cousins?
@hgy29 Will they be faster than the current shape type?
Likes: totebo, antix
https://deluxepixel.com
Vector shapes will be more efficient when drawing complex polygons or curves.
However a particle shader, as the one used for Box2D particle system, may be much more efficient than shapes or meshes.
https://google.github.io/liquidfun/Programmers-Guide/html/md__chapter11__particles.html
https://deluxepixel.com
But maybe something that just does squares as fast as possible, with the ability to have different scales and colours would be a good thing to suggest on the github page?
https://deluxepixel.com
Sorry I didn't look at this earlier!
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
also i use a nice trick i can do to have several 'brushes', which can be useful for particles too. in my texture associated with the mesh there are 64x64 textures next to each other horizontally. so if the 'brush' value is 2 in my function, then it will draw the segment using the 2nd block of these textures. that's the way you can practically use several textures in one mesh, they just have to be put next to each other in one big texture.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Haven't checked it on Android yet but can immediately see the difference on my PC.
Likes: totebo
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
Then change the math.random and math.floor to just random and floor. It will be faster.
https://deluxepixel.com
https://deluxepixel.com
On a Nexus 6 which benchmarked 18fps in the fastest previous test (using Shapes):
Without animation: 60fps
With animation: ~16fps
Gah!
Will be looking through the code to see if I've messed something up, or if it's simply GTween that sucks a lot of CPU.
MovieClip has proven faster than GTween in my previous projects. Is there a way to modify MovieClip to use getters and setters on any object, rather than just Sprites (like GTween)?
The Gideros project is attached. Improvements very much welcome!
https://github.com/gideros/gideros/tree/master/libpreviewwidget
Added this, in any case:
https://github.com/gideros/gideros/issues/194
Likes: SinisterSoft
PS: plural of vertex is vertices...
Likes: SinisterSoft
So, is it fast? On my Nexus 6, wait for it: 16fps.
I'm giving up trying to get speedy squares. For now. Anyone got ideas, shoot!
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975