PDA

View Full Version : bump_reflect_local_light



SirKnight
04-16-2002, 12:52 PM
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. http://www.opengl.org/discussion_boards/ubb/smile.gif 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 http://www.opengl.org/discussion_boards/ubb/smile.gif) 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. http://www.opengl.org/discussion_boards/ubb/wink.gif Now i get zigzag shaped specular highlights all over. Solving this program's problem sure is difficult. http://www.opengl.org/discussion_boards/ubb/smile.gif

-SirKnight

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

PH
04-17-2002, 07:26 AM
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.

SirKnight
04-17-2002, 06:08 PM
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. http://www.opengl.org/discussion_boards/ubb/wink.gif heh heh.

-SirKnight

cass
04-17-2002, 06:58 PM
Noone would be happier than me if you solved this puzzle!

davepermen
04-17-2002, 09:08 PM
fun to try something useless, eh? no future hardware will need to implement specular like this, so what? http://www.opengl.org/discussion_boards/ubb/smile.gif

i would like to play around with it myself, but only geforce2mx here.. doesn't run here very well http://www.opengl.org/discussion_boards/ubb/smile.gif

SirKnight
04-18-2002, 03:24 AM
Cass, I knew you were going to say that. http://www.opengl.org/discussion_boards/ubb/smile.gif



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. http://www.opengl.org/discussion_boards/ubb/smile.gif So all in all it's not completly pointless to try. http://www.opengl.org/discussion_boards/ubb/wink.gif

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. http://www.opengl.org/discussion_boards/ubb/smile.gif But hey ya never know.

-SirKnight

davepermen
04-18-2002, 04:17 AM
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.. http://www.opengl.org/discussion_boards/ubb/smile.gif you can do it without this funky matrix-stuff as well..