Is it possible to accelerate even more Google maps for Flash with Stage 3D hardrware acceleration? - actionscript-3

I am using Google Flash API for Flash and so far it is working more than great.
Anyway I wish to increase it's drawing performance using Stage 3D hardware acceleration.
Is it possible to force hardware acceleration using Stage 3D with Google Maps API for Flash ?

It's not possible to force Stage3D acceleration on any existing content.
Apps need to be built specifically for the GPU using the Stage3D API's directly or working on top of a framework. Geometry is composed of triangles defined by a series of vertices, these vertices are essentially colored and assembled by shaders written in AS3's shader assembly language AGAL. Vector content cannot be rendered on the GPU, everything is bitmap based.
This is a great post on how Stage3D is implemented: http://www.adobe.com/devnet/flashplayer/articles/how-stage3d-works.html
Also as RIAstar mentioned, the Google maps Flash API is deprecated. Mapquest has a Flash API that might be worth checking out. I'm not sure how the performance compares since it is not a Stage3D app either.
http://developer.mapquest.com/web/products/featured/as3-flex-flash

YCanvas is an open source 2D tile renderer library written in ActionScript 3. It provides high performance solution for rendering world maps. The library also contains Stage3D (GPU) accelerated implementation based on Starling.
ApplicationMap - YCanvasMap implementation with Feathers UI available on (available tiles: ArcGIS Imagery, ArcGIS National Geographic, MapQuest, OpenStreetMap, MapBox, CloudMade, Bing Maps Imagery)

Related

Using 3D in Google Maps

I would like to create a webapp where I can display my own geotiffs, with NDVI and other data layers, as well as 3D geometries, providing a seamless rendering of both 2D tiles and textured 3D shapes, exactly like maps.google.com achieves in switching from "map" to "earth" views.
After much research, the closest I came to a viable solution is to build the infrastructure from the ground up based on http://cesiumjs.org/, and while this seems doable, it is extremely low level, and will require an exotic cocktail of libraries and a buttload of man-hours.
Before going down that road, I want to make sure there isn't a cost effective alternative that takes all the heavy lifting out of my app's shoulders and gives me a friendly set of APIs to base my app on.
Mapbox comes close to perfection in this regard, but unfortunately, it only handles 2D.
On the other hand, on the Google side, amid Earth API and Maps Engine deprecation, it's hard to tell what exactly is currently possible and will remain available long term.
Bottom line, for a future-proof Google-centric solution built today, are there Google APIs in place that allow building a webapp that displays custom 2D and 3D data with a seamless rendering experience?
https://cesiumjs.org/ is a library very similar to google maps that provides support for 3d shapes on top of maps.

Zoom is smoother on maps.google.com than on Google Maps API v3

I have noticed that the zoom on maps.google.com behaves differently (read: smoother) than my custom map using version 3 of the google maps api. I later found out that this also applies to the demo from Google here.
Is there a way to get the same smooth zoom feeling on maps using the Google Maps API v3?
I've been trying to search around the net for a solution, but all I can find is people asking how to do zoom animations, which is not what I'm looking for.
The native Google Maps site maps.google.com uses the HTML5 canvas element for rendering maps. The Google Maps API v3 does not. It is currently (as of late 2015) not possible to get the smooth continuous zoom behavior using the Google Maps API.
After searching Google docs and the web for answers without results, I took some time to understand how the API v3 and how maps.google.com basically work to render and display maps. There's one major difference that makes immediately clear why a continuous zoom won't work using the API:
Google Maps API v3 creates a map made of image tiles each rendered into single <div /> containers with a fixed default size of 256 x 256 px. When switching the zoom level every single tile has to be re-rendered with a new image (of whatever type, possibly dynamically styled with custom overlays and so on). This is a very expensive task, so every additional zoom step adds extra resources to be loaded and extra computation costs for re-rendering the whole scene via DOM manipulation. A fluid zoom experience is nearly impossible, even with modern browsers on high CPU/memory machines.
maps.google.com uses the HTML5 canvas object for rendering map scenes (I'm pretty sure there's a API v3 style fallback variant for old browsers). Drawing in a natively supported canvas object is way less expensive than replacing images in DOM elements. Google uses a vector graphics based approach which basically allows to do a continuous zoom into detail without the need to fetch additional resources. Additionally needed information for a specific zoom level though could be fetched as smaller chunks of data and applied to the drawing routines.
I must admit that I don't know how this works in detail. It's just what I discovered by inspecting the source and I hope it pretty much sums up why a "smooth zoom" is currently not possible using the maps API. Anyway, let's look forward to the Google Maps API v4!
There are other JavaScript mapping libraries that allow for smooth zooming, such as Mapbox-GL and Cesium. They both use WebGL, just like maps.google.com.
https://www.mapbox.com/mapbox-gl-js/example/fitbounds/
https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Camera.html&label=Showcases
I think it now depends on whether Google Maps is in Lite Mode, which seems to be their name for the old-school, image tile-based maps, as opposed to the canvas-based maps.
According to Google Maps' documentation for System and Browser requirements, Maps will disable 3D for certain video cards, and for some video cards, it goes beyond that and only lets you use Lite Mode.

Taking advantage of Flash hardware acceleration

