Promethe’s Blog Web, RIAs and chocolate spaghettis…

9Jun/109

Pixel shader demo using Flash 10, Pixel Bender and Minko

I'm really excited to announce Minko (which is, by the way, the final name for my 3D library) has reached a new level: pixel shader integration! Pixel shaders are little programs that run on each pixel and can modify their final color. They are often written in C-like languages and in this precise case we use Pixel Bender, the shader language introduced with Flash 10.

In this post I will:

  • Explain how any 3D scene is built when using Minko
  • Explain how pixel shaders are integrated in the 3D scene
  • Explain how pixel shaders are built using Pixel Bender
  • Show you a very simple demo of the kind of effects pixel shaders will provide
  • Explain how the demo was built

Here are a two screenshots to show the results:

Phong shading + spheric environment mapping on a 2700+ polygons Lamborghini

Phong shading + spheric environment mapping demo

Technical details and a live demo right after the jump!

9Apr/1016

Apple makes its own compiler… illegal!


"3.3.1 … Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited)."

This is the very bad (sad) addition (restriction) to the iPhone developers program everyone is talking about right now. And I feel very concerned about this... and now everyone is wondering if software like the Flash-to-iPhone packager, Mono or Unity are definitely banned from the iPhone programming tool-chain.

I never talked about it before, but Aerys is working on a project targeting the iPhone and the iPad (among a lot of other platforms). And this very project is leveraged by some home-made code generation tool. Therefore, we are very scared of what this kind of restrictions might imply for our business.

But as scary as this statement might look at first, it is actually even funnier when you understand it makes any iPhone/iPad application illegal. And it gets even better because even Apple's standard tool-chain finds itself... prohibited!

The reason is very simple: Objective-C, C or C++ never "link" to any library providing the Documented iPhone APIs. Objective-C, C or C++ actually never link to anything. When compiling your code, the compiler creates an intermediary representation of your program in order to make it easier to (eventually cross-)compile it. In the case of GCC, the compiler used to build such applications, those intermediary languages are:

(Source: Wikipedia - Intermediate language)

This very intermediate representation is built before the symbols resolution and before any linking is done. Thus, linking against the "Documented APIs" has always been done "through an intermediary translation or compatibility layer". And it won't change anytime soon! But, still, I wish good luck to Apple's engineers in their future work to patch GCC and make it "compliant" (sic!).

To me, it is the most obvious sign that Apple doesn't care about its developers (but I was still pretty thrilled to eventually become one of them about a few days ago...). Not because it bannishes any interesting cross-compiling software venture. And not even because any iPhone/iPad developper who knows about other platforms openness and ease of production will feel sick just by reading this kind of restrictions.

No. To me, Apple is losing it all simply because this kind of idiocy can only be written by someone who doesn't have a clue about how a computer/compiler works! Apple started building casual devices and ends up targeting casual developers. Could this be the first sign of how (so called) intuitiveness - when enforced by completely hermeticly closed devices - finally makes people... dumber? So now the real question is "What happens when your developers program EULA is written by a marketing control-freak moron?".

PS : The title of this article was desgined to attract the eye. It is my interpretation of the latest Apple's developers program EULA additions and I might be completely off or wrong. Anyway, the doubt and worry caused by this very fuzzy and unclear addition stands as a major issue for all the companies and developers targeting the iPhone and iPad platforms.

1Apr/100

AS3 Monitor released on Google Code

I just released a small but useful piece of software on Google Code: my ActionScript 3.0 Monitor class. This little class makes it possible to watch the properties of any object directly on the stage.

It was inspired by Mr. Doob's Stats class. But my Monitor class is entirely dynamic and you can watch any property of any object.

The following simple (and useless?) code sample show how to track the (x, y) position of the mouse cursor on the stage:

package
{
  import aerys.monitor.Monitor;
 
  import flash.display.Sprite;
 
  public class MonitorDemo extends Sprite
  {
    public function MonitorDemo()
    {
      var monitor : Monitor	= new Monitor(30);
 
      monitor.watch(stage, "mouseX", 0xff0000, 1. / stage.stageWidth);
      monitor.watch(stage, "mouseY", 0x008800, 1. / stage.stageHeight);
      addChild(monitor);
    }
  }
}

And here is the result:

Here is another simple use case: tracking the (x, y, z) rotation of a 3D camera (the actual application is available on the official Aerys website):

The code is open source and available on Google Code. Comments and suggestions would be greatly appreciated!

