View Full Version : dot3 bumpmapping, and arb_vertex_program

DopeFish

11-11-2002, 04:56 AM

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?

dorbie

11-11-2002, 09:43 AM

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.

DopeFish

11-12-2002, 03:02 AM

Im not calculating it, Im using fixed values atm, as I *dont know* how to calculate it. heh.

dorbie

11-12-2002, 03:40 AM

Hmm, well that's your problem :-)

I have an explanation of transforming the light vector into tangent space here:

http://www.dorbie.com/bumplogo.html

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

bpeers

11-12-2002, 06:55 AM

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 http://www.opengl.org/discussion_boards/ubb/smile.gif

Btw love the chalk stuff http://www.opengl.org/discussion_boards/ubb/smile.gif

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.