2 Replies Latest reply on Mar 24, 2011 9:50 PM by AIF Bob

    using shader question

    Edward2009

      I have a shader,it's role is change the color of picture,like follows:
      <languageVersion : 1.0;>

      kernel NewFilter
      <   namespace : "Your Namespace";
          vendor : "Your Vendor";
          version : 1;
          description : "your description";
      >
      {
          input image4 src;
          output pixel4 dst;
          void
          evaluatePixel()
          {
              pixel4 px = sampleNearest(src,outCoord());
              px.rb=px.br;
              dst=px;
          }
      }

       

      Above code can run well under Pixel Bender,and can change the color of picture,then I export it as test.pbj.Then I call it under ActionScript3,the code is follows:
      package{
      import flash.display.Bitmap;
      import flash.display.Shader;
      import flash.display.Sprite;
      import flash.filters.ShaderFilter;
      import flash.utils.ByteArray;

      [SWF(width=700,height=500,backgroundColor=0x000000)]

      public class playTest extends Sprite{

      [Embed(source='test.pbj',mimeType='application/octet-stream')]
      private static const DesaturateKernel:Class;

      [Embed(source='test.jpg')]
      private static const BitmapClass:Class;

      public function playTest(){
      var bitmap:Bitmap=new BitmapClass() as Bitmap;
      var byteArray:ByteArray=new DesaturateKernel() as ByteArray;
      var shader:Shader=new Shader(byteArray);
      var filter:ShaderFilter=new ShaderFilter(shader);
      bitmap.filters=[filter];
      addChild(bitmap);
      }
      }
      }

       

      When I run above code,I find the color of picture don't change! Why? Where is wrong?
      Thanks