0

特定の範囲内にある色を (PixelBender を使用して) オフにする最良の方法は何ですか。たとえば、0x0000FF から 0x00FFFF までのすべての色をオフにします。ご協力いただきありがとうございます。これは Flash で動作する必要があります。ありがとう!

4

2 に答える 2

0

チャネルごとの「間」を意味する場合、これを行う簡単な方法を次に示します。

<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;
    }
}
于 2011-02-24T13:44:30.533 に答える
0

これが最善の方法かどうかはわかりませんが、うまくいきました。アイデアは、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;
    }
}
于 2011-02-25T15:45:09.843 に答える