-
1. Re: Required number of inputs
Kevin Goldsmith May 17, 2010 10:57 AM (in response to moham_44)Could you post the shader and the actionscript to the forum? If it is sensitive, you can e-mail it to me directly.
One gotcha in Flash is that you may choose to apply the shader in different ways depending on how many inputs it has (zero inputs = shader fill, 1 input = shader filter, 2 inputs = blend shader). You can use a shader filter with multiple inputs, but you need to explicitly set them on the shader object before processing.
-
2. Re: Required number of inputs
moham_44 May 17, 2010 11:20 AM (in response to Kevin Goldsmith)The shader i was using that generated the error was this one
<languageVersion : 1.0;>
kernel NewFilter
< namespace : "Your Namespace";
vendor : "Your Vendor";
version : 1;
description : "your description";
>
{
input image4 src;
output pixel4 dst;void evaluatePixel()
{
dst = pixel4(1, 1, 1, 1);
}
}However I managed to solve the issue by first sampling the input image and then change that value to the color I needed. I'm in no need of having a input as what i'm doing is generating the image inside the shader. And returning colors like this is what i've been doing in HLSL which is why I had quite some problems with it. But as it works without any problems in the PixelBender IDE I thought the problem was in the flash code.
The below code works.
<languageVersion : 1.0;>
kernel NewFilter
< namespace : "Your Namespace";
vendor : "Your Vendor";
version : 1;
description : "your description";
>
{
input image4 src;
output pixel4 dst;void evaluatePixel()
{
pixel4 temp = sampleNearest(src, outCoord());
temp.a = 1.0;
temp.r = 1.0;
temp.g = 1.0;
temp.b = 1.0;
dst = temp;
}
}
-
3. Re: Required number of inputs
Kevin Goldsmith May 17, 2010 11:29 AM (in response to moham_44)because you weren't using the input, it was removed as a compiler optimization for Flash. We should have given you a warning there, so that is our bad. I'll file a bug.
-
4. Re: Required number of inputs
AP van Grootel Oct 28, 2010 7:51 AM (in response to Kevin Goldsmith)Hi,
I am using the image4 src, and I have the same error.
This is what I do:
<languageVersion : 1.0;>
kernel aptest3
< namespace : "nl.bbtest.customfilter";
vendor : "BBTest";
version : 1;
description : "Test";
>
{
input image4 src;
input image4 background;
input image4 fill;
output pixel4 dst;
parameter float amount
<
minValue: 0.0;
maxValue: 1.0;
defaultValue: 0.0;
>;
parameter float amount2
<
minValue: 0.0;
maxValue: 10.0;
defaultValue: 0.0;
>;
void evaluatePixel()
{
pixel4 a = sampleNearest(src, outCoord() );
pixel4 b = sampleNearest( background, outCoord() );
pixel4 c = sampleNearest( fill, outCoord() );
float gray = (a.r + a.g + a.b)/3.0;
if( gray < amount )
{
dst = amount2 * a * c;
}
else
{
dst = 1.0 - 2.0 * (1.0 - b) * (1.0 - a);
}
}
}
and this is the actionscript I am using:
...
public function PB():void {
var im = new image() as Bitmap;
var bg = new image2() as Bitmap;
var fill = new image3() as Bitmap;
var shader:Shader = new Shader(new APTestFilter() as ByteArray);
shader.data.background = bg.bitmapData;
shader.data.fill = fill.bitmapData;
trace(shader.data.background,fill.bitmapData);
shader.data.amount.value = [0.5];
shader.data.amount2.value = [5.8];
var filter:ShaderFilter = new ShaderFilter(shader);
_spr.filters = [filter];
}
As you can see, I am using shader.data.background and shader.data.fill to fill the input image4 background; and input image4 fill; Then I put the filter on a DisplayObject. I was under the impression that this DisplayObject would fill the input image4 src;, but when I run this, I get the same error.
Thanks,
AP
-
5. Re: Required number of inputs
AP van Grootel Oct 28, 2010 8:19 AM (in response to AP van Grootel)Oeps, posted this too early. Instead of using shader.data.background (same for fill) it should read shader.data.background.input. And then it is working like a charm.
Thanks,
AP


