• ### Popular Now

• 14
• 12
• 9
• 10
• 13

#### Archived

This topic is now archived and is closed to further replies.

This topic is 5498 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am trying to compose a tangent space basis for bump mapping. I read in an nVidia doc that for each triangle in the model use the x,y,z position and the texture''s s and t texture coordinates to create plane equations of the form: Ax+Bs+Ct+D=0 Ay+Bs+Ct+D=0 Az+Bs+Ct+D=0 Then you are supposed to solve for the texture gradients dsdx, dsdy, dsdz. This gets one axis of the basis. Then you solve for dtdx, dtdy, dtdz to get the second. And finally calculate the SxT axis. How do you solve for dsdx, dsdy, dsdx? Are they partial derivatives? Can someone please explain the math to me. Thanks in advance.

##### Share on other sites
Yes, they are partials.
Rearrange and you have:

x = -(B/A)s - (C/A)t -D/A

##### Share on other sites
so dsdx = -A/B??? dsdy and dsdz also equal -A/B? That right? Then the axis is <-A/B, -A/B, -A/B> That doest seem right. Am i differentiating with respect to the wrong variable? I am thrown off by the notation dsdy, etc. I solved for s then differentiated s with respect to x to get -A/B, btw. Then how do you solve for A and B if that is right. Thanks for any help.

[edited by - executor_2k2 on March 4, 2003 2:54:04 AM]

##### Share on other sites
A different way:

For a triangle with vertices (x0, y0 ,z0),
(x1, y1, z1), (x2, y2, z2)
x0    s0 t0 1   A1  x1 =  s1 t1 1 * B1 x2    s2 t2 1   C1y0   s0 t0 1   A2y1 = s1 t1 1 * B2y2   s2 t2 1   C2

and the same for z.
By inverting the matrix of local coords, we can solve
for A, B, C such that:
x   A1 B1 C1   sy = A2 B2 C2 * t z   A3 B3 C3   1

Now you have the parametric equation for the plane through
your 3 points, and can calculate tangent (dX/ds) and
binormal (dX/dt).

[edited by - gumby on March 4, 2003 1:22:22 PM]