Reputation: 1280
I'm having a problem and it's getting really annoying. I want to use a simple Shader
to return the colours of all the pixels in an image, but simply assigning a script to a Shader
is proving to be a challenge.
I don't know PixelBender script and I don't intend to study it too much since I only want to use it for this simple function, but from examples I've constructed this simple script:
<languageVersion : 1.0;>
kernel PixelColourShader
< namespace : "puggsoy";
vendor : "Puggsoy";
version : 1;
>
{
input image4 src;
output pixel4 dst;
void
evaluatePixel()
{
dst = sampleNearest(src, outCoord());
}
}
Here's a simple AS3 script I made to test loading it:
package
{
import flash.display.Shader;
import flash.display.Sprite;
import flash.utils.ByteArray;
public class Main extends Sprite
{
[Embed(source = "PixelColourShader.pbj", mimeType = "application/octet-stream")]
private var PixelColourShader:Class;
private var shader:Shader;
public function Main():void
{
shader = new Shader(new PixelColourShader() as ByteArray);
}
}
}
I've looked over numerous examples and I'm sure this is the correct way to load it. However, this always gives this error at runtime:
[Fault] exception, information=ArgumentError: Error #2004: One of the parameters is invalid.
and I have no idea why. From what I can see the parameter is completely valid.
I'm making this in an AIR application with FlashDevelop using the Flex 4 SDK.
Upvotes: 1
Views: 443
Reputation: 14162
You need to use something like Adobe Pixel Bender to compile your text file into a binary pbj.
Upvotes: 0
Reputation: 1438
Try this:
var shaderShader = new Shader();
shader.byteCode = new PixelColourShader();
Upvotes: 0