// For standart Quake3 renderer (r_ppl = 0)

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

_replace.fsh
{
	uniform sampler2D	u_ColorMap;
	#if defined(ALPHATEST)
		uniform float	u_AlphaTestValue;
	#endif
	#if defined(CLIP)
		uniform vec4	u_clipPlane;
		in	vec3	v_clipVertex;
	#endif
	in	vec4		color;
	in	vec2		texCoord;
	out	vec4		fragColor;
	void main(void)
	{
		include clipPlane.inc
		vec4 pix = color * texture2D(u_ColorMap, texCoord);
		include alpha_test.inc
		fragColor = pix;
	}
}

_multitexture.vsh
{
	include multitexture.vsh
}

_multitexture.fsh
{
	uniform sampler2D	u_ColorMap0;
	uniform sampler2D	u_ColorMap1;
	uniform ivec2		u_Blend;
	#if defined(ALPHATEST)
		uniform float	u_AlphaTestValue;
	#endif
	#if defined(CLIP)
		uniform vec4	u_clipPlane;
		in	vec3	v_clipVertex;
	#endif
	in	vec4		color0;
	in	vec4		color1;
	in	vec4		texCoords;
	include Blend.inc
	out	vec4		fragColor;
	void main(void)
	{
		include clipPlane.inc
		vec4 d = texture2D(u_ColorMap0, texCoords.xy) * color0;
		vec4 s = texture2D(u_ColorMap1, texCoords.zw) * color1;
		vec4 pix = Blend(s, d, u_Blend);
		include alpha_test.inc
		fragColor = pix;
	}
}

_interpolate.vsh
{
	include interpolate.vsh
}

_interpolate.fsh
{
	uniform sampler2D	u_ColorMap0;
	uniform sampler2D	u_ColorMap1;
	#if defined(CLIP)
		uniform vec4	u_clipPlane;
		in	vec3	v_clipVertex;
	#endif
	in	vec4		color;
	in	vec4		texCoords;
	vec3			sample0;
	vec4			sample1;
	float			alpha;
	out	vec4		fragColor;
	void main(void)
	{
		include clipPlane.inc
		sample0 = texture2D(u_ColorMap0, texCoords.xy).rgb;
		sample1 = texture2D(u_ColorMap1, texCoords.zw);
		alpha = sample1.a * color.a;
		fragColor = vec4(color.rgb * mix(sample0, sample1.rgb, alpha), 1.0);
	}
}

_interpolate_at.vsh
{
	include interpolate.vsh
}

_interpolate_at.fsh
{
	uniform sampler2D	u_ColorMap0;
	uniform sampler2D	u_ColorMap1;
	#if defined(CLIP)
		uniform vec4	u_clipPlane;
		in	vec3	v_clipVertex;
	#endif
	in	vec4		color;
	in	vec4		texCoords;
	vec3			sample0;
	vec4			sample1;
	float			alpha;
	out	vec4		fragColor;
	void main(void)
	{
		include clipPlane.inc
		sample0 = texture2D(u_ColorMap0, texCoords.xy).rgb;
		sample1 = texture2D(u_ColorMap1, texCoords.zw);
		alpha = sample1.a * color.a;
		fragColor = vec4(color.rgb * mix(sample0, sample1.rgb, alpha * step(0.5, alpha)), 1.0);
	}
}
