Personal tools

Views

Lightness Hydra

From Adobe Labs

/*****************************************************************************
 *
 * Author: Jan Van Coppenolle
 * http://compiler.kaustic.com/lab
 *
 *****************************************************************************/
kernel Lightness
{
    parameter float amount
    <
        minValue: 0.0;
        maxValue: 1.0;
        defaultValue: 1.0;
    >;
    
    void evaluatePixel(in image3 src, out pixel3 dst)
    {
        pixel3 px = sampleNearest(src, outCoord());
        float minCh = min(px.r, min(px.g, px.b));
        float maxCh = max(px.r, max(px.g, px.b));
        float f = (minCh + maxCh) / 2.0;
        dst = px - amount * px + amount * pixel3(f, f, f);
    }
}
Retrieved from "http://labs.adobe.com/wiki/index.php/Lightness_Hydra"