-
Displacement filter cpu usage problem
Hi, i'm using the displacement filter to create a magnify glass effect on my image.
Using similar code to the example from adobe found at:
http://livedocs.adobe.com/flex/3/htm...bjects_18.html
Using adobes example uses about 22% of my cpu. (Pentium 4 3.4 ghz)
The image im using the effect on is quite large at over 1000 px * 1000 px and layer masking is involved so this pushes cpu usage up to 85%.
However, i have code which moves the magnified image and the magnifier at the same time and this way cpu usage is simply too high and it stutters.
Does anyone know how I can reduce the cpu usage used by the displacement filter?
This is a snippet of my code:
Code:
var filterX:Number = houseBig.mouseX; //(houseBig.mouseY) - (map.width / 2);
var filterY:Number = houseBig.mouseY; //(houseBig.mouseY) - (map.height / 2);
var xyFilter:DisplacementMapFilter = new DisplacementMapFilter();
the code below inside a function which has to be repeated
filterX = (magnify.x) - (houseBig.x) ;
filterY = (magnify.y) - (houseBig.y) ;
var pt = new Point(filterX, filterY);
mapBitmap.x = mouseX;
mapBitmap.y = mouseY;
xyFilter.mapBitmap = map;
xyFilter.mapPoint = pt;
// The red in the map image will control x displacement.
xyFilter.componentX = BitmapDataChannel.RED;
// The blue in the map image will control y displacement.
xyFilter.componentY = BitmapDataChannel.BLUE;
xyFilter.scaleX = 25; //MANIFY STRENGTH
xyFilter.scaleY = 25; //MANIFY STRENGTH
xyFilter.mode = DisplacementMapFilterMode.IGNORE;
houseBig.filters = [xyFilter];
I just want to reposition the filter more efficiently when this code repeats and the houseBig variables have changed.
Thanks, Phil
-
is the full 1000x1000px viewable? if not try using a mask to render only the viewable area
-
Yea dude, displacement in any form of computer graphics is CPU intensive. I would go with the mask technique. Much easier on the 'puter.
I (Love | Hate) Flash.
----
Save a version back so others may help you!
-
Thanks for help. Thing is, as im using this for a magnifying glass effect, only a small area of the image is visible anyway. Ive tried adding another mask of the whole stage using:
houseBig.mask = stageMask;
However this removes my displacement filter effect.
Last edited by phil7; 01-08-2010 at 07:06 AM.
-
Keep in mind also that, unless you're creating this for educational purposes, if you distribute, people are going to be on everything from netbooks to workstations. If a 3.4 is being pushed to 85%, no way a dinky netbook/laptop will be able to use it gracefully.
My advice is to scrap the displacement idea. It's just too expensive, especially with interactivity.
I (Love | Hate) Flash.
----
Save a version back so others may help you!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|