TBN-space "rotated"

Started by
4 comments, last by Roquqkie 17 years, 7 months ago
I have a really weird "bug"... I have a mesh and my mesh have tangents, bitangents and normals for each vertex, which I computed using Mesh.ComputeTangentFrame (a managed directx helper-function)... when I want to move my light-vector into my TBN-space it's rotated 90-degrees, that is: I have to set up my TBN-matrix as (B,-T,N) instead of (T,B,N)... anyone know why? :) Best regards, Roq
Advertisement
A mesh with backwards/mirrored texture coordinates could do that (e.g. a texture applied to a square with U coordinates of 1.0 on the left side and U coordinates of 0.0 on the right side).

A a mesh with the texture coordinates mirrored down the middle would do that for half the mesh. Artists quite often make only half of a symetrical object then mirror that half to make the whole think (think of a human character model, the artist models and textures the left arm, left leg, left part of the head etc, then copies and mirrors that to make the right part).

The mesh being inside out could also do similar - check that the winding order of polys in your mesh is what you expected (I'd add some debug code to draw lines representing both vertex and face normals to see that they point in the expected directions with respect to each other).

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

S1CA:

Thank you for your help :)

I'm rendering a screen-aligned quad in the xy-plane. the vertices are (0,0,0), (1,0,0), (1,1,0), (0,1,0) and the lower-left texture-coordinate is (0,0), lower-right (1,0), upper-right (1,1) and upper-left (0,1).
It's counter-clockwise.

My normals are all (0,0,-1), so they are coming "out" of my viewing-plane.

I outputted my tangents and bitangents and the tangents were (0,1,0) and the bitangents were (1,0,0)... Does this make sense? I thought tangents was the partial derivative with respect to the u-channel and bitangents to the v-channel...?

Also Microsoft did a mistake by calling it "binormals". You usually refer to binormals when talking about curves and the Frenet frame, while bitangents are for surfaces ;)

I'm really lost on this one :) (I come from a strong opengl-background, so I know all the theory already)

Best regards,
Roq
Binormals and tangents arn't really my thing, but DX maps texcoords vertically mirrored compared to what OpenGL does. In plain words, while (0, 0) texcoords in OpenGl is bottom left, in DX, (0, 0) is top left.

Hope this makes sense and is even relevent :)
Sirob Yes.» - status: Work-O-Rama.
sirob:
Thanks. Flipping my texture-coordinates y-axis removed the need for -T, but I still need to swap T and B, so it's TBN-matrix = (B,T,N);

Did Microsoft make a mistake here and thought that T was derived from the partial derivative of V and not U and visa-versa for B?

Please help me... I'm getting desperate! :)

Br,
Roq
Sorry to bump the post, but I'm in lack of time ;)

This topic is closed to new replies.

Advertisement