//.name Window
//.category Filters; Colors
//.param float window; 0.01; 1.0; Window; 1.0
//.param float level; -0.5; 1.5; Level; 0.5
//.input sampler2D tex0; Input

uniform sampler2D tex0;
uniform float window;
uniform float level;

void main(void)
{
	vec4 a = texture2D(tex0, gl_TexCoord[0].st);
	gl_FragColor = vec4(
				mix(
					step(level + window / 2.0, a.rgb),
					step(level - window / 2.0, a.rgb),
					(a.rgb - (level - window / 2.0)) / window
				),
			a.a);
}
