// loopit 2006


struct v2f {
	float4 position  : POSITION;
	float2 texcoords : TEXCOORD0;

	float fogc : FOGC;

	float3 amb_col   : TEXCOORD4;
	float3 diff_col  : TEXCOORD5;
	float3 spec_col  : TEXCOORD6;
};

void main( in v2f IN,
					 in uniform float4 fogcol : state.fog.color,
					 in uniform float4 fogparams : state.fog.params,
					 out float4 colOut : COLOR0) {

	colOut.rgb = IN.amb_col + IN.diff_col + IN.spec_col;

	float fog_exp = fogparams.x * IN.fogc;
  //float fog_factor = exp( - fog_exp * fog_exp );  //EXP2
	float fog_factor = exp( - fog_exp );  //EXP

	colOut.rgb = lerp( fogcol.rgb, colOut.rgb, saturate( fog_factor ) ); 
	colOut.a = 1;
}
