
#version 330

varying vec4 Normal;
varying vec4 Position;
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;

	float fc;
	fc = 1.0;
	fc = fdot;
	fc = 0.5 + 0.5*sin(float(gl_PrimitiveID));
	fc = (gl_PrimitiveID%2);
	
	
	if (gl_PrimitiveID % 5 == 0)		MyColor = vec4(1.0, 0.0, 0.0, 1.0);
	if (gl_PrimitiveID % 7 == 0)		MyColor = vec4(0.0, 1.0, 1.0, 1.0);
	if (gl_PrimitiveID % 3 == 0)		MyColor =vec4 (1.0,1.0,0.0,1.0);
	//vec4(1.0, 0.0, 0.0, 1.0);
	//MyColor = vec4(1.0, 1.0, 0.0, 1.0);

	
	float ffc = sin(-240.0*float(ttime*0.15+Position.x + Position.y));
	 //ffc = sin(20.0*float(Position.x));
	//sin((Position.y + Position.x)*200.0);
	if (ffc < 0.0)
		ffc = 1.0; else ffc = 0.0;
	//MyColor = vec4(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;

	gl_FragData[0].xyzw = MyColor*Color*fc;
	//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);


}
