Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Does anyone know how to create a Texture feedback effect in Stage3D / AGAL?

I've just found the term "ping-ponging" in some GPU wikipage, hopefully I'm using it in the right place!

I'll share with you my sample code portion responsible for alternating between the source and destination Texture targets:

protected override function _draw():void {
        super._draw();

        var src:int =   _textureFlip;
        var dest:int =  1 - _textureFlip;

        context3D.setRenderToTexture(_texturePair[dest], false, 0, 0); //
        clear();
        context3D.setTextureAt(0, _textureNoise);
        context3D.setTextureAt(1, _texturePair[src]);
        setupConstants();
        context3D.setProgram(_programs[0]);
        context3D.drawTriangles(_quadIndices.buffer, 0, 2);

        context3D.setRenderToBackBuffer();
        clear();
        setupConstants();
        context3D.setTextureAt(0, _texturePair[dest]);
        context3D.setTextureAt(1, null);
        context3D.setProgram(_programs[1]);
        context3D.drawTriangles(_quadIndices.buffer, 0, 2);

        context3D.present();

        _textureFlip =  1 - _textureFlip;
    }

Now... if I run the bottom portion by itself (and swap _texturePair[dest] with '_textureNoise'), I can see my texture fine.

Maybe I'm forgetting something in my AGAL code, but I figured I should ask here first for any guidelines.

Is it possible I have to upload some startup data (blank rect, black, white, anything!) in my first input-texture before the very first target texture is being rendered to?

  • Do I need to clear the Texture targets first?
  • Do I need to set the blend factors between switching from BackBuffer vs. Texture Targets?

Would very much appreciate your help :)

share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.