Flash 关闭像素弯曲器中的颜色范围

Flash 关闭像素弯曲器中的颜色范围,flash,actionscript-3,pixel-shader,pixel-bender,Flash,Actionscript 3,Pixel Shader,Pixel Bender,关闭(使用PixelBender)某个范围内的颜色的最佳方法是什么。例如,关闭0x0000FF和0x00FFFF之间的所有颜色。谢谢你的帮助。这必须在Flash中工作。谢谢 如果你指的是每个频道的“中间”,这里有一个简单的方法 <languageVersion : 1.0;> kernel untitled < namespace : "Your Namespace"; vendor : "Your Vendor"; version : 1; > {

关闭(使用PixelBender)某个范围内的颜色的最佳方法是什么。例如,关闭0x0000FF和0x00FFFF之间的所有颜色。谢谢你的帮助。这必须在Flash中工作。谢谢

如果你指的是每个频道的“中间”,这里有一个简单的方法

<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;
    }
}

无标题内核
<名称空间:“您的名称空间”;
供应商:“您的供应商”;
版本:1;
>
{
输入image4src;
输出像素4dst;
参数浮点rThreshold
<
最小值:0.0;
最大值:1.0;
默认值:0.0;
>;
参数浮点阈值
<
最小值:0.0;
最大值:1.0;
默认值:0.0;
>;
参数浮点bThreshold
<
最小值:0.0;
最大值:1.0;
默认值:0.0;
>;
无效的
evaluatePixel()
{
pixel4 sourcePixel=sampleNearest(src,outCoord());

if(sourcePixel.r不确定这是否是最好的方法,但它确实有效。其想法是在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;
    }
}
evaluatePixel()
{
float4 color=sampleNearest(src,outCoord());
浮动最小值=0.0;
如果(minColor.r>0.0)minInt+=minColor.r+3.0;
如果(minColor.g>0.0)minInt+=minColor.g+2.0;
如果(minColor.g>0.0)minInt+=minColor.b+1.0;
float maxInt=0.0;
如果(maxColor.r>0.0)maxInt+=maxColor.r+3.0;
如果(maxColor.g>0.0)maxInt+=maxColor.g+2.0;
如果(maxColor.g>0.0)maxInt+=maxColor.b+1.0;
浮点数=0.0;
如果(color.r>0.0)colInt+=color.r+3.0;
如果(color.g>0.0)colInt+=color.g+2.0;
如果(color.g>0.0)colInt+=color.b+1.0;

如果(colInt>=minInt&&colInt谢谢@sean,这并不完全是因为我必须根据颜色的数值键入一个范围。