bump_reflect_local_light

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).]

The problem with the method is due to the cross product being anticommutative, that is a x b = -( b x a ).
You can see this if you draw the axes of the per-vertex tangent space and see what happens when the light is moved around.

Thanks for the incite on that. Later im going to draw some lines on the vertices showing the normal, binormal and tangent and look at to see what happens like you say. Im suprised that no one has came up with a solution for it but if that person has to be me well so be it. heh heh.

-SirKnight

Noone would be happier than me if you solved this puzzle!

fun to try something useless, eh? no future hardware will need to implement specular like this, so what?

i would like to play around with it myself, but only geforce2mx here… doesn’t run here very well

Cass, I knew you were going to say that.

fun to try something useless, eh? no future hardware will need to implement specular like this, so what?

Well maybe so but it’s still a good programming challenge and it may even teach me somethings i didn’t know. So all in all it’s not completly pointless to try.

Now the chances for me to actually get it working correctly is pretty slim though i think. Since Cass is so much more advanced than I and he hasn’t figured it out yet, that doesn’t put me in a good position. But hey ya never know.

-SirKnight

i said useless, not pointless…

sure you’ll learn some funny things and i really hope you get it, it would be too cool (and if you could explain it to others in a tutorial, even bether… cause it would help to understand matrix-math quite a lot i guess (or at least, what is possible with it…))

but useless it is… you can do it without this funky matrix-stuff as well…