TwoTerm/ScanLineFilter.cikernel

26 lines
428 B
Plaintext
Raw Normal View History

/*
* simulate scanlines by darkening every other line.
*
*/
kernel vec4 scanline(sampler image, float strength)
{
vec4 fudge = vec4( 0.4, 0.4, 0.4, 0.0 );
vec2 coord = samplerCoord(image);
vec4 pixel = sample(image, coord);
fudge *= strength;
float yy = mod(coord.y, 2.0);
fudge *= (yy < 1.0) ? 1.0 : -1.0;
pixel = unpremultiply(pixel);
pixel += fudge;
return premultiply(pixel);
}