#version 120

#ifdef GL_ES
// define default precision for float, vec, mat.
precision lowp float;
#endif

//varying vec4 outColor;
varying vec4 outTColor; // texture format compensation color
//varying vec4 outFogColor;

varying vec4 premulOutColor;
varying vec4 premulOutFogColor;

uniform sampler2D tex;

void main()
{
#ifdef GL_ES
	vec2 pc = gl_PointCoord;
	vec4 diffuseColor = texture2D(tex, pc);
#else
	vec4 diffuseColor = vec4(1.0,1.0,1.0,1.0);
#endif
/*
	vec4 color = outColor * (diffuseColor + outTColor);
	if (color.w < 0.3) discard;
	gl_FragColor = vec4(color.xyz*(1.0-outFogColor.w) + outFogColor.xyz*outFogColor.w, color.w);
*/
	vec4 color = premulOutColor + (diffuseColor + outTColor) * premulOutFogColor.w;
	if (color.w < 0.3) discard;
	gl_FragColor = color + vec4(premulOutFogColor.xyz, 0.0);
}
