• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

cacheAsBitmapMatrix not working anymore?

Contributor ,
Feb 23, 2016 Feb 23, 2016

Copy link to clipboard

Copied

So, I used to think I had this working, but maybe I didn't.  I have a vector background that I want to cache for performance reasons.  My big issue is how to get my background image cached on iOS while still anti-aliasing it.

If I do the following, I take no hit on the Display List in Scout, but the image is aliased:

bg.cacheAsBitmap = true;

bg.cacheAsBitmapMatrix = new Matrix();

It's pretty much the same effect as just having cacheAsBitmap on.

If I do the following, I take a 7% hit on the Display List in Scout, but I do get it anti-aliased:


var matrixOpt:Matrix= new Matrix();

matrixOpt.scale(2,2);

bg.cacheAsBitmapMatrix = matrixOpt;

bg.cacheAsBitmap = true;

That performance hit is barely better than if I didn't do anything to the movieclip.

Does anybody know how to do this properly?  I would love to use this feature.  But right now, I think i'm doing it wrong.

Thanks!

TOPICS
Development

Views

810

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 23, 2016 Feb 23, 2016

Copy link to clipboard

Copied

What render mode are you using, and what do you have stage quality set to?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 23, 2016 Feb 23, 2016

Copy link to clipboard

Copied

Thank you for the quick response. 

I'm in GPU mode. And I'm rendering at HIGH quality due to the other vector stuff I'm animating which I won't be caching.

Also, I'm noticing that my first scenario ( bg.cacheAsBitmap = true; bg.cacheAsBitmapMatrix = new Matrix(); ) is turning out like my second scenario after the playhead moves around on the timeline a bit, complete with the (desired) anti-aliasing and (undesired) performance hit.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 23, 2016 Feb 23, 2016

Copy link to clipboard

Copied

I am also getting similarly undesirable results from

bg.cacheAsBitmapMatrix = bg.transform.concatenatedMatrix;

bg.cacheAsBitmap = true;

Just to try to be thorough.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 23, 2016 Feb 23, 2016

Copy link to clipboard

Copied

In my first iOS app I did a lot of cacheasbitmap and cacheasbitmapmatrix, to try to help performance. But these days I don't use those at all, GPU mode does well enough on its own.

Are things vector to save file space? Using High for stage quality is the thing that will kill performance the most. Something you could try is to do your own creating of bitmaps. Make a bitmap that is located at the top left of where the vectors are, and do a drawwithquality of the vector symbol into the bitmap's bitmapdata. Read about that here:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#dra...

Drawing into the bitmap that way lets you create a bitmap from vectors as if the stage quality was set to high, but you can then set the stage quality to "low".

Setting the stage quality to "low" is likely to solve all performance and cashing issues.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 23, 2016 Feb 23, 2016

Copy link to clipboard

Copied

First off, thanks again for responding so fast. That is seriously helpful.

I'm using the vector stuff so I don't have to create a bunch of spritesheets and @2x @3x bitmaps for various resolutions. I'm also using shapetweens here and there as well as some frame-by-frame animation.  So I was really hoping I could just use a runtime caching solution speed up some of the bigger pieces that don't move.

Thank you so much for the tip on drawWithQuality()!  I had exhausted my google-fu and still had not found that. I will give that a try and report back (for posterity).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 23, 2016 Feb 23, 2016

Copy link to clipboard

Copied

But wait, there's more...

Why are you using spritesheets? Those would be used in Starling, which you're not using, and making your own masked areas with a spritesheet behind it doesn't perform so well.

Shape tweens will be an issue, if there's a long sequence of unique frames. Getting rid of cacheasbitmap, and living with whatever the performance of the shape tweens is, would help with memory. But I can see why that would need a higher stage quality.

So, find any other way possible to do the effect without the shape tweens.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 23, 2016 Feb 23, 2016

Copy link to clipboard

Copied

Oh, I'm not using spritesheets. I'm trying to avoid it. 

But I was under the impression that I could use them in the displayList somehow if I needed to.  Not the case? Doesn't dragonbones have something for that? I was considering using them for stuff like confetti and sparks for particle effects - stuff I'm not likely to change. You has better method?

And yeah, the shapeTween gives some good results that feel polished unique. I like that. But you are correct about the performance hit. Sometimes I convert them to keyframes. That helps slightly.

I'm still working with the drawWithQuality thing. I think that will get me where I need to go. I need to write in some scaling to account for different resolutions. I assume I apply that to the matrix.  We'll find out.

If this is the end of our thread, thank you so much! 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 23, 2016 Feb 23, 2016

Copy link to clipboard

Copied

Here's the deal.  If I use the cacheAsBitmap setting in the Flash Pro IDE, I get 60 fps.  I thought cacheAsBitmap was supposed to give me the same kid of performance and anti-aliasing.  Am I wrong?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 24, 2016 Feb 24, 2016

Copy link to clipboard

Copied

Aside from cashing the object as a bitmap, another thing it does is to force things on to pixel boundaries. That's where the bit performance gain is. That might indirectly make some things look like they're not antialiased, in movement for example, you won't get sub pixel placement.

What is the performance like if you remove all cacheasbimtap lines and check boxes?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 24, 2016 Feb 24, 2016

Copy link to clipboard

Copied

If I get rid of all the cacheasbitmap stuff, I'm getting 50-60 fps (on my iPhone4s). If I use cacheasbitmap (checkbox) on the background, I can get it to 60fps pretty consistently, which is nice.

It just seems like when I first implemented cacheAsBitmapMatrix years ago that it gave me the performance bump of cacheAsBitmap without the aliasing.

And I'd like to get it running smoothly, because I would love to implement some particle effects.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 24, 2016 Feb 24, 2016

Copy link to clipboard

Copied

cacheasbitmapmatrix is needed if you want the GPU to rotate the image, and I imagine it would have jaggy edges. You could make the image larger, so that at its normal size it's really a 50% scale. That could help with the edges. Also, having a feathered alpha transparent edge could disguise some of the jaggies.

60 fps isn't vital you know. You could do tests at 30 or 40 fps, and find that it's perfectly good enough.

Here's something I made:

http://www.amazon.com/gp/product/B00XO0A0GM

There is a Watch Video link, take a look. Some of the choppiness is just the screen recording not being perfect, I know better ways to do that now. The game is set to 60 fps, which does help some of the particle effects. You'll see some water particles in a few places. The game doesn't use cacheasbitmap or cacheasbitmapmatrix at all, and stage quality is set to "low".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 24, 2016 Feb 24, 2016

Copy link to clipboard

Copied

Thanks for sharing that! It's cool to see somebody else who's using Flash in the kids space.

Yeah, I know I don't *have* to have 60fps.  I'm just early in development now and I know the more I add, the slower it will get.  So if it's not 60fps now, it's going to be 20fps later.

The app we have in the AppStore now dials down the fps for older devices.  I think I will also add in some options to limit effects on older devices. 

Thanks for your help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 27, 2016 Feb 27, 2016

Copy link to clipboard

Copied

LATEST

honestly, cacheAsBitmap and matrix have never been the best solution. period. Old documents reccomended it but it always was worse performace than a bitmap. Its already been said, but draw any thything u need to bitmapdata w drawWithQuality high, set stage quality to low and depth to 16bit

with the bitmap you draw, u can have antialiased high quality and the option to dispose, and frame rate was better than cachasbitmap last I checked (which was a long time ago)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines