precision highp float;

uniform vec4 cuttingplane; //object space -> contains normal. 4th coordinate is simply -1 or +1....multiplier....determine which side of the plane we are on...

varying vec2 texCoord;
varying vec2 bumptexCoord;
varying vec3 tmpNormal;
varying vec3 tmpPosition; //object space

uniform sampler2D textureUnit0;

void main ()
    vec3 cuttingnormal = cuttingplane.w * vec3(cuttingplane.x,cuttingplane.y,cuttingplane.z);
    float al = max(sign(dot(cuttingnormal,tmpPosition)),0.0);
    vec4 base = texture2D(textureUnit0, texCoord);
    vec4 bump = texture2D(textureUnit0, bumptexCoord);
    float bumpf = clamp((bump.r+bump.g+bump.b)*0.333,0.0,1.0);
    float bumpf2 = clamp((base.r+base.g+base.b)*0.333,0.0,1.0);
    vec3 altNormal = normalize(vec3(tmpNormal.x+(2.0*(bumpf - bumpf2)),tmpNormal.y+(2.0*(bumpf - bumpf2)),tmpNormal.z));
    vec3 tmpVec = -1.0*normalize(vec3(0.2,-0.1,1.0));
    float mydiffuse = max(dot(tmpVec,altNormal),0.0);
    float myspecular = pow(clamp(max(dot(reflect(tmpVec,altNormal),tmpVec),0.0),0.0,1.0),24.0);
    gl_FragColor = (base*mydiffuse*3.0+base*myspecular*1.5);
    gl_FragColor.a = al;