Header image

ND2D – ParticleExplorer

March 16th, 2011 | Posted by lars in 3D | Molehill / Stage3D | ND2D | Particles - (0 Comments)

I just uploaded a ParticleExplorer I’m using to debug the ND2D particlesystem. It’s already fun to play with, but be careful it can freeze your browser ;)


(Note: The demo is broken with the latest Flashplayer 11 Release due to API changes)

I’d really like to push ND2D to github, but I’m struggling a bit with the current public PB3D release. There are some nasty bugs that make the renderings look ugly (Bilinear filtering is not working properly). I guess I have to wait for the next update :(

ND2D Molehill 2D Engine

March 10th, 2011 | Posted by lars in 3D | Molehill / Stage3D | ND2D | Talk - (31 Comments)

I just came back from the FITC Amsterdam and because at the whole conference, Molehill was all over the place, I felt like I have to post the progress of my Molehill accelerated 2D engine. Here is another test with 1600 animated sprites using spritesheets. It runs with 40fps on my machine in Safari, Firefox is a lot slower and it feels a bit jerky. Maybe it’s an issue of the incubator build, maybe an issue in my engine… I’ll find out.


(Note: The demo is broken with the latest Flashplayer 11 Release due to API changes)

Check out the demos showing all effects and features on Github.

I’ll push the engine open source in an alpha version next week (I hope…). These are the features that are already implemented:

- Flash-displaylist-like hierarchy for 2D elements (It will feel very familar)
- 2D sprites with spritesheets for animation, tinting, blendmodes, pivot points
- Scenes & scene management
- 2D camera
- SpriteClouds for fast sprite rendering (batch drawing)
- Configurable particlesystem that runs entirely on the GPU
- Full mouseevent support for sprites
- Utils (Color mixing, random number generation, …)
- Extendible rendering pipeline to build your own effects and extensions using PixelBender 3D.

Planned features are:
- Pixel precise mouse events. At the moment it’s only a bounding box check.
- Faster batching of SpriteClouds.
- More particlesystem options
- ATF texture support
- Distortion effects
- Box2D integration
- …

And if anyone likes to contribute, just drop me an email…

In this demo, you can see a GPU accelerated particle system I built for my upcoming ND2D engine. The particles are entirely processed on the GPU using pixelshaders. Flash does basically nothing :) There is still plenty of room for improvements, but the performance is already really good! I’ll post more details about the engine the next days…


(Note: The demo is broken with the latest Flashplayer 11 Release due to API changes)

Btw.: Who’s attending to the FITC Amsterdam next week? See you there ;)

Good news everyone. Since a few hours a version of the Pixel Bender 3D compiler has reached the public beta phase. You can download it here.
Now you’re able to write vertex and fragment shaders not only with assembler-like opcodes, but with a lot more readable language.

Instead of:

mov ft0, v0
tex ft1, ft0, fs1 <2d,clamp,linear>
mov oc, ft1

You can write much more readable code like this:

void evaluateFragment()
{
    float4 color = sample(textureImage, float2(uv.x, uv.y));
    result = color;
}

To use a PD3D shader in Molehill you have to write three pixelshaders. The first one is the vertex shader that calculates the vertex position, the second one will be the material vertex shader which (optionally) prepares and calculates data for the fragment shader and finally the fragment shader which is responsible to set the pixel color. Here is an example of the most simple shader you can imagine:

Vertex Shader:

vertex kernel default
<namespace : "AIF Test";
vendor : "Adobe";
version : 1;>
{
    parameter float4x4 objectToClipSpaceTransform;
 
    input vertex float4 vertexPosition
    <id : "PB3D_POSITION";>
 
    output float4 vertexClipPosition;
 
    void evaluateVertex()
    {
        vertexClipPosition = vertexPosition * objectToClipSpaceTransform;
    }
}

Material Vertex Shader & Fragment Shader:

material kernel color
<namespace : "AIF Test";
vendor : "Adobe";
version : 1;>
{
    input vertex float4 vertexColor
    <id : "PB3D_COLOR";>
 
    interpolated float4 color;
 
    output float4 result;
 
    void evaluateVertex()
    {
        color = vertexColor;
    }
 
    void evaluateFragment()
    {
        result = color;
    }
}

To compile a shader program from these three shaders you can use the included PBASMCompiler:

var inputVertexProgram:PBASMProgram = new PBASMProgram(compiledVertexProgramBinary);
var inputMaterialVertexProgram:PBASMProgram = new PBASMProgram(compiledMaterialVertexProgramBinary);
var inputFragmentProgram:PBASMProgram = new PBASMProgram(compiledMaterialFragmentProgramBinary);
 
var programs:AGALProgramPair = PBASMCompiler.compile(inputVertexProgram, inputMaterialVertexProgram, inputFragmentProgram);
var agalVertexBinary:ByteArray = programs.vertexProgram.byteCode;
var agalFragmentBinary:ByteArray = programs.fragmentProgram.byteCode;
 
