 	vec3 specular;
 };
 
+varying vec3 vPosition;
+varying vec3 vNormal;
+varying vec2 vUv;
+
 uniform vec3 uEmissive;
 uniform vec3 uDiffuse;
 uniform vec3 uSpecular;
 uniform float uShininess;
-
 uniform vec3 uEyePosition;
 
 #if MAX_POINT_LIGHTS > 0

#if MAX_DIRECTIONAL_LIGHTS > 0
  for(int i = 0; i < MAX_DIRECTIONAL_LIGHTS; i++)
  {
		float q = max(dot(uDirectionalLights[i].direction, n), 0.0);

		if (q > 0.0) {
			vec3 r = reflect(-uDirectionalLights[i].direction, n);
			float w = pow(max(dot(r, v), 0.0), uShininess);

    	diffuse += uDirectionalLights[i].diffuse * uDiffuse * q;
			specular += uDirectionalLights[i].specular * uSpecular * w;

#endif

#ifdef DIFFUSE_MAP
	diffuse *= texture2DLodEXT(uDiffuseSampler, vUv, 0.0).rgb;
#endif

#ifdef SPECULAR_MAP
	specular *= vec3(texture2D(uSpecularSampler, vUv));
#endif

#ifdef REFLECTION
	vec3 reflection = reflect(-v, n);
	diffuse *= textureCubeLodEXT(uEnvironmentSampler, reflection, 0.0).rgb;
#endif

#ifdef REFRACTION
	vec3 refraction = refract(-v, n, uRefractFactor);
	diffuse *= textureCubeLodEXT(uEnvironmentSampler, refraction, 0.0).rgb;
#endif

  gl_FragColor = vec4(emissive + diffuse + specular, 1.0);
