# How to use Pixel Bender (pbj) in ActionScript3 on large Vectors to make fast calculations?

Remember my old question: 2d game view camera zoom, rotation & offset using 'Filter' / 'Shader' processing?

I figured I could use a Pixel Bender Shader to do the computation for any large group of elements in a game to save on processing time. At least it's a theory worth checking.

Which I'm guessing is about accomplishing the same thing in a different language.

I am attempting to do some tests. Here is some of the code:

        private const SIZE : int = Math.pow(10, 5);
private var testVectorNum : Vector.<Number>;

{

var time : int = getTimer(), i : int = 0;
trace("TEST1 : ", getTimer() - time);
}


The problem is that I keep getting a error saying:

[Fault] exception, information=Error: Error #1000: The system is out of memory.

Update:

I managed to partially workaround the problem by converting the vector into bitmapData: (Using this technique I still get a speed boost of 3x using Pixel Bender)

    private function testShader():void
{
var time : int = getTimer(), i : int = 0;
testBitmapData.setVector(testBitmapData.rect, testVectorInt);

testVectorInt = testBitmapData.getVector(testBitmapData.rect);
trace("TEST1 : ", getTimer() - time);
}


I found a complete solution to this issue.

Please notice size is now 10,000,000

Here is the new code snippet:

        private const SIZE : int = Math.pow(10, 7);
private var testVectorInt : Vector.<Number>; //gotta use Number (not int)
private var testVectorInt2 : Vector.<Number>; //Need separate vectors for I & O

{
var time : int = getTimer(), i : int = 0;