dorbie, I am using the half angle vector…it’s calculated in my vertex program.
I still have the same problem, though. The reason I thought I’d fixed it was because I tesselated the plane to be 100x100, and the specular highlights started looking good (ie. eliptical at low camera elevation), but when I reduced the resolution of the plane mesh again, my highlight looked totally distorted (you could see it bending round the triangles).
Here’s the latest nv_vertex_program:-
!!VP1.0
c[0]-c[3] = modelview*projection matrix
c[8] = light position in object coordinates
c[9] = some useful constants:-
.x = 0.5 used to compress signed vector into unsigned colour
c[10] = view position in object coordinates
#######################################################################
Transform vertex position into clip space, using combined matrix (modelview and projection).
DP4 o[HPOS].x, c[0], v[OPOS];
DP4 o[HPOS].y, c[1], v[OPOS];
DP4 o[HPOS].z, c[2], v[OPOS];
DP4 o[HPOS].w, c[3], v[OPOS];
#######################################################################
#######################################################################
DIFFUSE…
#######################################################################
Get vertex to light vector (L).
ADD R0, -v[OPOS], c[8];
Transform L vector by Normal(NRML)/Tangent(TEX1)/Binormal(TEX2) orthagonal matrix to convert
it into “tangent space” (aka “texture space” aka “triangle space”)
DP3 R1.x, v[TEX1], R0;
DP3 R1.y, v[TEX2], R0;
DP3 R1.z, v[NRML], R0;
MOV o[TEX1], R1;
#######################################################################
SPECULAR…
#######################################################################
Get vertex to view vector (V).
ADD R2, -v[OPOS], c[10];
create half angle vector (H) = (V+L)/2
ADD R2, R0, R2;
MUL R2, R2, c[9].xxxx; # divide by 2
Transform H vector by Normal(NRML)/Tangent(TEX1)/Binormal(TEX2) orthagonal matrix to convert
it into “tangent space” (aka “texture space” aka “triangle space”)
DP3 R3.x, v[TEX1], R2;
DP3 R3.y, v[TEX2], R2;
DP3 R3.z, v[NRML], R2;
MOV o[TEX2], R3;
########################################################################
Pass through other stuff…
########################################################################
MOV o[TEX0], v[TEX0]; # move standard texture coordinates into normal map texture stage
MOV o[TEX3], v[TEX0]; # move standard texture coordinates into diffuse texture stage
MOV o[COL0], v[COL0];
MOV o[COL1], v[COL1];
END
Diffuse looks fine (ie. correct) but the specular is spherical (and when the light is very close to the triangle, the specular highlight is some distance away, when it should really be directly under the light).