blob: bf491f13dec1281ae617376cf6f19abd87ec33b0 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
<languageVersion : 1.0;>
kernel Crossfade
< namespace : "flex";
vendor : "Adobe Systems";
version : 1;
description : "Crossfade between two images, for use with Flex effects"; >
{
parameter float progress;
parameter float width;
parameter float height;
// First parameter is unused in AnimateTransitionShader effect
input image4 src0;
input image4 from;
input image4 to;
output pixel4 dst;
void evaluatePixel()
{
// Acquire the pixel values from both images at the current location
float2 coord = outCoord();
float4 color0 = sampleNearest(src0, coord);
float4 fromPixel = sampleNearest(from, coord);
float4 toPixel = sampleNearest(to, coord);
float prog = progress;
// Output equals mixture of two pixels, according to progress value
dst = mix(fromPixel, toPixel, progress);
// workaround for Flash filter bug that replicates last column/row
if (coord.x >= width || coord.y >= height)
dst.a = 0.0;
}
}