17Dec/090

AIR 2.0 HTTP Web Server

AIR 2.0 brings a lot of new features. Among them is the new ServerSocket class. The Socket class exists since Flash 9 and enabled a lot of new client/server applications. But it has always been limited to client side sockets as long as AIR (and the Flash Platform as a whole for that matter) is concerned. Therefor, this new server socket feature makes it possible to build actual server software using AIR!

Rich of this new and incredible ability, Christophe Coenraets posted a small but yet very powerful code snippet to build an HTTP web server using AIR 2.0!

16Dec/090

Voice Recognition in Flash 10

The following video demonstrates a new "voice gesture" library targeting the Flash Platform. As you might have guessed, those "voice gestures" are pretty much like "mouse gestures" but they are activated by voice only. I guess it uses some kind of voice learning/recognition algorithm. I can't stress enough how trhilled I am to see this kind of new and powerful software coming to Flash. This enables a whole new kind of usages and applications...


Voice Gesture from didier.brun on Vimeo.

13Dec/093

Frustum Culling in Flash 10

Update: corrected a few glitches in the bounding sphere creation routine.

Optimization is always important. But when it comes to 3D for the Flash Platform, it's an everyday battle. The first ideas that come to mind are to avoid:

  1. redrawing the same regions : each pixel value must be set once and only once
  2. rendering invisible objects : objects that are out of sight still take a lot of CPU horsepower

While Flash takes care of the first one in its very renderer, the second one is not handled. But that is something we can easily address!

The Technic

The method is called "frustum culling". The big picture is that every mesh is approximated using a bounding volume (typically a sphere or a box). If the bounding volume is visible, the corresponding mesh is rendered. The two following pictures show the frustum culling caught in action:

The mesh is visible

The mesh is visible: TPS counter indicates 18900 triangles per seconds

Frustum culling in action (TPS counter indicates 0!)

The mesh is out of sight: frustum culling is acting and TPS counter indicates 0!

Code snippets and a live experiment right after the jump!

10Dec/093

MadCompany: Coming Soon!



24Aug/0922

Amazon Web Services REST queries signature in ActionScript 3

As I was working on a custom MP3 player, I wanted to use a web service to search for album arts in order to display them as the corresponding music is played. After a quic Google search I found Amazon Web Services (AWS). Amazon actually provides services to search items in their catalog and therefor you can look for a precise music album and get its cover. This very service is the Product Advertising and is accessible through the Product Advertising API.

But since the 15th of August 2009 AWS requires every request to be signed. It simply means that a "Signature" parameter must be added to each and every request. One might think that the API key should be enough, but this key is inserted in every query URL and can be read by pretty much anyone. The signature is created using the secret AWS password and crypted using the HMAC/SHA256 algorithms so that AWS can be sure the request actually comes from the genuine owner of the API key.

The documentation features a guide to explain the whole signing process step-by-step but as you might have guesses, there is a huge difference between reading it on the documentation and actually implementing it successfully.

Full code right after the jump...

Read more...

26Aug/081

DirectFlex and Flash 10 : what’s next ?

My first post was about the 3D Flash library I'm currently working on : DirectFlex. As I said, it is not a simple 3D engine but a full 3D API like DirectX or OpenGL. As Flash 10 is likely to be available when the first public version of DirectFlex will be released, I decided to rewrite the API's core to take advantage of the new 3D mathematics classes and the hardware acceleration features. This is actually the third time that DirectFlex is entirely rewritten from scratch... but time after time the quality of the work and the performances have improved a lot.

Read more...

21Aug/084

DirectFlex : a new Flash 10 3D API

The next version of the Flash player will introduce a lot of new cool/useful features. One of them is the brand new 3D API. Of course, a lot of people are talking about the cool new "3D effects" that use this 3D API, but in the end those do not allow "real" and "complex" 3D such as real-time 3D games. So basically, yeah, drawing 3D spinning planes is "cool", but that's not how you're gonna create some "ass-kicking" RIA...

In order to render complex 3D geometry, you'll have to use the underneath 3D API itself. This 3D API is mainly about three classes : Matrix3D, Vector3D and Utils3D. Those implements data types and methods to transform vertices data from a space to another in order to render actual 3D geometry on our very 2d flat screens. And... that's it. We also have the new "Graphics.drawTriangles" method and hardware acceleration, but all of this does not provide what we could call a user-friendly 3D API. But here comes...

Read more...