Currently working on adding tangent-space Dot3 bumpmapping to my renderer, but Im stuck as to actually doing the math, ie calculating the tangent and such for it.
Im wanting to offload as much of the per-vertex math as possible into a vertex program, using Cg for a high-level language interface to it.
Anyway, without the proper math for it, the texture coordinates for the normalization cubemap are wrong (screenshot http://mrg.telefragged.com/shadows/shadows4.jpg ). As you can see, its lit beneath the light, but anything above it remains unlit (its not a problem with the cubemap itself).
Anyone able to help with the math? Or is there an easier way to implement Dot3 bumpmapping than doing it this way?
How are you computing the vector to light? I’d guess this is what you’re doing wrong. Do you transform the light into tangent space? You need to do this if your bump map is a tangent space representation.
Im not calculating it, Im using fixed values atm, as I dont know how to calculate it. heh.
Hmm, well that’s your problem
I have an explanation of transforming the light vector into tangent space here:
It predates the dot3 hardware stuff but the principals are the same, I just use it for the emboss displacement but you can use the same values for your light vector in tangent space.
So to make this clearer, the Ls, Lt and Lz terms are the tangent space vector components you need for the light vector, these values are computed by transforming the object space (or in your case world space because there’s no animation) light vector into tangent space using the Normal Binormal and Tangent coordinate frame vectors. This is what my dot products do. Some formulate this as a rotation, when I worked this out I was thinking about it as a projection but the math turns out to be equivalent. Delta s and delta t are your tangent and binormal vectors.
You need to know what a dot product of two vectors is to understand the description.
[This message has been edited by dorbie (edited 11-12-2002).]
Calculate the normal of the plane that goes through your vertices’ x coordinate, and their s and t values (just substract x2 s2 t2 from x1 s1 t1, this gives you one vector, same thing with x3 and x1, and then cross product). Read as a plane equation Ax + Bs + Ct + D = 0 (you don’t know/need D), you get ds/dx and dt/dx. Do the same by using y and z for ds/dy…dt/dz and you have the two vectors…
uh, hope this makes sense
Btw love the chalk stuff