varying vec2 TexCoord;
varying vec4 ViewCoords, ClrDiffuse;

uniform float SelfIllum;
uniform vec2 Eng_ObjID;
uniform sampler2D DiffuseMap;
uniform sampler2D Eng_EnvScreenShadows;

#ifdef _EngDef_ShadowsEnabled
/*const float sd = 1.0 / _EngDef_ShadowsScreenTextureSize;

bool compareID(in vec2 I1, in vec2 I2)
{
	return (int(I1.x * 255.0) == int(I2.x)) && (int(I1.y * 255.0) == int(I2.y));
}

vec4 getShadow(in vec2 C)
{
	float ret = 0.0;
	vec4 shadow = texture2D(Eng_EnvScreenShadows, C + vec2(-sd, -sd));
	ret = compareID(shadow.gb, Eng_ObjID) ? 1.0 : shadow.r;

	shadow = texture2D(Eng_EnvScreenShadows, C + vec2(sd, -sd));
	ret = min(ret, compareID(shadow.gb, Eng_ObjID) ? 1.0 : shadow.r);

	shadow = texture2D(Eng_EnvScreenShadows, C + vec2(sd, sd));
 	ret = min(ret, compareID(shadow.gb, Eng_ObjID) ? 1.0 : shadow.r);

	shadow = texture2D(Eng_EnvScreenShadows, C + vec2(-sd, sd));
	ret = min(ret, compareID(shadow.gb, Eng_ObjID) ? 1.0 : shadow.r);

	return vec4(ret);
} */
#endif

void main()
{
#ifdef _EngDef_ShadowsEnabled
    //vec2 ShadowCoords = ((ViewCoords.xy / ViewCoords.w) + 1.0) * 0.5;
	//vec4 shadow = getShadow(ShadowCoords);
	vec4 shadow = vec4(1.0);
#else
	vec4 shadow = vec4(1.0);
#endif
    
    vec4 Clr = ClrDiffuse * shadow.r + gl_LightSource[0].ambient + SelfIllum;
    Clr.a = 1.0;
    
	gl_FragColor = texture2D(DiffuseMap, TexCoord) * min(vec4(1.0), Clr);
}
