0 Replies Latest reply on Jul 30, 2009 12:52 PM by jbryson

    Unexplained output for simple I/O PB filter

    jbryson

      Wanting to do something simple with pixel bender math, I built a bytearray and passed it in 7 sets of 32bits. The pb filter is supposed to take the first 32bit number and output it in a 3 pixel format, the other two 32bits being 0.  1-7 sets of 4 bytes each worked just fine.  When I added an 8th set of 4 bytes, the length of the output is correct, but every pixel past the first 4 is 0.

       

      Simple I/O PB Filter

      {
           input image1 src;
           output pixel3 dst;
      
           void
           evaluatePixel()
           {
                float val = sampleNearest(src, outCoord());
                dst = pixel3(val,0.0,0.0);
           }
      }
      


      Sample Actionscript 3 Code

       

       

      public function PBTest()
      {
           loader = new URLLoader();
           loader.dataFormat = URLLoaderDataFormat.BINARY;
           loader.addEventListener(Event.COMPLETE, onComplete);
           loader.load(new URLRequest("spreadOut.pbj"));
      }
      
      
      private function onComplete(e:Event):void {
           shader = new Shader(loader.data);
           filter = new ShaderFilter(shader);
           myBA = new ByteArray();
           myBA.endian = Endian.LITTLE_ENDIAN;
           for(var i:uint = 1; i<29; i++) {
                myBA.writeByte(i);
           }
      
           
           /* Uncomment to see the effect of adding an extra 4 bytes
           myBA.writeByte(29);
           myBA.writeByte(30);
           myBA.writeByte(31);
           myBA.writeByte(32);
           */
      
      
           myBA.position = 0;
      
           shader.data.src.width = myBA.length/4;
           shader.data.src.height = height;
           shader.data.src.input = myBA;
      
      
           outBA = new ByteArray();
           outBA.endian = Endian.LITTLE_ENDIAN;
      
           var shaderJob:ShaderJob = new ShaderJob(shader,outBA,width,height);
           shaderJob.addEventListener(ShaderEvent.COMPLETE, shaderComplete);
           shaderJob.start();
      }
      
      
      private function shaderComplete(e:Event):void {
           outBA.position = 0;
      
           for(var i:int = 0; i<outBA.length; i++)
           {
                trace(i+" value -> " + outBA.readUnsignedByte());
           }
      }
      
      
      

       

      Output for 28byte Input (as Expected)Output for 32byte Input (Odd Behavior)
      0 value -> 1
      1 value -> 2
      2 value -> 3
      3 value -> 4
      4 value -> 0
      5 value -> 0
      6 value -> 0
      7 value -> 0
      8 value -> 0
      9 value -> 0
      10 value -> 0
      11 value -> 0
      12 value -> 5
      13 value -> 6
      14 value -> 7
      15 value -> 8
      16 value -> 0
      17 value -> 0
      18 value -> 0
      19 value -> 0
      20 value -> 0
      21 value -> 0
      22 value -> 0
      23 value -> 0
      24 value -> 9
      25 value -> 10
      26 value -> 11
      27 value -> 12
      28 value -> 0
      29 value -> 0
      30 value -> 0
      31 value -> 0
      32 value -> 0
      33 value -> 0
      34 value -> 0
      35 value -> 0
      36 value -> 13
      37 value -> 14
      38 value -> 15
      39 value -> 16
      40 value -> 0
      41 value -> 0
      42 value -> 0
      43 value -> 0
      44 value -> 0
      45 value -> 0
      46 value -> 0
      47 value -> 0
      48 value -> 17
      49 value -> 18
      50 value -> 19
      51 value -> 20
      52 value -> 0
      53 value -> 0
      54 value -> 0
      55 value -> 0
      56 value -> 0
      57 value -> 0
      58 value -> 0
      59 value -> 0
      60 value -> 21
      61 value -> 22
      62 value -> 23
      63 value -> 24
      64 value -> 0
      65 value -> 0
      66 value -> 0
      67 value -> 0
      68 value -> 0
      69 value -> 0
      70 value -> 0
      71 value -> 0
      72 value -> 25
      73 value -> 26
      74 value -> 27
      75 value -> 28
      76 value -> 0
      77 value -> 0
      78 value -> 0
      79 value -> 0
      80 value -> 0
      81 value -> 0
      82 value -> 0
      83 value -> 0
      
      
      0 value -> 1
      1 value -> 2
      2 value -> 3
      3 value -> 4
      4 value -> 0
      5 value -> 0
      6 value -> 0
      7 value -> 0
      8 value -> 0
      9 value -> 0
      10 value -> 0
      11 value -> 0
      12 value -> 5
      13 value -> 6
      14 value -> 7
      15 value -> 8
      16 value -> 0
      17 value -> 0
      18 value -> 0
      19 value -> 0
      20 value -> 0
      21 value -> 0
      22 value -> 0
      23 value -> 0
      24 value -> 9
      25 value -> 10
      26 value -> 11
      27 value -> 12
      28 value -> 0
      29 value -> 0
      30 value -> 0
      31 value -> 0
      32 value -> 0
      33 value -> 0
      34 value -> 0
      35 value -> 0
      36 value -> 13
      37 value -> 14
      38 value -> 15
      39 value -> 16
      40 value -> 0
      41 value -> 0
      42 value -> 0
      43 value -> 0
      44 value -> 0
      45 value -> 0
      46 value -> 0
      47 value -> 0
      48 value -> 0
      49 value -> 0
      50 value -> 0
      51 value -> 0
      52 value -> 0
      53 value -> 0
      54 value -> 0
      55 value -> 0
      56 value -> 0
      57 value -> 0
      58 value -> 0
      59 value -> 0
      60 value -> 0
      61 value -> 0
      62 value -> 0
      63 value -> 0
      64 value -> 0
      65 value -> 0
      66 value -> 0
      67 value -> 0
      68 value -> 0
      69 value -> 0
      70 value -> 0
      71 value -> 0
      72 value -> 0
      73 value -> 0
      74 value -> 0
      75 value -> 0
      76 value -> 0
      77 value -> 0
      78 value -> 0
      79 value -> 0
      80 value -> 0
      81 value -> 0
      82 value -> 0
      83 value -> 0
      84 value -> 0
      85 value -> 0
      86 value -> 0
      87 value -> 0
      88 value -> 0
      89 value -> 0
      90 value -> 0
      91 value -> 0
      92 value -> 0
      93 value -> 0
      94 value -> 0
      95 value -> 0

      Using:

      Adobe Pixel Bender Toolkit V1.5 Build 01

      Adobe Flash Builder 4 Premium Beta v4.0 Build 235740

      Flex 4.0 SDK

      Windows Vista Home Premium (PB Toolkit is ridiculously buggy on it)

       

      ~John