varying vec4 pos3D;
varying vec3 light, normal;
   
void main()
{
		vec3 halfV = normalize(light - pos3D);
    
    vec3 toFresnel = normalize(-pos3D);
    
    vec3 n = normal.xyz;

		float nDotL = max(dot(n, halfV), 0.0);
    
    float fresnel = pow(max(dot(n, toFresnel), 0.0), 0.5);
    
    fresnel = clamp(pow(1.0 - fresnel, 1.0), 0.0, 1.0);
    
    //fresnel = (fresnel + _depth.a)* 0.5;
    //piFresnel = fresnel;
   
    vec4 color;
   
    //color.rgb = vec3(0.2, 0.0, 0.0);
    color.rgb = vec3(0.8, 0.65, 0.65);

		//diffuse
		//color.rgb = mix(vec3(0.0, 0.02, 0.1), color, max(0.1, nDotL));
    color.rgb = mix(vec3(0.0, 0.02, 0.15), color, max(0.1, nDotL));
		//specular
		color.rgb = mix(color.rgb, vec3(1.0, 1.0, 1.0), clamp(pow(nDotL, 160.0) * 1.7, 0.0, 1.0));

    //color.rgb += pow(1.0 - gm, 5.0);

    color.rgb += vec3(fresnel * 1.0);


  gl_FragData[0] = gl_Color * vec4(color.rgb, 1.0);
  
  gl_FragDepth = gl_FragCoord.z;
}
