_Assemble.vsh
{
	uniform	mat4	u_ModelViewMatrix;
	uniform	mat4	u_ModelViewProjectionMatrix;
	uniform float 	u_ambientScale;
	#if defined(CLIP)
		out	vec3	v_clipVertex;
	#endif
	out	vec4	color;
	include deforms.inc
	include colorGen.inc
	void main(void)
	{
		vec4 glVertex = DeformGeometry();
		color = colorGen(glVertex.xyz, u_gen, u_parm0, u_parm1, u_parm2, u_parma) * vec4(vec3(u_ambientScale), 1.0);
		gl_Position = u_ModelViewProjectionMatrix * glVertex;
		include clipVertex.inc
	}
}

_Assemble.fsh
{
	#extension GL_ARB_texture_rectangle: enable
	uniform sampler2DRect	u_ColorBuffer;
	uniform sampler2DRect	u_SpecularBuffer;
	#if defined(ALPHATEST)
		uniform float	u_AlphaTestValue;
	#endif
	#if defined(CLIP)
		uniform vec4	u_clipPlane;
		in	vec3	v_clipVertex;
	#endif
	in	vec4	color;
	out	vec4	fragColor;
	void main(void)
	{
		include clipPlane.inc
		if (texture2DRect(u_SpecularBuffer, gl_FragCoord.xy).a == 1.0)
		{
			discard;	// no portal surfaces draw
			return;
		}
		vec4 pix = texture2DRect(u_ColorBuffer, gl_FragCoord.xy) * color;
		include alpha_test.inc
		fragColor = pix;
	}
}


_AmbientLight.vsh
{
	uniform	mat4	u_ModelViewMatrix;
	uniform	mat4	u_ModelViewProjectionMatrix;
	#if defined(CLIP)
		out	vec3	v_clipVertex;
	#endif
	include deforms.inc
	void main(void)
	{
		vec4 glVertex = DeformGeometry();
		gl_Position = u_ModelViewProjectionMatrix * glVertex;
		include clipVertex.inc
	}
}

_AmbientLight.fsh
{
	#extension GL_ARB_texture_rectangle: enable
	uniform sampler2DRect	u_ColorBuffer;
	uniform sampler2DRect	u_SpecularBuffer;
	uniform sampler2DRect	u_LightDiffuseBuffer;
	uniform sampler2DRect	u_LightSpecularBuffer;
	#if defined(CLIP)
		uniform vec4	u_clipPlane;
		in	vec3	v_clipVertex;
	#endif
	out	vec3		fragColor;
	void main(void)
	{
		include clipPlane.inc
		vec4 specular = texture2DRect(u_SpecularBuffer, gl_FragCoord.xy);
		if (specular.a == 1.0)
		{
			discard;	// no portal surfaces draw
			return;
		}
		vec3 diffuse = texture2DRect(u_ColorBuffer, gl_FragCoord.xy).rgb;
		vec3 lightD = texture2DRect(u_LightDiffuseBuffer, gl_FragCoord.xy).rgb;
		vec3 lightS = texture2DRect(u_LightSpecularBuffer, gl_FragCoord.xy).rgb;
		fragColor = lightD * diffuse + lightS * specular.rgb;
	}
}


_FBO2Screen.vsh
{
	include generic_vertex.vsh
}

_FBO2Screen.fsh
{
	#extension GL_ARB_texture_rectangle: enable
	uniform sampler2DRect	u_ColorBuffer;
	out	vec3		fragColor;
	void main(void)
	{
		fragColor = texture2DRect(u_ColorBuffer, gl_FragCoord.xy).rgb;
	}
}


_FBO2ScreenDistorted.vsh
{
	include generic_vertex.vsh
}

_FBO2ScreenDistorted.fsh
{
	#extension GL_ARB_texture_rectangle: enable
	uniform sampler2DRect	u_ColorBuffer;
	uniform sampler2DRect	u_DistortBuffer;
	uniform vec2		u_Scale;
	out	vec3		fragColor;
	void main(void)
	{
		vec3 tsm = texture2DRect(u_DistortBuffer, gl_FragCoord.xy).xyz;
		vec2 ts = gl_FragCoord.xy + tsm.z * (tsm.xy - 0.5) * u_Scale;
		fragColor = texture2DRect(u_ColorBuffer, ts).rgb;
	}
}
