<jittershader name="rgba2grgb">
	<description>
	converts full chroma rgba data to grgb data packed as rgba data (rgbg on GPU)
	</description>
	<param name="chromasmooth" type="float" default="1." />
	<language name="glsl" version="1.0">
		<bind param="chromasmooth" program="fp" />
		<program name="vp" type="vertex" source="sh.passthru.xform.vp.glsl" />
		<program name="fp" type="fragment">
<![CDATA[

// texcoords
varying vec2 texcoord0;

// parameters
uniform float chromasmooth;

// samplers
uniform sampler2DRect tex0;

// entry point
void main()
{   
	// round to nearest pixel centered coordinates 
	// (reason for adding 0.5 to account for GL_LINEAR)
	vec2 coord_left = vec2(floor(texcoord0.x)+0.5,texcoord0.y);
	vec2 coord_right = vec2(floor(texcoord0.x+1.)+0.5,texcoord0.y);
	
	// sample  data points (are actually  since to argb => rgba)
	vec4 rgba_left = texture2DRect(tex0, coord_left);
	vec4 rgba_right = texture2DRect(tex0, coord_right);
	
	vec4 rgbg_val;

	rgbg_val.a = rgba_left.g;
	rgbg_val.g = rgba_right.g;
	// averaging chroma downsample if chromasmooth is on
	rgbg_val.rb = mix(rgba_left.rb,(rgba_left.rb+rgba_right.rb)*vec2(0.5),vec2(chromasmooth>0.5)); 
	
	gl_FragColor = rgbg_val;
}

]]>
		</program>
	</language>
</jittershader>








