2D faces, funny fx

Flash

4 faces

i was playing (again) with a new version of the renderer.
Here a little experience with it.

Away3D, my new goal

Flash

I will have to pause the development of my engine for a while. I’ve just joined the dev Team of the Away3D engine. I will focus on bitmapdata/graphics implementations. Alexander Zadorozhny and Rob Bateman, the 2 geniuses behind the engine have set the technical bar very high. So if i can had just one class to the engine i would already glad. Everything you need for an implementation of the engine in a project is already in the engine or is on the drawingboard…
The approach is quite different than what i was doing, but the results on screens are simply amazing.

I have the serious feeling i now stand before a very challenging aventure here!

i will, as soon as i can post some working examples here.

For the visitors that have left the planet for the past weeks: after the release of Papervision and his great demo’s 2 flashers were working on what at first glance, seams like a clone of papervision. But after a few thousands lines of great code added and several major decisions made, the clone became technically superior to the original. So good in fact that both teams have decided to collaborate and merge the 2 engines. And that’s a very good news for everyone working with Flash.

Raster renderers, faster than Flash API

Flash

Because, we are working with bitmapdata we can do nice things with the rendering.

the line, the fill and the point. with lightining or not. (soon gourauld & phong shading)
There is even a linefill renderer, not shown here, where the fill are rendererd with a line as well, in a different color.
Because there is no way to draw directly into bitmapdata with the Flash API, i wrote my own one.
The big challenge was to find a way to fill the triangles fast.
The first approach was to trace on a separate bmd, the 3 lines and use the floodfill.
It worked, but gave some artifacts when i was filling on a none equal colorbackground, So i’ve tried to build a scrach bmd in order to build the triangle, fill it… then use the result as a mask by using a channelswap system. The result was perfect, except for one detail: it was slow!

Back to the drawingboard! In the meanwhile the point, line renderers were ok. They have change
a bit since i’ve ported a Bresenham line code from c++ to as2 then as3. I’ve optimized some lines but basically
it remains the same.

For the fill, i came across a class called Raster on the bytearray.org site. Unfortunatly the code had some
unexpected behaviors when “abused” in 3D. I say abused, because i use a part of the class on a way that was not intended. In 3D you also come across situations where the drie vertices are arranged in a way that its almost never an issue in 2D and i think that why the artifacts are still in the original class. So i’ve rewrote a part of the code to make it 3dable! I had contact with Didier Brun, who wrote the first version of the algorithm. But i could help me on this… he just got married! Didier: sinceres felicitations! Let’s hope that after the honey moon, he will have time to look at it with me.

I’am currently working on the same fixes on the big sister of the algorithm for the image renderer.
But, one thing is sure, the renderer draws quicker than using the lineTo or beginFill of the Flash API.
Let’s see if the image renderer gives me a custom beginBitmapFill.

Here a little demo the 3 renderers in raster format.
(the model is loaded from a .3ds file found here

renderer raster

Flash 3D: what’s the challenge?

Flash

Since we cannot ask the hardware for help. We must do it with triangles.
Papervision, Sandy and SWFZ or Away3D, they all use the movieclip approach.
Why? Because of the beginbitmapfill method that gives you an already masked triangle.
That I go for bitmapdata seams at first sight suicidal, specially with the hype arround PV and
the cool demos. But I do beleive that 3D is one thing, creating nice imagery another one if not more important.
Right now, everybody wants a spinning cube with video playing on it or build another clone of the iTunes album browser… And that’s where I think working bitmapdata has more to offer than movieclips.

But first I have to pay the price of not having the magical beginbitmapfill method for me.

The reel challenge for 3D in flash is to be able to transform images and apply color influences at runtime. The more triangles are drawn fast, the beter. But wait a moment, technics like Gouraud shading, aren’t made to smooth surface with a lower polygoncount, Phong is not that methode that calculate light influence at pixel level? Tell me now, is it now so stupid to think that nice shading are easyer achieved with bitmapdata??

ok.. but I’am are not there yet!

Look at this little demo, i’ve wrote it in AS2 a year ago, it demonstrate the movieclip beginbitmapfill and the way i was rendering the bitmapdata back then. Its a good way to see what’s really happening in all thiose engines, just to understand the challenge.

beginbitmapfill

As you can see, the way i was rendering was really expensive. i needed to copy the source bitmapdata, transform it, so far so good, but i needed a mask, so i had to draw a mask really fast then add it the the alpha channel of the resulted bmd then add to the render queue.

the first way i’ve found then to draw a triangle filled to generate the alpha channel was to first look for a way to draw lines in bitmapdata. Here again, mister Macromedia says: you’re on your own! Ok, so i wrote my own drawing bitmapdata API, based on Bresenham’s line algorithm, famous for its ability to draw pixel lines very fast.
Ok so i draw 3 lines, used the floodfill, and set the alpha channel.
then, i thought, wouldn’t it be nice, to draw them once and transform them as wel. It was faster, but
i could get a nice mask. 6 version of the renderer later, i finally found a good way to achieve what i’am looking for: a way to copy a source, apply a transform, draw a mask and apply a colortransform or go for pixel loop.
Without masks! The trick is to draw as a scanline, then you have your triangle.

This time i’am even with the beginBitmapFill, and i can soon be able to be even faster than this methode when it wil come to add those nice color influences.

check this latest demo on the code.
The image above is the class without transform, the latest version of the class, with transform.

beginbitmapfill

There are not much unknow Flash capabilities over now, and i think i’ve found a good but very challenging one!
You’ll now probably understand why i do not have much sleep lately…

2D animated sprites in 3D

Flash

One example how 2D animated elements are rendered. The engine has its own animator.
Each 2D sprite (got the name from Director before it was used in AS3)
can be set in system has 2D, 3D or 2D in 3D.

The animation is generated at init from library movieclips or external files
and save internally as a sort strip bitmapdata, A sort of a cell generator keeps
the cell count, even if information of the source is being flipped, rescaled or shared with other sprites.
The internal “animator” plays the cells like the flash timeline, but also options such as play once, reverse, loop and reverse etc.. events on cycle, sequenses changes within the same animated sprite are possible.

in fact this part of the engine was the reason i’ve started writing. i wanted to animate bitmapdatas on screen
en let the engine show the right image at the right place in 2D. I will post soon examples of the 2D capabilities.

here a little demo

2D animated bmd in 3D

Webcam feed as a texture

Flash

This was a logical following of the flv texturing.
This time i’ve used a sphere primitive, but it could be anything.

To be honest, to have a good fps rate, the model should be very low on polygons.
Because the bitmapdata source needs to be drawn on each iteration.

Wouldn’t it be fun to see a user driving a 3D car in a game or let him choose clothes with his own body?
Could be a new form of avatar for a user profile… i can think hundreds of possibilities here!

wanna see a spherical you?

webcam texturing demo

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in