I wonder if someone would mind checking my code below. One is supposed to light in view space, the other in object space. (I think those are the right terms…)

```
varying vec3 vienon, halfve;
varying vec3 vienon, halfve;
void main()
{
vienon = normalize(gl_NormalMatrix * gl_Normal);
vec3 viepos = vec3(gl_ModelViewMatrix * gl_Vertex);
halfve = normalize(-normalize(viepos) + normalize(vec3(1.0, 1.0, 1.0)));
gl_Position = ftransform();
}
varying vec3 vienon, halfve;
void main()
{
vec3 n;
float NdotL, NdotHV;
n = normalize(vienon);
NdotL = max(dot(n, normalize(vec3(1.0, 1.0, 1.0))), 0.0);
NdotHV = max(dot(n, normalize(halfve)), 0.0);
vec4 difcom = vec4(0.8, 0.8, 0.8, 1.0) * NdotL;
vec4 specom = pow(NdotHV, 128);
//vec4 ambcom = vec4(0.2, 0.2, 0.2, 1.0);
vec4 color = 0;
//color += ambcom;
color += specom;
color += difcom;
gl_FragColor = color;
}
```

```
varying vec3 objnor, halfve;
#version 120
void main()
{
objnor = normalize(gl_Normal);
vec3 viepos = vec3(gl_ModelViewMatrix * gl_Vertex);
//Convert the light direction into view coordinates, find the half-vector, then convert back again?
halfve = normalize(vec3(transpose(gl_ModelViewMatrix) * vec4(normalize(-normalize(viepos) + normalize(gl_NormalMatrix * vec3(1.0, 1.0, 1.0))), 1.0)));
gl_Position = ftransform();
}
varying vec3 objnor, halfve;
void main()
{
vec3 n;
float NdotL, NdotHV;
n = normalize(objnor);
NdotL = max(dot(n, normalize(vec3(1.0, 1.0, 1.0))), 0.0);
NdotHV = max(dot(n, normalize(halfve)), 0.0);
vec4 difcom = vec4(0.6, 0.6, 0.6, 1.0) * NdotL;
vec4 specom = pow(NdotHV, 128);
vec4 ambcom = vec4(0.2, 0.2, 0.2, 1.0);
vec4 color = 0;
color += ambcom;
color += specom;
color += difcom;
gl_FragColor = color;
}
```