//pref
Ambient|float|0|0.9|2
Diffuse|float|0|0.9|2
Specular|float|0|0.5|2
Shininess|float|1|80|120
Hemispheric lighting: "Ambient" is second light source from above with reflection from below. Copyright 2015 Chris Rorden, BSD2clause.|note
//vert
#version 330
layout(location = 0) in vec3 Vert;
layout(location = 3) in vec3 Norm;
layout(location = 6) in vec4 Clr;
out vec3 vN, vL, vV;
out vec4 vClr, vP;
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelViewMatrix;
uniform mat3 NormalMatrix;
uniform vec3 LightPos = vec3(0.0, 20.0, 30.0); //LR, -DU+, -FN+
void main() {
    vN = normalize((NormalMatrix * Norm));
    vP = vec4(Vert, 1.0);
    gl_Position = ModelViewProjectionMatrix * vec4(Vert, 1.0);
    vL = normalize(LightPos);
    vV = -vec3(ModelViewMatrix*vec4(Vert,1.0));
    vClr = Clr;
}
//frag
#version 330
in vec4 vClr, vP;
in vec3 vN, vL, vV;
out vec4 color;
uniform float Ambient = 0.5;
uniform float Diffuse = 0.7;
uniform float Specular = 0.2;
uniform float Shininess = 60.0;
uniform vec4 ClipPlane = vec4(2.0, 0.0, 0.0, 0.0);

void main() {
	if ((ClipPlane[0] < 1.5) && (dot( ClipPlane, vP) > 0.0)) discard;
	vec3 l = normalize(vL);
	vec3 n = normalize(vN);
	vec3 h = normalize(l+normalize(vV));
	vec3 a = vClr.rgb;
	vec3 d = a;
	vec3 up = vec3(0.0, 1.0, 0.0);
	float ax = dot(vN, up) * 0.5 + 0.5; //Shreiner et al. (2013) OpenGL Programming Guide, 8th Ed., p 388. ISBN-10: 0321773039
	vec3 upClr = vec3(0.9, 0.9, 1.0); //a bit of blue from reflects sky
	vec3 downClr = vec3(0.6, 0.6, 0.55); //darker yellow from ground
	a *= mix(downClr, upClr,  ax) * abs(dot(vN, up)); //note: unlike book we make edges dark!
	float diff = dot(n,l);
	float spec = pow(max(0.0,dot(n,h)), Shininess);
	vec3 backcolor = Ambient*vec3(0.1+0.1+0.1) + d*abs(diff)*Diffuse;
	float backface = step(0.00, n.z);
	color = vec4(mix(backcolor.rgb, a*Ambient + d*diff*Diffuse + spec*Specular,  backface), 1.0);
}