Categories
Uncategorized

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 replies on “Introducing b2dLite”

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *