2 Replies Latest reply on Dec 12, 2011 2:04 PM by AIF Bob

    Problem with multiple inputs / sequential shaders in flash

    Bludgin

      Hi,

      I'm working with pixelbender for the first time and having a little difficulty understanding a couple of things.

       

      The project is a little flash game with pixel art spaceships, and I've embedded a couple of pixelbender shaders into the swf. I'm writing an editor where you draw an rgba image, the editor infers a greyscale heightmap (at the moment this is done in flash with a blur handcoded using getPixel/setPixel) I use that height map as the source image to make a normal map via a pixel bender shader, I then have another pixelbender shader waiting to take the rgba image and the normal map as two inputs, add a few parameters, with the expected result of a nicely lit sprite output.

       

      The first problem is accessing the result of the normal map shader to pipe it into the lighting shader. The normal map displays perfectly on screen, but my normalMap.bitmapData still contains the unmodified height map image, how do I get at the post-filter image data to send it to the next shader?

       

      The second problem is a bit trickier.. I first thought it was just a minor bug in the pixel bender toolkit, compiling for flash when using multiple source images has an issue where only one source image is scaled. I thought the problem would go away eventually because I am using two identically sized bitmaps for source. However, now that it is in a swf, the output is inside a sprite, and this parent sprite has scale and rotation applied to it. The shader output shows one scaled and rotating image mixed with an unscaled, unrotating image in the top left corner. Even if I make a new sprite, and apply the filter before applying the scale / rotation, the effect persists. This does not seem to effect shaders with a single source - they can be scaled and rotated freely. Is there any solution for this short of ditching the two input shader altogether?

       

      I'm hoping i've missed something simple, but any help at all would be appreciated, thanks.