Skip to content

Flash11 Session Sneak Peak

The Session

Here is Sneak peek of my session “Next-generation games using Stage3D(Molehill)” at Adobe MAX

My friend [Jean-Philippe Doiron] and I will introduce multiple techniques such as deferred lighting, CascadeShadow Mapping, ScreenSpace Ambient occlusion, MRT, and more through vertex and fragment shaders. We will also show new ways of handling Physics, particles and pathfinding.

It’s a deep dive into GPU/CPU programming with the new Flash Player, and discover how to produce beautiful GPU effects that are reusable in your games and applications.

Please take a look at some of the things we are about to show you at the MAX!

Video Sneak Peak

The videos are in HD, watch them in full res!

Please register at AdobeMax and join the session : http://bit.ly/odwg8U

We will also do a session on Flash3D at GDC Online if you can come: http://twb.io/n5rXxy

See you all there!

Massive 3D Particle System in Flash Molehill

Evolution of Molehill

I’ve been working on Molehill for more than a year now.

Since the very first iteration, to what we have now… wow there was a huge evolution.

  • Evolution (countless changes) in the API and features
  • Evolution in performances
  • And a lot of evolution in the community.
I have never seen such a great group of people working at the same time on a pre-release, in all possible application of the tech.
Still! When I look at the demos out there today, there is not much!
You can take a look at “The big list” by Lee Brimelow

An old thread

can you remember the debate about PixelBender vs pure AS3 vs haxe?
Let me help you remember! There was a nice attempt by a lot of people on the net to do a massive particle system with flash.
A lot of comparison have been done between different way by the “masters”, and to honor theses efforts, I tought I’de make something with Molehill out of this old thread.

PixelBender+Alchemy option (by Ralph Hauwert)
http://www.unitzeroone.com/blog/2009/03/18/flash-10-massive-amounts-of-3d-particles-with-alchemy-source-included/
Pure AS3 option (by Joa Ebert)
http://blog.joa-ebert.com/2009/04/03/massive-amounts-of-3d-particles-without-alchemy-and-pixelbender/

haXe:
http://webr3.org/blog/haxe/flash-10-massive-amounts-of-3d-particles-with-haxe/
 

Revamping an old post

It’s always fun to play with particle system when using a new tech.

Today I’m presenting to you one of the very first proof of concept I made with molehill, using a technique we developed at Frima Studio. (Already one year ago!)

So I went in my archive and fixed all the API changes that were made since then.

There was also an old blog post going with it that I never released due to the “to early stage” of molehill pre-release, and the technological advantage of open-sourcing such as technique.

But since then there was a lot of development… First the presentation at Adobe Max 2010 of the  ZombieTycoon trailer, Then The featured release of a couple of Zombie Tycoon levels, the  session at Flash Gaming Summit 2011 and the session for the San Flashisco user group. And internally at frima, the tech never stopped to grow!

We are going to present at Adobe Max 2011.  I’m sure it’s going to be awesome this year (again!).

The Particle System

This is a very simple particle system.
The particle position are defined using a classic “Strange attractor” algorithm.
Each particle is made with a quad and  is facing the camera (Billboard)

Batching

THE most important thing when doing a particle system is to have a good batching process.
Particles are often in very high numbers, and they must be drawable in batch to keep the performances high enough.

When we first started thinking about it, it was pretty obvious that to create something nice with billboards, we would have to transform each quad to make it face the screen (Transform by the Inverse ViewProjMatrix).  While this might sound obvious and simple to do, when processing the vertex in a vertex shader that process them one by one with no index or whatsoever defining what corners we are processing, it’s not “that” obvious!

The problem

The transformation needed on the four corners of your quad is not the same! but you can only define “one way” of doing things in your shader. (No if statement). Hence, if you can’t differentiate what you are processing, how can you make the good transformation to each vertex??

After a couple iteration where the CPU was doing the matrix transformation and re-uploaded each position each frame… We went in another direction. (It was WAY to heavy!)

The vertex shader let you define constant that you can access within the shader. Sadly, you have only 128 Float4 of theses.
So no real way of “batching” large amount of particles by making a list of transformation for each vertex. The best you could do is a couple of dynamic particle at the same time.

The trick

Read more…

