3 Replies Latest reply on Apr 11, 2011 9:34 AM by Rytis Alekna

    outCoord() with output pixel1 and pixel2 are not supported!

    Rytis Alekna

      Hello,

       

      sorry it's not a new topic here, but there is a problem that you should know:

       

      Pixel bender kernel doesn't support output types pixel1 and pixel2. Only pixel3 and pixel4. And I'm not talking about Pixel Bender toolkit. I'm talking about compiled kernel (with pbutil.exe from Pixel Bender Toolkit 2.5.449694) that is embeded in in Flash.

       

      Problem is that when output is pixel1, built in function outCoord, doesn't provide coordinates. It always return 0 for both x and y.

       

      I wanted to create range generator - kernel that generates numbers from 0 to any specified ShaderJob instance.

       

      There is my code:

      (BTW, this code to compile with pbutil.exe took 1:20 min!!!)

      /** 
       *  Genertes numbers from 0 to any specified in shader job
       */
      kernel RangeGenerator
      <   namespace : "__";
          vendor : "__";
          version : 1;
      >
      {
          
          /** Output */
          output pixel1 dst;
          
           /** 
            *  Evaluate pixel
            */
          void evaluatePixel() {
           
              dst = pixel1( outCoord().x );
                
          }
      }
      

       

       

       

       

      And thre is my test:

       

       

       

      package {
           import flash.display.Shader;
           import flash.display.ShaderJob;
           import flash.display.ShaderPrecision;
           import flash.utils.ByteArray;
           import flexunit.framework.Assert;
           
      /**
       * Range generator test using FlexUnit
       */
      public class RangeGeneratorTest {
           
           [Embed(source='RangeGenerator.pbj', mimeType='application/octet-stream')]
           public var RangeGenerator : Class;
           
      
           [Test]
           public function testIfRendersValidRange () : void {
                
                var shader : Shader = new Shader( new RangeGenerator() as ByteArray );
                
                var output : Vector. = new Vector.();
                
                var shaderJob : ShaderJob = new ShaderJob( shader, output, 100, 1 ); // 100 is expected range.
                
                shaderJob.start( true );
                
                Assert.assertEquals( "Output must be 100 length", 100, output.length ); // passes
                
                for ( var i : int = 0; i < output.length; i++ ) {
                     
                     Assert.assertEquals( "Vector item must be same as iterator value", i, output[i] );
                     
                }
                
           }
           
      }
           
      }
      

       

       

      I'm not a new with this problem. Same was spotted here: http://www.boostworthy.com/blog/?p=243

       

      Thanks for you help!