views:

218

answers:

2

Why would bitmap outperform vector?

My Flash is for a large Kiosk, with rich media requirements and must function accurately as a counter. I want to keep everything vector for scalability.

When I did a simple FPS test, I noticed my Bitmap version performed perfectly, and the all vector file was noticeably slower.

PLEASE EXPLAIN
• vector performance
• what graphic standards I can apply
• solutions for using vector


KIOSK TEST ANIMATION
alt text


RESULTS
• only text and bitmap perform well, not vector
• background and clouds OK, but more layers slow it down

+6  A: 

Its really quite logical when you get your head around what a vector is.

A vector is a visual representation of the computer plotting many points on the screen and joining the dots and colouring it in. This is a the reason why vectors look good scaled up as well as down.

A bitmap as your probably aware - in flash is regarded as pixel data. Something thats just picture stuff.

When the screen renderers vectors, at every screen redraw it must plot and map and recreate the vector - each time working it out. With bitmap, - well, its a picture and therefore saves all that computing power trying to redraw complicated objects and plot 100's of points.

You caching everything as vector, you will not notice a difference in the slighest. Anything you've drawn on the stage - check the 'cache as bitmap' checkbox, and any new item produced in the code and added as a child, cacheAsBitmap = true on every visual thing.

There is a great little trick that should work a treat here.

You can still use your vectors. However, when adding them to your stage, check the 'cache as bitmap' checkbox underneath the display settings in the properties panel.

in the code you can write

myCloud.cacheAsBitmap = true

That property is available for every visual object.

This works best when the objects you have on the stage are doing simple things like spinning and fading - it tends to not be as effecient when performing movieclip nested animations and similar stuff, as of course, the object will still need to be redrawn at every frame. Although you will still see a big improvement.


here are some urls on the from googling 'as3 cache as bitmap'

http://www.adobe.com/devnet/flash/articles/bitmap_caching_03.html

live docs for displayObject - you'll see it 3 down in the first table.

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObject.html

Glycerine
only set cacheAsBitmap to true when the Sprite does NOT rotate, continually scale or have alpha set to < 1 otherwise the image has to be recached each time there is a change which is costly.
Allan
@Allan This is an important point, often overlooked. When you transform a graphic object (expect for x or y translation), the cached bitmap is no longer valid and has to be recalculated. If you're changing your graphic, say, every frame (or very often, as vague as that is), cacheAsBitmap will make things worse, not better.
Juan Pablo Califano
Don't attempt to use the advice in this answer without noting Allan's comment!
fenomas
Have you got a reference so I can read up on this? I've always kinda experienced the opposite.
Glycerine
@Glycerine, thanks. CasheAsBitmap gave my vector animation full performance. For moving things across the stage 'without' alpha or scaling, I know it works great.
VideoDnd
No problemo! - I'm still pushing for the proof of a perfomance drop if the cached object isn't static but as long as you fixed your problem the world is a happier place. And its sunny in Glasgow today! Wonderful world it is.
Glycerine
A: 

Question 1: What if your vector MC doesn't rotate but it's parent MC does rotate?
e.g. Imagine an MC called 'world' which is circular and rotates on screen.
Now imagine that this 'world' MC has other MCs inside it such as an 'elephant' MC and a 'volcano' MC (which in terms of appearance - sit on the surface of the world). The 'elephant' and the 'volcano' only rotate because their parent ('world') rotates.

Should we use 'runtime bitmap caching' on the 'elephant' MC and the 'volcano' MC?

Question 2: Imagine the SWF is 10K (when the world MC is a vector). If we create the 'world' MC using an imported graphic from photoshop say, and use that graphic instead of a vector inside 'world' MC then the SWF could become much larger (say 100K for example) because of the file-size of the new imported graphic.

Given that our 'world' MC rotates on screen, is it better to have a larger SWF size (due to use of BMPs instead of vectors inside our world MC) or is it better to use a vectors for our 'world' MC despite the performance hit in rotating a complex vector MC?

James
you should repost this as a separate question, not as an answer to an old question.
grapefrukt