AS3 Displacement Map Filter doesn't work on Mobile?

7 posts (showing 1-7)

Market Level 0Community Level 2
110 posts

As in the title. I recently modified a project to be played on Mobile. The project uses the DisplacementMapFilter for transitions between scenes. Tests on normal .swf export work fine. However it doesn't appear to work at all when I export to .apk and test on android. The scene alpha fade into the other, as part of the transition. So I know the code is running and working. However the images are not being displaced. Is this a known thing? Or is something else going on?

posted 2015-05-18T00:06:23-07:00

Market Level 3Community Level 10
2192 posts

According to this:

Shader support on mobile is 'Limited'. You may have just found out how limited.

For mobile you get better performance anyway with 3D, i.e. Stage3D rather than 2D, or with Starling that reproduces the Flash 2D API on top of Stage3D. Starling also includes its own DisplacementMapFilter

posted 2015-05-19T01:58:52-07:00

Market Level 0Community Level 2
110 posts

Intresting but I haven't heard the DisplacementMap being called a Shader. Also on this page:

a quarter down "Conceptually, Flash Player or AIR goes through the pixels of the filtered image one by one..."

So I would assume it means that the filter should be working. And I haven't found any search results that say it doesn't. So I'm at a loss.

I have looked into Starling, but in this case it's just a conversion project. It would be a huge time sink to remake the content. I guess I'll spend a day trying out different instances of the filter to figure it out.

posted 2015-05-19T03:23:04-07:00

Market Level 5Community Level 6
545 posts

Are you by any chance using the "GPU" rendering mode?
Filters do not work in GPU mode at all on mobile devices :/

You could switch to either CPU or Direct mode, and filters will work, but the performance might suffer.

posted 2015-05-19T03:53:53-07:00 | edited 2015-05-19T03:54:33-07:00

Market Level 0Community Level 2
110 posts

Wish I read that sooner. I tested all the rendering settings and that is exactly the issue.

Within the Publish Settings for Hardware Acceleration : None, Level 1 - Direct, Level 2 - GPU. all work depending on the following.

Within the Player Settings for Render Mode: AUTO and CPU work, while GPU doesn't.

If Auto runs GPU for everything other then this Filter in the entire project, I'm happy with that.

posted 2015-05-19T16:56:21-07:00

FGL AdminCommunity Level 4
321 posts

Unfortunately it doesn't quite work that way - Auto will either run in CPU or GPU mode (entirely), depending on the device and project settings. Basically in your case, Auto is the same as running in CPU mode. It's not possible to mix Software and Hardware (GPU) rendering in the way you describe - if you want the performance advantage of GPU mode, you'll unfortunately have to think of another way to implement the intended effect or go without it.

To get the best of both worlds you would probably be best looking into working with Stage3D. It's not a 'flip a switch and go' solution though; you'll need to rewrite a significant portion of your project in all likelihood. However, that would give you access to AGAL shaders (allowing you to implement the displacement map effect, and even have more control over it) as well as (generally) improved performance vs GPU mode.

Honestly, my suggestion would be to just replace those screen transitions with regular fade-in and fade-out transitions for the mobile version, and run GPU mode.

posted 2015-05-19T18:03:03-07:00 | edited 2015-05-19T18:04:19-07:00

Market Level 0Community Level 2
110 posts

The effect is indeed expensive... Even though the rest of the project runs fine in CPU mode, the transition itself could cause someone with a poorly optimized device to lag into oblivion and earn me some single star ratings. I'll be looking into Stage3D for following projects, and play around with some matrix effects as a mobile replacement.

Cheers for the info.

posted 2015-05-21T18:39:58-07:00