Header image

ND2D Postprocessing effects

September 8th, 2011 | Posted by lars in Experiments | Molehill / Stage3D | ND2D | Pixelshader | Source | Talk

I never really introduced the TextureRenderer of ND2D and what possibilities you have, when using it. The TextureRenderer does what the name suggests: It renders a display object (Sprite2D, etc.) and all subsequent objects onto a Context3D texture. The cool thing is, that you are able to draw your entire scene to a (fullscreen) texture and add some post processing effects, by writing a new material / shader and displaying it via a standard Sprite2D.

Here’s the plain scene without post processing:

… and here with a small “dizzyness” post process shader:

I’ve added this test to the examples incluced in the ND2D sources. You can see the live running example here (test #18).

You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.

9 Responses

  • benny! says:

    Wow … demos are looking very cool. Keep it up!

  • Trogl says:

    Hello! I have a question about the particle system. It seems they behave differently than I expected. The particles moves with ParticleSystem2D and fully redrawn when the gravity vector changed. How can I realize stardust effect of mouse? Ie when I move the mouse, it left trail of particles, which then disappear.

    ps. nd2d is awesome!

  • Andy says:

    How do you use that in Flash IDE, Timelinecode. Yes I know… you should use FB – but I really wanted to get it to work in the IDE. I always get 1172 Defintition not found for VertexRegisteriInfo and VertexBufferHelper. But the pxielbender swc is linked correctly in the as3 settings as RSL (also the appropiate global flashplayer.swc and so on).

    Something I’m missing here?

    Heres the totally basic code:

    import com.adobe.pixelBender3D.VertexRegisterInfo;
    import com.adobe.pixelBender3D.utils.VertexBufferHelper;

    import de.nulldesign.nd2d.display.Scene2D;
    import de.nulldesign.nd2d.display.World2D;
    import de.nulldesign.nd2d.display.Sprite2D;
    import de.nulldesign.nd2d.materials.SpriteSheet;
    import de.nulldesign.nd2d.geom.Face;
    import de.nulldesign.nd2d.geom.UV;
    import de.nulldesign.nd2d.geom.Vertex;
    import de.nulldesign.nd2d.utils.NodeBlendMode;

    import flash.display3D.Context3D;
    import flash.display3D.Context3DVertexBufferFormat;
    import flash.display3D.IndexBuffer3D;
    import flash.display3D.VertexBuffer3D;

    var myScenes:Vector. = new Vector.();
    var myScene:Scene2D = new Scene2D();
    var spriteTexture:Class;
    var s:Sprite2D;

  • lars says:

    @Andy: The error indicated, that the pb3d.swc isn’t integrated properly. Try to compile it into the SWF, not by linking it as RSL.

  • lars says:

    @Trogl: The ND2D particlesystem is fully GPU based. That means, that you can’t control the position of each particle. Instead the particles move by some defined rules. You could use this system for fire or smoke effects. If you want to have individual control over particles, try to use a Sprite2DCloud or Sprite2DBatch instead.

  • Pingback: Cool Stuff with the Flash Platform - 9/19/2011 | Remote Synthesis

  • Andy says:

    Hmmm… I’m not exactly sure how to “compile it into the SWF”. I can change from RSL to “merged into code” but this isn’t changing anything. Well… I’ve read at adobe labs forums that there are more people having the same issue and only with the pb3d swc, when included from flash directly (not flex, not fb or fd)… maybe there’s something wrong with the swc.

  • lars says:

    @Andy: Hmm ok… Today Adobe announced a new pb3d Library, I’ll integrate the new one the next days. Maybe this will make a difference. In the long run, I’m going eliminate the dependency to this lib, …

  • Andy says:

    Hi lars… with pb3d preview 3 the errors are gone.

    Don’t know if anybody is interested in that, but here’s some working example code how to use it with just the Flash IDE (assuming you included all the needed swc’s and set up the appropiate flashplayer11.xml in the install directory).

    NOTE: I just needed to change setActiveScene from protected to public and I took one of the provided sample pngs and included it as bitmap in the library and named it “spriteTexture”.


    import de.nulldesign.nd2d.display.Scene2D;
    import de.nulldesign.nd2d.display.World2D;
    import de.nulldesign.nd2d.display.Sprite2D;
    import de.nulldesign.nd2d.materials.SpriteSheet;
    import flash.display3D.Context3DRenderMode;

    var W:int = 800;
    var H:int = 600;

    var myScenes:Vector. = new Vector.();
    var myScene:Scene2D = new Scene2D();
    var myWorld:World2D = new World2D(Context3DRenderMode.AUTO, 60, true);
    var s:Sprite2D;
    var _texture:Class = getDefinitionByName(String("spriteTexture")) as Class;

    function startApp():void{
    if (stage == null) {
    addEventListener(Event.ADDED_TO_STAGE, init);
    } else {
    init();
    }
    }

    function init(e:Event = null):void {
    removeEventListener(Event.ADDED_TO_STAGE, init);

    addChild(myWorld);
    myWorld.setActiveScene(myScene);
    myWorld.start();

    s = new Sprite2D(new _texture());
    myScene.addChild(s);

    s.x = W/2;
    s.y = H/2;
    }

    startApp();

    I hope you don’t mind lars, I’m posting this here… no intention to spam your entries ;)
    +1 for a nd2d forum ;)



Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">