Legal
The views expressed in this blog are my own and do not necessarily reflect the views of Adobe Systems Incorporated.
Search
May 21, 2008
the formatter in action!
I forgot to post the example! Here is the Fade To History kernel I posted yesterday, run through the formatter:
<languageVersion: 1.0;>
kernel FadeToHistory
< namespace : "Kevin's Tutorial Filters";
vendor : "Kevin's Filters, Inc";
version : 1;
description : "Fade from color to B&W to sepia";
>
{
parameter float crossfade
< minValue: 0.0;
maxValue: 2.0;
defaultValue: 0.0;
>;
const float3 lumMult = float3(0.3, 0.59, 0.11);
input image4 src;
output pixel4 dst;
void
evaluatePixel()
{
dst = sampleNearest(src,outCoord());
float luminance = dot(dst.rgb, lumMult);
float3 sepia = float3( dst.r * 0.4 +
dst.g * 0.769 +
dst.b * 0.189,
dst.r * 0.349 +
dst.g * 0.686 +
dst.b * 0.168,
dst.r * 0.272 +
dst.g * 0.534 +
dst.b * 0.131 );
float3 startMix = dst.rgb;
float3 endMix = float3(luminance);
float mixValue = crossfade;
if ( crossfade > 1.0 )
{
// normalize mix value to the range of 0-1
mixValue -= 1.0;
startMix = float3(luminance);
endMix = sepia;
}
dst.rgb = mix(startMix, endMix, mixValue);
}
}
kernel FadeToHistory
< namespace : "Kevin's Tutorial Filters";
vendor : "Kevin's Filters, Inc";
version : 1;
description : "Fade from color to B&W to sepia";
>
{
parameter float crossfade
< minValue: 0.0;
maxValue: 2.0;
defaultValue: 0.0;
>;
const float3 lumMult = float3(0.3, 0.59, 0.11);
input image4 src;
output pixel4 dst;
void
evaluatePixel()
{
dst = sampleNearest(src,outCoord());
float luminance = dot(dst.rgb, lumMult);
float3 sepia = float3( dst.r * 0.4 +
dst.g * 0.769 +
dst.b * 0.189,
dst.r * 0.349 +
dst.g * 0.686 +
dst.b * 0.168,
dst.r * 0.272 +
dst.g * 0.534 +
dst.b * 0.131 );
float3 startMix = dst.rgb;
float3 endMix = float3(luminance);
float mixValue = crossfade;
if ( crossfade > 1.0 )
{
// normalize mix value to the range of 0-1
mixValue -= 1.0;
startMix = float3(luminance);
endMix = sepia;
}
dst.rgb = mix(startMix, endMix, mixValue);
}
}
Trackbacks
TrackBack URL for this entry:
http://blogs.adobe.com/cgi-bin/mt-tb.cgi/908
Comments
Thank you for signing in, You may now comment. (Sign Out)
(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)