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

_replace_soft.fsh
{
	uniform sampler2D	u_ColorMap;
	uniform float		u_ColorMapSwizzle;
	uniform sampler2DRect	u_DepthMap;
	uniform vec3		u_depthParms;	// x = -zFar * zNear, y = zFar - zNear, z = zFar
	uniform float		u_softness;	// 1.0 / soft
	#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;
	in	float		depth;
	out	vec4		fragColor;
	include Texture.inc
	void main(void)
	{
		include clipPlane.inc
		vec4 pix = color * Texture(u_ColorMap, texCoord, u_ColorMapSwizzle);
		include alpha_test.inc
		float dp = u_depthParms.x / (texture(u_DepthMap, gl_FragCoord.xy).r * u_depthParms.y - u_depthParms.z);
		float softness = clamp((dp - depth) * u_softness, 0.0, 1.0);
		fragColor = pix * softness;
	}
}


_multitexture_soft.vsh
{
	uniform	mat4	u_ModelViewMatrix;
	uniform	mat4	u_ModelViewProjectionMatrix;
	#if defined(CLIP)
		out	vec3	v_clipVertex;
	#endif
	out	vec4	color0;
	out	vec4	color1;
	out	vec4	texCoords;
	out	float	depth;
	include deforms.inc

	uniform	vec4	u_gen_t2;
	uniform	vec4	u_parm0_t2;
	uniform	vec4	u_parm1_t2;
	uniform	vec4	u_parm2_t2;
	uniform	vec4	u_parma_t2;
	include colorGen.inc

	include tcGen_multitexture.inc
	void main(void)
	{
		mat2 dummy;
		vec4 glVertex = DeformGeometry(dummy);
		tcGen(texCoords.xy, texCoords.zw, glVertex.xyz);
		color0 = colorGen(glVertex.xyz, u_gen, u_parm0, u_parm1, u_parm2, u_parma);
		color1 = colorGen(glVertex.xyz, u_gen_t2, u_parm0_t2, u_parm1_t2, u_parm2_t2, u_parma_t2);
		vec4 pos = u_ModelViewProjectionMatrix * glVertex;
		depth = pos.z;
		gl_Position = pos;
		include clipVertex.inc
	}
}

_multitexture_soft.fsh
{
	uniform sampler2D	u_ColorMap0;
	uniform float		u_ColorMap0Swizzle;
	uniform sampler2D	u_ColorMap1;
	uniform float		u_ColorMap1Swizzle;
	uniform sampler2DRect	u_DepthMap;
	uniform vec3		u_depthParms;	// x = -zFar * zNear, y = zFar - zNear, z = zFar
	uniform float		u_softness;	// 1.0 / soft
	uniform vec2		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;
	in	float		depth;
	include Blend.inc
	include Texture.inc
	out	vec4		fragColor;
	void main(void)
	{
		include clipPlane.inc
		vec4 d = Texture(u_ColorMap0, texCoords.xy, u_ColorMap0Swizzle) * color0;
		vec4 s = Texture(u_ColorMap1, texCoords.zw, u_ColorMap1Swizzle) * color1;
		vec4 pix = Blend(s, d, u_Blend);
		include alpha_test.inc
		float dp = u_depthParms.x / (texture(u_DepthMap, gl_FragCoord.xy).r * u_depthParms.y - u_depthParms.z);
		float softness = clamp((dp - depth) * u_softness, 0.0, 1.0);
		fragColor = pix * softness;
	}
}

_interpolate_soft.vsh
{
	uniform	mat4	u_ModelViewMatrix;
	uniform	mat4	u_ModelViewProjectionMatrix;
	#if defined(CLIP)
		out	vec3	v_clipVertex;
	#endif
	out	vec4	color;
	out	vec4	texCoords;
	out	float	depth;
	include deforms.inc
	include colorGen.inc
	include tcGen_multitexture.inc
	void main(void)
	{
		mat2 dummy;
		vec4 glVertex = DeformGeometry(dummy);
		tcGen(texCoords.xy, texCoords.zw, glVertex.xyz);
		color = colorGen(glVertex.xyz, u_gen, u_parm0, u_parm1, u_parm2, u_parma);
		vec4 pos = u_ModelViewProjectionMatrix * glVertex;
		depth = pos.z;
		gl_Position = pos;
		include clipVertex.inc
	}
}

