/*uniform vec3		sundir;
varying float		h;
varying vec3		vPos;
varying vec3		cnormal;
uniform float 		inScatter;
uniform float 		sunpower;
uniform vec3		fogColor;
uniform float 		extintion;
varying vec3 		baseColor;

// costanti passate allo shader
uniform vec3  SUN; 	// = colore del sole
uniform vec3  cBr; 	// = RayLeigh
uniform vec3  cBm; 	// = Mie	
uniform	vec3  C0; 	// = cBr+cBm;	
uniform vec3  C1; 	// = 1.0/(cBr+cBm);

uniform float C4;	// = (1-g)^2
uniform float C5;	// = 1+g^2
uniform float C6;	// = 2*g
uniform float C7;	// = 3/2
//uniform float		fogMultiplier;

varying vec3  cC0;*/

varying vec3  	skyColor;
varying vec3 	fFex;
varying vec3 	fLin;

/*uniform vec3  campos;
uniform float cHeightFallof;

float cVolFogHeightDensityAtViewer=exp( cHeightFallof * -campos.y);
//float cFarDistance=100000.0;

float ComputeVolumetricFog( vec3 cameraToWorldPos )
{
	float fogInt = length( cameraToWorldPos )*cVolFogHeightDensityAtViewer;
	if( abs(cameraToWorldPos.y ) > 0.01)
	{
		float t = cHeightFallof * cameraToWorldPos.y;
		fogInt *= ( 1.0-exp( -t ) ) / t;
	}
	return exp( -extintion*0.005 * fogInt);
}*/

////////////////////////////
void main()
{
/*	float cos=dot(-sundir,normalize(cnormal));
	float cos2=(1.0-step(-cos,0.9999))*16.0;
	
	// SKY //////////////////////////////////////////////////////
	float F1=(1.0 + cos*cos);
	float F2=(C4/pow(C5-C6*cos,C7));

	vec3 Br = cBr*F1;
	vec3 Bm = cBm*F2;

	vec3 Fex=exp(-cC0*5000000.0);
	vec3 LinMul=C1*(1.0-Fex);
	vec3 Lin = (Br+Bm)*LinMul*inScatter*0.005;
	vec3 scatterColor=baseColor + Lin;
	vec3 skyColor=(scatterColor + cos2*Lin);*/
	
	// FOG /////////////////////////////////////////////////////
	/*vec3 viewDir=vPos-campos;
	float distance=length(viewDir);
	float delta=(1.0-ComputeVolumetricFog(viewDir))*distance;	
	vec3 fFex=exp(-C0*delta);
	float fF1=(1.0 + cos*cos*0.2);
	vec3 fLin=( (fF1*cBr) )*C1*(1.0-fFex)*inScatter*fogColor*0.005;*/

	// BLENDING ///////////////////////////////////
	gl_FragColor.xyz=fLin+fFex*skyColor.xyz;
	gl_FragColor.w=1.0;
}
