关闭Pixel Bender中的颜色范围

关闭(使用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;
    }
}
    
不确定这是否是最佳方式,但它有效。这个想法是在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;
    }
}
    

要回复问题请先登录注册