Personal tools

Views

Displaced Halation hydra

From Adobe Labs

<languageVersion : 1.0;>
/**
David Wicks
thingsiam.com
**/

kernel StrangeDisplacer
<   nameSpace : "thingsiam";
    description : "creates strange displaced halation effects";
>
{
    parameter float turbulence
    <
        minValue:float(0);
        maxValue:float(3.14);
        defaultValue:float(0.1);
    >;
    
    parameter float dropOff
    <
        minValue:float(1.0);
        maxValue:float(0.8);
        defaultValue:float(0.9);
    >;
    
    parameter float2 dist
    <
        minValue:float2(-10, -10 );
        maxValue:float2(10, 10 );
        defaultValue:float2(0.0, 0.0 );
    >;
    
    parameter float2 linDist
    <
        minValue:float2(-10, -10 );
        maxValue:float2(10, 10 );
        defaultValue:float2(0.0, 0.0 );
    >;
    input image4 src;
    output pixel4 dst;

    void
    evaluatePixel()
    {
        //some fun with trig values
        float2 pos = outCoord();
        float cosine = cos(outCoord().x*turbulence);
        float sine = sin(outCoord().y*turbulence);
        float2 offset = float2( dist.x*cosine + linDist.x, dist.y*sine + linDist.y );
        float fade = 1.0;
        
        //blending idea taken from the "light-tunnel" example
        pixel4 color = max( sample( src, pos ), sample( src, pos+offset )*fade );
        
        //fake for-loop
        
        fade *= dropOff;
        pos += offset;
        color = max( color, sample( src, pos+offset )*fade );
        
        fade *= dropOff;
        pos += offset;
        color = max( color, sample( src, pos+offset )*fade );
        
        fade *= dropOff;
        pos += offset;
        color = max( color, sample( src, pos+offset )*fade );
        
        fade *= dropOff;
        pos += offset;
        color = max( color, sample( src, pos+offset )*fade );
        
        fade *= dropOff;
        pos += offset;
        color = max( color, sample( src, pos+offset )*fade );
        
        fade *= dropOff;
        pos += offset;
        color = max( color, sample( src, pos+offset )*fade );
        
        fade *= dropOff;
        pos += offset;
        color = max( color, sample( src, pos+offset )*fade );
        
        dst = color;
    }
}
Retrieved from "http://labs.adobe.com/wiki/index.php/Displaced_Halation_hydra"