When I run the following pixel bender code:
input image4 src;
output float4 dst;
// How close of a match you want
parameter float threshold
<
minValue: 0.0;
maxValue: 1.0;
defaultValue: 0.4;
>;
// Color you are matching against.
parameter float3 color
<
defaultValue: float3(1.0, 1.0, 1.0);
>;
void evaluatePixel()
{
float4 current = sampleNearest(src, outCoord());
dst = float4((distance(current.rgb, color) < threshold) ? 0.0 : current);
}
I got the following error message:
ERROR: (line 21): ':' : wrong operand types no operation ':' exists that takes a left-hand operand of type 'const float' and a right operand of type '4-component vector of float' (or there is no acceptable conversion)
Please advice
From the error message, it sounds to me like Pixel Bender doesn't support the ternary (?:) operator. Expand it out into an if-statement:
if (distance(current.rgb, color) < threshold)
dst = float4(0.0);
else
dst = float4(current);