3 Replies Latest reply on May 3, 2009 9:48 AM by Mavriša

    Vector in, image out?

    Mavriša Level 1

      Is there any way to put a vector in and have a kernel output an image? I have a set of thousands of points in polar coordinates in a vector, and pulling up Math.sin() for every point really bogs down the player. I know pixelbender could whip through it much faster but I don't know if its possible to have different input and output types..

      Any ideas?

        • 1. Re: Vector in, image out?
          Kevin Goldsmith Level 3

          you can put the points into a byte array, pass them into Pixel Bender as an image and pass them out as pixel values. Not too hard.


          A Pixel4 is the same thing as a Float4, so if you are doing x, y points, you can put them into a buffer as (x1,y1,x2,y2) and then do a kernel that uses pixel.rg and pixel.ba as two different points.



          1 person found this helpful
          • 2. Re: Vector in, image out?
            Mavriša Level 1

            Well the number of pixels (400 x 400 = 160000) greatly exceeds the number of points being put in (8000). It would be good if there was an equivalent to the setPixel function we have in actionscript but I'm not aware of one in pixelbender. I'm thinking perhaps just calculate the positions in pixelbender and hope the performance increases it has over flash will be enough.


            Can someone show me a working example of how to set up a ShaderJob in AS3 that would accept 4 values from a Vector.<Number> at once and output those into another Vector.<Number> (including the simplest pixelbender bytecode this is possible with)? Every time I've tried to use ShaderJob I've been unsuccessful and have had to try something else.


            Thanks a lot,


            • 3. Re: Vector in, image out?
              Mavriša Level 1

              Alright so I got it working sortof... The problem now is that it only gives me 8 useable results, and the others are either 0, numbers very close to 0 (eg: 1.454326456e-41) or very large numbers (6.52342342e28) which are absolutely not what I'm looking for. I applied the exact same calculation in flash before, and had no problem. Even outputting outCoord() gives me very strange results past 8 correct values. Has anyone had any similar problems and does anyone know how to fix it? I saw two similar complaints on bugs.adobe.com, but they were unresolved.

              Thanks in advance for any help,