ZombieTycoon & Molehill Session at FlashGamingSummit

I, Speaker

This weekend I was a speaker in a conference for the very first time.

And then, monday at this one

I must say, it was damn exiting. Event more when it’s to talk about the very first game using the a technology that people has waited for years.

Adobe has even used our project as the featured  game using Molehill for it’s official beta release.

The session was shared between Luc beaulieu (CTO) and me, both representing Frima Studio.

My session was about many techniques we used to create ZombieTyccon and how we managed to work with the limitations defined in Molehill.

I though it could be great to share this to everyone.

The session

download the Slides (powerpoint)

The videos

Read more…

Flash Network Profiler – What are YOU downloading?

FlashPreloadProfiler RC2

Loaders Profiler

This time, it’s all about loading files.
This new profiler show you every file being loaded using

    – flash.display.Loader
    – flash.net.URLStream
    – flash.net.URLLoader

The profiling is simple, it’s going to show:

    – Current download progress
    – HTTP Status
    – File Size
    – File Url (for every display Loaders, and URLStream with IOError)

You can copy to clipboard the URL or the Errors with the left side icons.
You can also save the whole list of downloads with a “save all” option

You don’t have access to:

    – URL of display loader while it being downloaded.
    – URL of URLStream and URLLoader when download is succesful

Configs

There are now real “options” in the profiler.
You can decide to turn On and Off most of the feature so that they are not processed when you don’t need them.
You can also decide to launch the profilers you want “in the baclground” before the profiled SWF is started so that you don’t miss any information.
This new feature let you browse between tabs without loosing the data in each one.

You can also activate DeMonsterDebugger in the new Config Panel.

Project Integration

Did you have trouble with the mm.cfg file? You (like many others) were not able to use the profiler? This time is over.
There is now a SWC in the download section that you can include in your project.
The only thing you have to do is

this.stage.addChild(new FlashPreloadProfiler());

That’s it!

 

Video

Like the last time, I made a video of the new features:

So what’s the next step?
Until Molehill arrive officialy, I guess it’s going to be NetStream and Sockets.

FlashPreloadProfiler Project home page

If you find bugs, please submit them in the google code project, or let me know with comments here.

Have a nie and optimized day.

 

Complete Flash Profiler – It’s getting serious!

There was the first version, that wasn’t even looking like a profiler..
Then there was FlashPreloadProfiler Alpha and Beta..
But often I had to fallback on Flex Profiler to do the Performance Profiling.

Here is the first version that should be considered as a “fully qualified Flash AS3 profiler”.

Here is FlashPreloadProfiler RC1!

It has the basic features:
-Memory profiling
-Function Performance profiling (New!)
-Convivial UI (New!)

And it has the unique features:
-Overdraw graph
-Mouse Listeners graph
-Internal events graph
-DisplayObject Lifecycle graph
-Full Sampler recording “dump”
-Memory allocation/collection “dump” (New!)
-Function Performance “dump” (New!)
-Auto-Integration with De MonsterDebugger
-Run on debug/release SWFs

I can now officialy say that I don’t need any other tool anymore to optimize standard AS3 code. (Discussion on Molehill (Flash 3D) optimization will come soon!!)

There is a LOT of optimization that has been done in the profiler itself.
But the real new features are the new UI with ToolTips and lot’s of feedback. Plus the whole Function Performance profiling tool. There was also a lot of fixes in the code.

Here is the PerformanceMonitor screen:

This time, I’ve also made a full video of me explaining what the tool is all about and how to use it!
The video quality is very bad and I’m going to upload a better version really soon. Sorry!

Again, comments are very very welcome! You can post them on the google code project or right here on my blog.

If you want to participate, please send me a mail!
If you want to contribute financialy, there is a link on the profiler page and on the google code page.

Funny fact:
While developping the profiler, I ran Flash CS5 without removing the profiler first…
And I knew that FlashIDE was running SWF inside the main interface.. But to see that one of the main components was using some GrantSkinner library, that was just plain hillarious! Go check it out!

Reference:
FlashPreloadProfiler project

Finally! We can talk about Molehill! (GPU-3D in Flash)

I’ve been in the Molehill Prerelease program for a few months now.
Today I am proudly showing you what’s Molehill all about.

