开发者

Show / Hide specific color ranges with PixelBender

开发者 https://www.devze.com 2023-02-05 16:11 出处:网络
What is the best way to hide specific (interpolated) color ranges? For example, I have a gradient that goes from blue > cya开发者_C百科n > yellow > red. What I need is to hide blue > cyan, yellow > re

What is the best way to hide specific (interpolated) color ranges? For example, I have a gradient that goes from blue > cya开发者_C百科n > yellow > red. What I need is to hide blue > cyan, yellow > red but leave the cyan > yellow.

var rangeA:Object = {min:0x0000FF, max:0x00FFFF}  //hide
var rangeB:Object = {min:0x00FFFF, max:0xFFFF00}; //show
var rangeC:Object = {min:0xFFFF00, max:0xFF0000}; //hide

It is ok to apply different filter for each range.

Any ideas?


This is the simplest solution i've found:

void
evaluatePixel()
{
    float4 color = sampleNearest(src,outCoord());

    float maxR = max(minColor.r, maxColor.r);
    float maxG = max(minColor.g, maxColor.g);
    float maxB = max(minColor.b, maxColor.b);

    float minR = min(minColor.r, maxColor.r);
    float minG = min(minColor.g, maxColor.g);
    float minB = min(minColor.b, maxColor.b);

     dst = color;

    // Check whether a color is within the range
    if(color.r >= minR && color.g >= minG && color.b >= minB)
    {
        if(color.r <= maxR && color.g <= maxG && color.b <= maxB)
        {
            dst = float4(0.0,0.0,0.0,0.0);
        }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号