Wednesday, March 9, 2011

Introducing M2D – GPU accelerated 2D framework for Flash ‘Molehill’ API

Introducing M2D – GPU accelerated 2D framework for Flash ‘Molehill’ API:

M2D – GPU accelerated 2D framework for Flash MolehillI am pretty sure, that most of you are familiar with ‘Molehill’ – the new 3D API for Flash Player that enables GPU acceleration. Some people were wondering if this is just for 3D. The good news is that you can actually accelerate 2D graphics as well by rendering them on a stage3D instead on a stage (DisplayList). It’s little bit tricky, but definitely possible.

For instance if you have a look at this demo – http://www.bytearray.org/wp-content/projects/molehill2d/molehill/ – the 2D graphics are rendered on GPU via Molehill.
But if you look at the code of this example and are not really coming from an OpenGL or DirectX world, it might take too long for you to pick it up.

To make it easier for you, Ely Greenfield wrote a framework called M2D, which is available here at github.

Features:
- render embeds
- animate spritesheets
- position, rotate objects
- particles

Kudos to Ely! I mean, this is really big thing for 2D Flash games. Now you can render thousands of sprites with 60 FPS easily and smoothly and I am looking forward to see games using it.

I have forked the original Ely’s M2D and added RenderScene class and Physics class that uses Box2D C++ Alchemy port. RenderScene is simplified API for using M2D, which will fit most of your use cases and is easy to use for everyone.

How does it work?
In 3D there are couple things available to you – geometry (in our case triangles), textures and shaders.
To actually display an image – you render two triangles per a rectangle and then you upload a bitmap to it with correct UVs.
How does M2D work

Can I accelerate DisplayObjects from Flash DisplayList?

Yes, you certainly can. The only thing is that currently it supports only static DisplayObjects, but MovieClip support is planned for the future. Animated sprites are currently supported via SpriteSheets – there is a tool, which can help you to easily convert SWF to a PNG SpriteSheet – check Zoë by Grant Skinner.

Future plans
- Mouse Events – there is currently no framework support for mouse events
- Animated MovieClips – animations can be done via SpriteSheets
- Optimizations – we are pretty sure that there will come numerous optimizations in the future by the community
- ATF support (Adobe Texture Format)

Open Source Project
The framework is provided for public domain “as is” with no guarantees, you may use it in your own commercial projects for free, fork it, change it, upgrade it. We are looking forward to hearing from community about new updates, projects using M2D and proposals for the future versions [...]

No comments:

Post a Comment