I have been messing around with that demo for a little while now and just when i thought i had a solution to the problem with the light real close to the model it all blows up on me. I was going through the vertex program math on paper and i noticed that its the second column of the ‘H’ matrix that i beleive is the problem. With the H matrix looking like this of course:

| R.x U.x L.x |

| R.y U.y L.y |

| R.z U.z L.z |

After pluging in some values like for my example i used a light vector of <0.2, 0.2, -1.0> (which is close to the model to show the problem) and just for example i made up some vertex at (0.1, 0.1, 0.5). So after computing the vertex to light vec i get <0.1, 0.1, -0.5> and then i normalized that. So after going through the math to finally compute the H matrix i then multiply this matrix by the light vector (actually vertex to light vector) to make sure everything went ok and would really transform this vector to <0,0,1> like its supposed to.

After doing this my result was <3.84e-6, 0.2722, 0.9999990675>. Ok the x component is pretty close to 0, i can accept that. The z component is very close to one so that is also acceptable. The reason why i think it isnt exact is from my rounding errors. BUT, the y component is 0.2722, that is not close enough to 0 so that makes me unhappy. I think that part may be contributing to the error we see.

I have a question about this whole thing though that will clear up some stuff and maybe help me solve this problem. First is, is it correct that this H matrix is a matrix to transform a vector into ‘light space’ with the light at the origin? If so then why is the 1 in <0,0,1> a positive and not negative? I would think it should be negative but for some reason no. Also, is this ‘texel matrix’ being computed used to convert the values computed in the texture shader which will be in texture space into some other space like eye space or something? I havnt really found any good docs about a texel matrix.

Earlier when i tried some stuff that i thought would fix the problem was to use a different vector other than <0,0,1> when computing U (L x <0,0,1> ). I tried <0.5, 0.5, 0.5> but the normalized version of that and it computed an H matrix that when i multiply the light vec by i get <0,0,1> like im supposed to. (ok the 1 was still 0.9999 but whatever ) This to me looked like it was going to work out better since i got rid of that .27 value in the y component, but it turned out that the program is even MORE screwed up. Now i get zigzag shaped specular highlights all over. Solving this program’s problem sure is difficult.

-SirKnight

[This message has been edited by SirKnight (edited 04-16-2002).]