
#version 330

varying vec4 Normal;
varying vec4 Position;
varying vec4 Position2;
uniform float ID;
uniform float ttime;
uniform float _dat_x;

varying vec4 Color;
varying float fc0;

void main () 
{





	float fdot = dot(vec3(0, 1, 0), Normal.xyz);
	fdot = clamp(fdot, 0.0, 1.0);


	vec4 MyColor = Color.xyzw;
	MyColor = vec4(0.5, 0.2, 1.0, 1);
	float fc;
	fc = 1.0;
	fc = fdot;
	fc = 0.5 + 0.5*sin(float(gl_PrimitiveID));
	fc = (gl_PrimitiveID%2);


	float ftc = sin(5.0*ttime + float(gl_PrimitiveID)*0.06);
	ftc = pow(1.1*ftc, 12.0);
	ftc = 1.0+10.0*clamp(ftc, 0.0, 1.0);
//tc = 1.0;
	if (gl_PrimitiveID % 4 == 0)		MyColor = vec4(1.0, 0.2, 0.2, 1.0);
	if (gl_PrimitiveID % 9 == 0)		MyColor = vec4(0.2, 0.2, 1.0, 1.0);
	if (gl_PrimitiveID % 7 == 0)		MyColor =vec4 (1.0,1.0,0.2,1.0);
	//vec4(1.0, 0.0, 0.0, 1.0);
	//MyColor = vec4(1.0, 1.0, 0.0, 1.0);
	
	MyColor *= ftc;
	float ffc = sin(-110.0*float(ttime*0.1+Position.z+ 0.03*Position2.y+0.03*Position2.x));
	 //ffc = sin(20.0*float(Position.x));
	//sin((Position.y + Position.x)*200.0);
	if (ffc < -0.5)
		ffc = 1.0; else ffc = 0.1;
	//MyColor = vec4(1.0);
	//ffc = 1.0;
	fc = 1.0;
	fc *= ffc;
	//MyColor.xyz = vec3(1.0)*ffc;
//	fc = 1.0;
	//fc *= fc0*100.0;
	// RGB albeido
	//gl_FragData[0].xyzw = Normal.xyzz;
	//gl_FragData[0].xyzw = vec4 (1.0)*fdot;
	float fog = gl_FragCoord.x;
	fog = 1.0/pow(fog, 1.0);
	gl_FragData[0].xyzw = MyColor*Color*fc+vec4 (0.0)*ftc;
	


	//gl_FragData[0].xyz = vec3(1.0)*length(gl_FragData[0].xyz);
	//gl_FragData[0].xyz = vec3(pow (gl_FragCoord.z*1.0,200.0));
	//gl_FragData[0].xyzw = Color.xyzz;
	//*vec4(0.0, 1, 0.0, 0.0);;
	//Color.xyzw;
	
	
	
	
	
	
	
	
	//*_dat_x;
	//vec4(0.0);

gl_FragData[1].xyzw = vec4(0, 0.5, 1, 1);


}
