0
什么是关闭(使用PixelBender)关闭特定范围内颜色的最佳方式。例如,关闭0x0000FF和0x00FFFF之间的所有颜色。谢谢你的帮助。这必须在Flash中工作。谢谢!关闭Pixel Bender中的颜色范围
什么是关闭(使用PixelBender)关闭特定范围内颜色的最佳方式。例如,关闭0x0000FF和0x00FFFF之间的所有颜色。谢谢你的帮助。这必须在Flash中工作。谢谢!关闭Pixel Bender中的颜色范围
不知道这是否是最好的方式,但它的工作。这个想法是模拟Pixel Bender中的uint颜色值。
evaluatePixel()
{
float4 color = sampleNearest(src,outCoord());
float minInt = 0.0;
if(minColor.r > 0.0) minInt += minColor.r + 3.0;
if(minColor.g > 0.0) minInt += minColor.g + 2.0;
if(minColor.g > 0.0) minInt += minColor.b + 1.0;
float maxInt = 0.0;
if(maxColor.r > 0.0) maxInt += maxColor.r + 3.0;
if(maxColor.g > 0.0) maxInt += maxColor.g + 2.0;
if(maxColor.g > 0.0) maxInt += maxColor.b + 1.0;
float colInt = 0.0;
if(color.r > 0.0) colInt += color.r + 3.0;
if(color.g > 0.0) colInt += color.g + 2.0;
if(color.g > 0.0) colInt += color.b + 1.0;
if(colInt >= minInt && colInt <= maxInt)
{
dst = float4(0.0);
}else{
dst = color;
}
}
如果你的意思是每个频道“之间”,这是一个简单的方法来做到这一点。
<languageVersion : 1.0;>
kernel untitled
< namespace : "Your Namespace";
vendor : "Your Vendor";
version : 1;
>
{
input image4 src;
output pixel4 dst;
parameter float rThreshold
<
minValue: 0.0;
maxValue: 1.0;
defaultValue: 0.0;
>;
parameter float gThreshold
<
minValue: 0.0;
maxValue: 1.0;
defaultValue: 0.0;
>;
parameter float bThreshold
<
minValue: 0.0;
maxValue: 1.0;
defaultValue: 0.0;
>;
void
evaluatePixel()
{
pixel4 sourcePixel = sampleNearest(src,outCoord());
if(sourcePixel.r <= rThreshold) sourcePixel.r = 0.0;
if(sourcePixel.g <= gThreshold) sourcePixel.g = 0.0;
if(sourcePixel.b <= bThreshold) sourcePixel.b = 0.0;
dst = sourcePixel;
}
}
谢谢@sean,这不是很完美,因为我不得不根据颜色的数值键入一个范围。 – 2011-02-25 15:41:12