program = context3D.createProgram();
program.upload(agalVertexBinary, agalFragmentBinary);

For a description how to connect a pixelshader to data streams look into the PDF and the examples that are included in the PB3D release. The documentation is already pretty good ;)

If you have no idea what I’m talking about and you’re have heard the word pixelshader for the first time, take a look at Thibault’s intro to Molehill and Michael’s Simple 2D Molehill example.

Molehill Demo

March 2nd, 2011 | Posted by lars in 3D | Molehill / Stage3D - (7 Comments)

I made this demo a while ago to test the performance of my molehill port of ND3D.

You should see 144 of these little fellas that are lighted by a simple lighting shader and animated on the GPU. Each of these dudes has about 1500 polygons and 100 frames of animation data and it runs with at least 50 fps on my machine. Molehill simply rocks. This is just the beginning :)


(Note: The demo is broken with the latest Flashplayer 11 Release due to API changes)

You need the Flash Player Incubator Plugin to view the demo. Grab it here.

(No preloader, so be patient the browser will hang for a short while, while initializing the character animations.)

Molehill released!

March 1st, 2011 | Posted by lars in 3D | Molehill / Stage3D | Talk - (2 Comments)

As you might have noticed the latest flash player codenamed “Molehill” has been released to the public. Finally everyone can play around with the new GPU features. Read about the details here: Changing the web, again.

In my previous post, I mentioned my plans for Molehill. Meanwhile I have developed a 2D engine based on Molehill and I will release the beta version within the next days hopefully. Unfortunately I was on a holiday and just came back yesterday. Now my inbox is flowing over and I’m back into my projects, but I will use the next days to clean up the code, write a few examples and get that thing online for you.

Stay tuned!

Flash 3D – Molehill

January 13th, 2011 | Posted by lars in 3D | Molehill / Stage3D | Talk - (7 Comments)

It’s been a while since my last “real” post… but it’s about time, there are so many things happening. I’m still pretty busy developing large scale flex applications for clients and it’s still fun, but obviously I went out for a walk to the “other side” and learned Objective C on the iPhone. I was always interested in hardware accelerated graphic programming and the iOS platform was a nice and easy way to learn it, because all the tools were there and I could just start. So I started learning OpenGL on the iPhone, which was a lot of fun … and gave me headaches sometimes.

A few month ago I was asked by Adobe to take part in a prelease team for the new upcoming Flash Player codenamed “Molehill” and guess how excited I was (Thanks Thibault!). Finally our dreams are becoming reality: Hardware accelerated Flash content. Leveraging the GPU to do all the rendering at nearly native speed in the browser, wow:

As you know, I built my own little 3D engine (ND3D) in Flash and hey it became a little successful and a few people are still using it. Of course it never could compete with all the big engines like Papervision3D, but it’s small, fast and lightweight.

As you can imagine I’m playing around a lot with the new Molehill API and it’s so stunning and I can’t wait for the final player to be released to the public. I also thought about what to do with ND3D and if it would make sense to port the engine to Molehill and make use of the hardware acceleration. This time I can’t compete with the major players as well (Away3D, Alternativa3D or Flare3D) which are making their engines ready for Molehill, but it was never my goal to compete …

My goal for the next version of ND3D is to build a small and easy extendible 3d library that has all the basic features you need to display high quality 3d content (loading textures and meshes, animating them, extendible materials, lighting, reflections, etc…). Since I’m still a “learner” in many 3D topics, it’s challenging and very exiting (I never coded a pixelshader before Molehill…). I’m interested in way too many topics at the moment: Bump mapping, Shadow mapping, Projections, just to name a few. The more I dig into graphic programming the bigger the whole world get’s… Let’s see where I will end up. So ND3D will be mainly a research and learning project for me and hopefully it will be usable to some of you. I will be open sourced and hopefully you guys like to contribute and extend it…

But more important is: Flash is coming from a 2D world and there are so many cool 2D games out there that need to be ported to Flash, so Flash needs a hardware accelerated 2D framework. On the iPhone I was working a lot with Cocos 2D and I really liked it, so I decided to create a Molehill accelerated 2D engine, let’s call it ND2D for the time being.

My plan it to be ready with this engine as soon as the player reaches the public beta (fingers crossed). It will be open source like ND3D and free for everyone to use. I wanna see thousands of particles and spaceships exploding at 60hz in HD in Flash, with the new player somethiing like this will be possible:

If you’re interested in this 3D topic and want to learn how graphic programming works, be able to write pixelshaders and be prepared for Molehill I recommend reading these two books: OpenGL Official Learning Guide and Pixelshader Programming in OpenGL. If you’re already able to code pixelshaders for OpenGL or DirectX, Molehill will be very familar to you…

And I almost forgot to mention an article I just read that drove me to write this post, an interesting read about Flash competing with Unity3D: Adobe vs. Unity

So long…