Introducing b2dLite

update 27/03/2014

Latest version is on github, will add a few extra samples to go along with the source code later today.

Still have to move some more math onto the gpu but its working well at the moment :), need to do some more testing as the more that I shift to the gpu the smaller the batches become and the draw call savings get lessened ūüôĀ

update 18/03/2014:

Latest version is a bit faster handling 50,000 objects in under 10 ms no sweat (about 6-7 ms on my upper-mid range machine).

Added the use of asc2 fast bytearrays and it speeds it up a little, but not a great deal so will leave that out I think to maximise compatibility.

Just want to move a bit more math onto the GPU (still have a few multiplications and divisions that can be moved over to save a few cycles).

Once that is done I will update on github. Next step is putting rotation back in and maybe an alpha multiplier.

————————-

You can find it on github here:

https://github.com/bwhiting/b2dLite

Current  features:

drawing textured quads of a given position and size, with option texture offsets and scales

Future features:

add rotation – reduces performance as it will add to the number of registers required per quad, 3 no longer 2 (but all math done on gpu so no big deal)

(knowing if there is demand for this will be useful)

add more texture methods, i.e. auto mip map generation and non power of 2 size fixing function

Potential features:

Colourization, and other advanced effects.

 

Please give it a test drive and feedback on anything that works well, or doesn’t, anything missing?

Will keep this updated as I change things. Will also add a few demos when time permits.

First demo:

http://bwhiting.co.uk/b3d/b2dLite/ <Р10,000 objects

Another demo courtesy of¬†Peter Str√łmberg:

http://www.videometry.net/AGAL/bw/bw.html

 

6 Responses to “Introducing b2dLite”

  1. Slavomir Durej says:

    Awesome work Ben! yeah, rotation and colouring/tinting are definitely good next step!

  2. So do you starting own lite 2d framework?

  3. Josh Tynjala says:

    Rotation and alpha would definitely be nice additions.

    I’ve been wanting a simple library that only focuses on batching quads. I’m still a beginner with the low-level Stage 3D stuff, so it’s been intimidating to try to do it on my own. b2dLite seems really accessible from a learning perspective. I’ve tried understanding some stuff from Starling’s source code, but there’s a lot of abstraction in Starling that makes it difficult. The simplicity here is nice.

    I notice that the vertex and fragment shaders are defined in an array of integers. Were those originally written in AGAL? If so, would you be willing to add the original AGAL source code to the repository? It would be a nice learning experience to tweak the shaders a bit and see what happens.

  4. bwhiting says:

    Heh Josh, yes they were originally AGAL but I saved them as arrays so there were no depenacies on the agal assembly class from adobe.
    Will add the original shaders for you tomorrow and add a few comments to explain in more detail whats going on under the hood.

  5. bwhiting says:

    Have added the code for the shader up on github:
    https://github.com/bwhiting/b2dLite/blob/master/shader.md

    Feel free to ask as many questions you like.

Leave a Reply