LevelReduction Hydra
From Adobe Labs
/*****************************************************************************
*
* Author: Jan Van Coppenolle
* http://compiler.kaustic.com/lab
*
*****************************************************************************/
kernel LevelReduction
{
parameter int channelLevels
<
minValue: 2;
maxValue: 256;
defaultValue: 256;
>;
void evaluatePixel(in image3 src, out pixel3 dst)
{
pixel3 px = sampleNearest(src, outCoord());
int3 bp = int3(px * 255.0) * channelLevels / 256;
dst = float3(bp) / float(channelLevels - 1);
}
}