My goal is to test Flash 3D environment performance by generating lots of 3D cubes, rotating them and reading FPS.
I know that I can rotate 2D objects in 3D space. For example, I can construct a cube with 6 movie clips, rotating them and putting them together accordingly. Then I can generate lots of these cubes in random x,y,z locations (predefined area in front of viewport), rotate them and read fps.
But then I read about this hardware acceleration and it's unclear to me, when it is activated/used. Certain conditions must be met. I know that it must be allowed by the user (right click->settings->enable hardware acceleration) or if it is embedded through object tag, wmode=direct must be set.
That's from viewers side, but what from developers?
If I draw a simple red rectangle on stage, and user has enabled hardware acceleration, does that mean that graphic information will get rendered on GPU?
I'm reading various sources and "Adobe Flash 11 Stage3D Game Programming" book, and from what I gather, in order to render graphical information on GPU, I have to explicitly call Stage3D class in AS3, then I can draw my 2d/3d objects there.
Which is it - if I want my app to be run in hardware acceleration mode (and its enabled from viewers side), does it happen automatically no matter what the content in my flash file? Or do I have to add the Stage3D class there.
Thank you.
Will be waiting for the answer.
First off: Don't mix up 2 distinct concepts in Flash:
General Hardware Acceleration
This was introduced mainly for video playback in Flash Player 10. I am not sure if it used for graphics at all. It has nothing to do with rendering 3D Graphics directly on the GPU.
GPU Support
With Flash Player 11, Adobe introduced Stage3D. This is an interface through which Flash can render graphics utilizing the GPU, if available. On Windows it uses Direct3D, on Mac OpenGl. The classic Flash DisplayList Graphics API does not support this. You have to go through the Stage3D Api, as explained in the book you have mentioned. To use GPU Support in the browser the embed tag needs the attribute wmode set to "direct". Working directly with the Stage3D Api is not easy and you have to learn the concepts of 3D Programming, Shader Programming, etc. for doing this. There are some libraries which help working with Stage3D. For 3D there is i.e Away3D. If you just need 2D graphics with gpu support, Starling is a very popular framework these days.
Here's a function that converts a movieclip into a bitmap. I use normal flash to create what is going to be shown on screen, then convert the movieclips to bitmaps and delete the movieclips:
private function fConvertClip(pClip: MovieClip, pWidth: int, pHeight: int): Bitmap {
var bd: BitmapData = new BitmapData(pWidth, pHeight, true, 0x00000000);
bd.draw(pClip, null, null, null, null, true);
aBitmaps.push(bd);
var bmp: Bitmap = new Bitmap(bd, "auto", false);
bmp.smoothing = true;
return bmp;
}
Don't turn on the hardware acceleration setting. In general, you control what's on the gpu with code. Bitmapdata is on the gpu so you convert everything that goes on the screen to bitmaps.
gotoandlearn.com has great tutorial videos on this.
You can create anything in normal flash - shapes, gradients, dropshadows, dynamic text, programmed coloring, etc. - and convert it all to bitmaps with programming while your game is running. You don't need to import images/spritesheets/animations. Have artists give you everything in vector. So when the user wants to change the color of a car, you simply convert the code instead of loading/importing a bitmap of the car in red.

What does Chrome use for accelerated 2D vector graphics in its HTML5 canvas draw functions?

So i would like to do things like what is possible with a HW accelerated HTML5 canvas for animated 2D vector graphics drawing, but on top of my OpenGL (4.x) rendered 3D scene (for complex HUD and GUI displays). I need this to be able to work on Win7+, MacOs, and Linux, mobile platform support is not needed.
BTW I am working with C++.
I was wondering if anyone knew what for example Chrome uses for accelerated 2D vector graphics in its HTML5 canvas draw functions? I was under the impression it was accelerated using ANGLE (which wraps OpenGL or DX9). Or am I wrong and its only SVG rendering that is accelerated, not the javascript canvas draw functions.
Doing HTML5 canvas style animated 2D vector graphics with OpenGL is highly non-trivial, is Google using an available library for that or is it just in-house code?
I have been looking into OpenVG and have had a hard time finding the right implementation to use for that, so far the only thing i can actually get examples compiled for is ShivaVG (but there seems to be shimmering artifacts for the tiger demo and other issues for the latest release 7 years ago). Also i think ShivaVG is using fixed function and my team decide to lock down our OpenGL usage to 4.x core profile, so that won't work. I would love to use NV_Path_Rendering but its not portable (to anything other than a nvidia accelerated device).
I also thought using OpenVG would be useful since I might be able to hide NV_Path underneath, or a new OpenVG library that might come out in the future. But I am wondering if OpenVG's future might be in peril.
They apparently use the Skia library for all 2D rendering.

as3 Why use starling for games on Android and IOS devices?

I have a nice setup where I publish, compile, design, etc. in Flash Pro CS5.5 and write as3 code (and some xml) in Sulbime Text 2.
Being forced to import each image or generate a sprite sheet seems like a such a hassle for nothing.
My apk apps work fine use mouse events, so what's the point in switching to starling?
I can answer you with 3 letters FPS.
You are getting a big boost in performance as you are working with law level API of Adobe Stage3D. And you do not need to worry about how to handle it because starling is warping it for you with nice 2D game Engine.
I suggest you to work with Starling for core game development and Gazman SDK for UI.
How ever there is one problem with starling. It does not have native support for vectors, so scaling could be a problem in many cases, spatially when building android application that you want to support in many screen resolutions. You can read this post about starling solution for that problem.