Jump to content
  • Advertisement


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


Calculating texture gradients

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

If you intended to correct an error in the post then please contact us.

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 this post

Link to post
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 this post

Link to post
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 C1

y0 s0 t0 1 A2
y1 = s1 t1 1 * B2
y2 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 s
y = 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]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!