//varying vec4 v_color;
varying vec4 v_select;
varying vec4 v_position;

void main() {
        vec3 xTangent = dFdx( v_position ).xyz;
	    vec3 yTangent = dFdy( v_position ).xyz;
    	vec3 faceNormal = normalize( cross( xTangent, yTangent ) );

	    float NdotL = max(dot(faceNormal, vec3(0,0,1)), 0.0);

	    gl_FragColor = NdotL * vec4(0.5,0.5,0.5,1);

        if (v_select.x == 1.0f)
            gl_FragColor = NdotL * vec4(0.2,0.0,0.2,1);
        else if (v_select.y == 1.0f || v_select.z == 1.0f)
            gl_FragColor = v_select.y * NdotL * vec4(0,0.5,0,0) + v_select.z * NdotL * vec4(0.5,0,0,0);
}
