////////////////////////////////////////////////////////////////////////////////
//
//  ADOBE SYSTEMS INCORPORATED
//  Copyright 2008 Adobe Systems Incorporated
//  All Rights Reserved.
//
//  NOTICE: Adobe permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
<languageVersion : 1.0;>
kernel WipeUp
<   namespace : "flex";
    vendor : "Adobe";
    version : 1;
    description : "Wipe up between two images for Flex effects";
>
{
    // first input is unused in AnimateTransitionShader effect
    input image4 src0;
    input image4 from;
    input image4 to;
    output pixel4 dst;

    parameter float progress<
        minValue: 0.00;
        maxValue: 1.00;
        defaultValue: 0.0;
    >;

    parameter float width<
        minValue: 0.0;
        maxValue: 1024.0;
        defaultValue: 576.0;
    >;

    parameter float height<
        minValue: 0.00;
        maxValue: 1024.0;
        defaultValue: 384.0;
    >;
    
    void
    evaluatePixel()
    {
        float2 coord = outCoord();

        // Use src0 in a branch we won't reach just to defeat the 
        // optimizer from removing the input parameter
        if ((height * (1.0 - progress)) >= coord.y) 
            dst = sampleNearest(from, coord);
        else if (progress < 100.0)
            dst = sampleNearest(to, coord);
        else
            dst = sampleNearest(src0, coord);
        // workaround for Flash filter bug that replicates last column/row
        if (coord.x >= width || coord.y >= height)
            dst.a = 0.0;
    }
}
