<jittershader name="contrast-interp">
	<description>Shader for for modifying image contrast by interpolation and extrapolation</description>
	<param name="image" type="int" default="0" />
	<param name="avgluma" type="vec3" default="0.62 0.62 0.62" />
	<param name="contrast" type="float" default="1.0" />
	<param name="brightness" type="float" default="1.0" />
	<param name="saturation" type="float" default="1.0" />
	<param name="alpha" type="float" default="1.0" />
	<language name="glsl" version="1.0">
		<bind param="image" program="fp" />
		<bind param="avgluma" program="fp" />
		<bind param="contrast" program="fp" />
		<bind param="brightness" program="fp" />
		<bind param="saturation" program="fp" />
		<bind param="alpha" program="fp" />
		<program name="vp" type="vertex">
<![CDATA[
//
// Vertex shader for modifying image contrast by
// interpolation and extrapolation
//
// Author: Randi Rost
//
// Copyright (c) 2003-2005: 3Dlabs, Inc.
//
// See 3Dlabs-License.txt for license information
//

varying vec2 texcoord;

void main (void)

{
    gl_Position = ftransform();
    texcoord    = vec2(gl_TextureMatrix[0] * gl_MultiTexCoord0);
}
]]>		
		</program>
		<program name="fp" type="fragment">
<![CDATA[
//
// Fragment shader for modifying image contrast by
// interpolation and extrapolation
//
// Author: Randi Rost
//
// Copyright (c) 2002: 3Dlabs, Inc.
//
// See 3Dlabs-License.txt for license information
//

const vec3 LumCoeff = vec3 (0.2125, 0.7154, 0.0721);

varying vec2 texcoord;
uniform sampler2DRect image;

uniform vec3 avgluma;
uniform float saturation;
uniform float contrast;
uniform float brightness;
uniform float alpha;

void main (void)
{
	vec3 texColor  	= texture2DRect(image, texcoord).rgb;
	vec3 intensity 	= vec3 (dot(texColor, LumCoeff));
	vec3 color     	= mix(intensity, texColor, saturation);
	color          	= mix(avgluma, color, contrast);
	color			*= brightness;
	gl_FragColor   	= vec4 (color, color.g*alpha);
}
]]>		
		</program>		
	</language>
</jittershader>
