Question

i need some help to create a filter in Pixel Bender for AS3 to make this effect in the right side in this image:

http://a.imageshack.us/img829/1488/gradientmap.jpg

Can you help me?

Thank you.

Was it helpful?

Solution

A little late, but this seems to do the trick:

<languageVersion : 1.0;>

kernel Darken
<   namespace : "omino";
    vendor : "omino";
    version : 1;
    description : "darken the right part of an image";
>
{
    input image4 src;
    output pixel4 dst;

    parameter float leftEdgeOfEffect <minValue: 0.0 ; maxValue: 2000.0; defaultValue: 200.0;>;
    parameter float darkness <minValue: 0.0 ; maxValue: 1.0; defaultValue: 0.75;>;

    void
    evaluatePixel()
    {
        float2 co = outCoord();
        pixel4 p = sampleNearest(src,co);
        if(co.x >= leftEdgeOfEffect)
            p.rgb = p.rgb * (1.0 - darkness);
        dst = p;
    }
}

The actual pixel manipulation happens here: p.rgb = p.rgb * (1.0 - darkness);

It's just darkening the R, G, and B. You could get trickier here for more interesting effects.

OTHER TIPS

Is there any reason it needs to be done in Pixel Bender? You could probably get the same effect by covering half of the image with a black rectangle set to about 80% opacity. If you need any additional tweaking of the effect, applying a blend mode to the fill would probably work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top