_interpolate_soft.fsh
{
	uniform sampler2D	u_ColorMap0;
	uniform float		u_ColorMap0Swizzle;
	uniform sampler2D	u_ColorMap1;
	uniform float		u_ColorMap1Swizzle;
	uniform sampler2DRect	u_DepthMap;
	uniform vec3		u_depthParms;	// x = -zFar * zNear, y = zFar - zNear, z = zFar
	uniform float		u_softness;	// 1.0 / soft
	#if defined(CLIP)
		uniform vec4	u_clipPlane;
		in	vec3	v_clipVertex;
	#endif
	in	vec4		color;
	in	vec4		texCoords;
	in	float		depth;
	vec3			sample0;
	vec4			sample1;
	float			alpha;
	out	vec4		fragColor;
	include Texture.inc
	void main(void)
	{
		include clipPlane.inc
		sample0 = Texture(u_ColorMap0, texCoords.xy, u_ColorMap0Swizzle).rgb;
		sample1 = Texture(u_ColorMap1, texCoords.zw, u_ColorMap1Swizzle);
		alpha = sample1.a * color.a;
		vec4 pix = vec4(color.rgb * mix(sample0, sample1.rgb, alpha), 1.0);
		float dp = u_depthParms.x / (texture(u_DepthMap, gl_FragCoord.xy).r * u_depthParms.y - u_depthParms.z);
		float softness = clamp((dp - depth) * u_softness, 0.0, 1.0);
		fragColor = pix * softness;
	}
}

_interpolate_at_soft.vsh
{
	uniform	mat4	u_ModelViewMatrix;
	uniform	mat4	u_ModelViewProjectionMatrix;
	#if defined(CLIP)
		out	vec3	v_clipVertex;
	#endif
	out	vec4	color;
	out	vec4	texCoords;
	out	float	depth;
	include deforms.inc
	include colorGen.inc
	include tcGen_multitexture.inc
	void main(void)
	{
		mat2 dummy;
		vec4 glVertex = DeformGeometry(dummy);
		tcGen(texCoords.xy, texCoords.zw, glVertex.xyz);
		color = colorGen(glVertex.xyz, u_gen, u_parm0, u_parm1, u_parm2, u_parma);
		vec4 pos = u_ModelViewProjectionMatrix * glVertex;
		depth = pos.z;
		gl_Position = pos;
		include clipVertex.inc
	}
}

_interpolate_at_soft.fsh
{
	uniform sampler2D	u_ColorMap0;
	uniform float		u_ColorMap0Swizzle;
	uniform sampler2D	u_ColorMap1;
	uniform float		u_ColorMap1Swizzle;
	uniform sampler2DRect	u_DepthMap;
	uniform vec3		u_depthParms;	// x = -zFar * zNear, y = zFar - zNear, z = zFar
	uniform float		u_softness;	// 1.0 / soft
	#if defined(CLIP)
		uniform vec4	u_clipPlane;
		in	vec3	v_clipVertex;
	#endif
	in	vec4		color;
	in	vec4		texCoords;
	in	float		depth;
	vec3			sample0;
	vec4			sample1;
	float			alpha;
	out	vec4		fragColor;
	include Texture.inc
	void main(void)
	{
		include clipPlane.inc
		sample0 = Texture(u_ColorMap0, texCoords.xy, u_ColorMap0Swizzle).rgb;
		sample1 = Texture(u_ColorMap1, texCoords.zw, u_ColorMap1Swizzle);
		alpha = sample1.a * color.a;
		vec4 pix = vec4(color.rgb * mix(sample0, sample1.rgb, alpha * step(0.5, alpha)), 1.0);
		float dp = u_depthParms.x / (texture(u_DepthMap, gl_FragCoord.xy).r * u_depthParms.y - u_depthParms.z);
		float softness = clamp((dp - depth) * u_softness, 0.0, 1.0);
		fragColor = pix * softness;
	}
}