When people are complaining about developing game in Flash, most of the time it drills down to two main arguments:
1: No hardware acceleration
2: Bad resources management

Well it’s almost over! People will have to find other reasons!

The new Flash 3D H.A – Codename: Molehill

As I’m sure you already know it, Adobe just announced our new toy: Molehill.
A new Flash Player supporting 3D Graphics with Hardware Acceleration and a brand new 3D API with a better resources management system.
Needless to say, it’s a web gaming revolution. Better, it’s not only for the web, but also for mobile platforms!

Technically, “Molehill” is a set of programmable shader-based 3D APIs, exposing features like z-buffering, stencil color buffer, fragment and vertex shaders, cube textures and more. “Molehill” will enable developers to leverage the GPU where possible, while providing the flexibility to fallback to a CPU software rasterizer if the hardware is incompatible.

Today, Adobe Flash Player 10.1, renders thousands of non z-buffered triangles at approximately 30 Hz. With the new 3D APIs, developers can expect hundreds of thousands of z-buffered triangles to be rendered at HD resolution in full screen at around 60 Hz

There are many other solutions… is it?

I think Adobe didn’t have much choice to go that way. With WebGL, HTML5, Unity and the Apple war, they had to do something big.

  • HTML5 and WebGL: my guess is they won’t match flash games for many months / years.
  • Unity3D: I know they have quite a head start on 3D for the web, but really think that this move from Adobe will gain back a lot of developer that went for Unity for 3D.
  • As for the “Unity3D is not only a renderer, it’s also an editor”, the flash community is big VERY big and I’m sure there will be plenty of third party solutions to create Editors just like Unity3D.

    Adobe already announced:
    The 3D capabilities enabled by the new APIs will also be available to the broader developer community through popular ActionScript® 3D frameworks, such as Alternativa3D, Away3d, Flare3D, Sophie3D or Yogurt3D.

    Can you remember the time when flash didn’t support GPU-3D ?

    In may 2009, I was at the Login2009 conference in Seattle and there was a round table called “Barriers to entry: Is Flash the answer to Life, the Universe, and Everything?”
    Here is the description:
    Is Flash, the most blessed and holy of all browser plug-ins, our only hope for eliminating the most deadly barriers to entry for online games?
    If your game requires a browser plug-in or downloading and installing an application, do you stay awake at night worrying about how many players will never install your game and thus will never get to the “fun” part?
    Is there anything we can do? Are there any solutions on the horizon that will work in every browser without installing additional plug-ins? Can Flash deliver the kind of high-end content our tools will let us create? What about Flash-based technologies like PaperVision3D? Are we going to get help from the developers of the major browsers?

    It was kinda funny back then because most game developers were saying that the only real solution “for high-end content” at that time was to go with Unity3D. And the big question was “If Adobe ever introduce 3D HA to the Flash player, would you choose Unity or flash to create 3D games?”
    The real answer was never given because there was always somebody to say “Yeah but Adobe won’t do it (3D with HA)! They move SOOO slowly.”
    Now that this is coming, I’m smiling just thinking back of that discussion 🙂

    My part in this

    I’ve worked intensively with Flash for a few years now and I’ve followed the flash scene closely all that time.
    The engineer working on the project are releasing good builds, fixing bugs entered by the Prerelease community and adding feature very quickly. They are also doing very fast iteration and making sure the API is convenient and optimized with a lot of VERY experienced and qualified developer. I can honestly tell you that I’ve never seen Adobe making such good and fast development.
    Being a Prerelease community member, I’m giving a lot of feedback on performances and optimization that could be made and making sure that the current Flash 10.1 performance problems are part of the discussions.

    Game development using Molehill at Frima Studio

    I try not to talk about my “day job” too much in here to really keep things apart, but I think this time it worth bending the rule.

    Me, a good friend and colleague of mine (JP Doiron) and many other folks at Frima have worked on games prototypes using Molehill and we were able port a proprietary 3D engine and extend it to create a very nice demo for the Adobe Max presentation by Sebastian Marketsmueller (Flash Player engineer). In his presentation on Flash Player 3D Future today he showed a lot of cool stuff including our Zombie Tycoon demo.

    Official Video

    I strongly suggest you watch it in 720p!
    By the way, this is a special version just for you guys to see what kind of performance we can get (HiRes-Stats on top left corner)

    Check out the Official Frima Studio Page

    Tech

    This video shows many things:

  • Over 500 avatars (with full GPU-animation-skinning and multiple models, animations and textures sharing)
  • More than 500 000 polygons
  • Multiple sort of mapping: ShadowMap, LightMap, NormalMap, DetailMap
  • Dynamic Lighting: directional light and spotlight
  • Particles: Smoke, Fire, Rain, Bullets, Homing missile
  • Props
  • Special Effects
  • Animated Screen Image Overlay
  • Flocking (Boids) system for zombie movement
  • And the best thing: All of that in a 1280×1050 window at more than 30fps with practically zero memory allocation and very small usage of the CPU.

    I don’t know how this looks to you, but my feeling tells me there is going to be a LOT of new 3D MMOs browser base in the next months / years.
    Thanks for that Adobe!

    Compare!

  • In flash 10, having playable 3D game with this kind of graphics was very good:
  • Flash 10 Rendering

  • And now, here is what we can achieve with molehill (again, running at 30fps):
  • Flash Molehill Rendering

    Reference

    Molehill at Adobe Labs
    Frima Studio Zombie Tycoon Tech Demo running on Molehill

    Flash security: Protecting against PreloadSWF (SWF Hijacking)

    Finally! here is a half-answer.

    If you have read my last posts, you now know the power of Flash hijacking via preloadSWF.
    I never given a lot of feedback about how to block this attack because I didn’t know any.

    I’ll skip some step on how preloasSWF work, if you want to know please read my previous articles: One SWF to rule them all! and FlashPreloadProfiler
    And for those who didn’t knew yet, the last version of FlashDevlelop now support PreloadSWF easy integration for profiling your application with FlashPreloadProfiler!

    Case study

    The only thing happening before a SWF loaded (allComplete) callback is the constructor of that loaded SWF.
    This means it’s the only moment you have to “do something”

    Let’s suppose you have a project you want to keep the code from being: viewed, modified, copied.
    And let’s suppose you have some kind of classic setup:
    A obfuscated launcher, embedding an encrypted SWF containing the whole code base.
    In its constructor, the launcher create a key, that decrypt the embedded SWF and use loadBytes to instantiate it before adding it to the stage.

    The Basics

    The whole protection reside around one very simple flash behavior.
    When a SWF gets loaded, FP give a (incremental) name to the root object.
    The first one being loaded is called “root1” and then “root2” etc.
    This also applies to the preloaded SWF which is loaded first, hence is being named “root1”

    Read more…

    The only real Flash Builder Profiler alternative (and it’s free!)

    FlashPreloadProfiler

    (now in Beta) is an open source multi-purpose profiler designed to help productivity and stability during development by displaying under-the-hood data of any flash app.
    The main goal is to help expose and diagnose problems before they get too big.

    It enables developers, artists, designer and testers to see what sometimes “cannot be seen”, such as:

  • What is the current FPS and memory statistics and graph of a SWF
  • Where are all active MouseEvent listeners
  • What is the global scene overdraw
    • How many sprites are contained in the scene and how they overlap each others (including all “invisible” DisplayObject added as children)
  • What is the life cycle of all DisplayObjects on the Stage
    • Instanciation, AddedToStage, RemovedFromStage, Garbage Collection
  • Object instance statistics
  • Internal events frame division
  • Advantages (Over Flash Builder Profiler)

  • First, it’s free! So it costs $500 less than the Adobe profiler.
      If you like my work, you can donate at the bottom of this page
  • The profiler is very compact and don’t need any external tool. (under 80Ko!)
  • The data is showed in a transparent UI on top of the profiled application.
  • You have access to more profiling tools, such as:
    • Overdraw graph
      Mouse listeners graph
      Internal events time repartition
      Instanciation Statistics/StackTrace for all Objects (including Objects created and destroyed in a single frame, which FlashBuilder Profiler just can’t track)
      Save sampling “Data Dump” in the clipboard
      Can hook on ANY flash app, local or web, debug or release, yours or others.

    Take a look!

    Read more and try it!

    Freezing and unfreezing objects

    Wow.. It’s been a long time since my last post! But don’t worry there is a lot of things I plan to talk about.

    So let’s start with: Freezing and unfreezing objects

    *Erratum*
    When I made all my tests, they were builded into FlashCS3 (which only build Flash 9 SWF)

    And when playing the animations, it was really ugly.

    But when you build the same animation in Flash CS5 (Flash 10 SWF), the animation is really clean and have absolutly no object waiting for GC. which is GREAT.

    And if you start a SWF10 preloader and then load a SWF9 file? working great!

    And if you start a SWF9 preloader and then load a SWF10 file? Bad GC!

    So this post is still valid only if the first thing you run is a SWF9 animation in FP9/10/10.1
    *End erratum*

    Read more…

    jpauclair.net: 6 Months – Articles recap.

    For those who started reading only a few weeks or months ago, here is a recap of the technical articles of my blog:


    Tamarin Part I: AS3 Array

    private function InitializeArray() : void
    {
    var i:int = 0, myArray:Array = new Array();
    for (i = 0; i < 100000; i++) { myArray[i] = i; }
    }
    private function InitializeArrayBackward() : void
    {
    var i:int = 0, myArray:Array = new Array();
    for (i = 100000; i >=0; i--) { myArray[i] = i; }
    }
    

    When testing those two functions in GSkinner PerformanceTest, I get this:
    InitializeArray : 11 ms
    InitializeArrayBackward : 44 ms

    There is something very important to understand when using the Array class.
    If you read the Tamarin source code you will discover that Array is made of multiple things…

    Read more


    Tamarin part II – More on Array and Vector

    Start a flash app with

    var a:Vector.<int> = new Vector.<int>(1024 * 1024);
    

    Would result in a total memory use (System.totalMemory: including all the other junk)

    System.totalMemory = 7 311 360

    So now let’s fill this array

    var a:Vector.<int> = new Vector.<int>(1024 * 1024);
    for (var i:int = 0; i <= 1024 * 1024; i++) { a[i] = 0 }
    

    System.totalMemory = 8 364 032

    WHAT!! That’s a 1 052 652 bytes (1 Mo) hole! ouchh

    Read more


    Base64 Optimized as3 lib

    I went through both lib (as3Crypto and PHPRPC protocol) and optimized what I could in the base64 encoding/decoding. The final version is ~700% faster with almost no heap expansion compare to both libs.

    as3Crypto is currently adding the modified version to its core

    Read more


    Reverse engineering AMF3 Vector for Java

    Did you ever worked in AS3 with Byte Array and AMF data serialization for transferring object over network ? It really simplify everything. Of course there is a size overhead. But the bottom line is that we can save hundreds of hours by using it.
    Since Flash 10, there is one big flaw with AMF: it doesn’t support Vector. Well it’s not true, The FlashPlayer support it, but not what link to it. So you still can serialize Vector object in a byte array and save it in a file for example, but you can’t send it to a web page written in PHP or a server in Java because there is no implementation of those new « flash 10 features (Vector, Dictionary,…)» in the flex framework.

    Project Red5 (OSS Socket server) has used it to implement in their engine.

    Get around Flash documentation: Read more


    AS3 hidden treasure in the mm.cfg file. Revealing and documenting many Flash secrets!

    Very simple: 45 undocumented feature of Flash Player!

    Read all the secrets


    One SWF to rule them all : The Almighty PreloadSWF

    This is onw of the “almost hidden” feature of the mm.cfg
    Simply said, it enables you to load a SWF before any other running swf and manipulate any as3 online SWF .

    Read more


    Flash Assembler (not ByteCode) : And you thought it couldn’t get faster

    One of the hidden feature of the mm.cfg enables you to output flash JIT-generated assembler to a file.
    Here is how to use it for optimization.

    Read more


    Flash Preload Profiler

    Using one of the hidden mm.cfg features again to show how powerful the preloadSWF is.
    This “Flash preload Profiler” is a multi-purpose profiler that enables you to diagnose visual performance problems before they get too big.

    Read more


    What’s in the next 6 months?

  • Flash 10.1 is almost released… I guess there is plenty of stuff to discover there!
  • Flash on mobile platform is very interesting and there is so much that could be done in that sector. It opens a whole new interactivity level. I want to be a part of that!
  • %d bloggers like this: