Advertisement Jump to content
Sign in to follow this  

D3DXComputeTangent fails

This topic is 4908 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

D3DXComputeTangent fails on the mesh. I am sure that vertex declaration is correct; I took the working sample which uses D3DXComputeTangent, and after substituting its simple sphere model for more complicated mesh, D3DXComputeTangent starts to fail. Obviously, the problem is in the mesh itself and I wonder if anything can be done about it. I use MAX + Panda to export the mesh into X format. Thank you

Share this post

Link to post
Share on other sites
Hi there Tokaplan, how are you doing?

[The Problem]
D3DXComputeTangent is failing?

[The Solution]
Why don't you try D3DXComputeTangentFrame()?
What is the difference between the 2?

"Computes the tangent vectors for the texture coordinates given in the texture stage. Provided to support legacy applications. Use D3DXComputeTangentFrameEx for better results."

"Compute tangent, binormal, and normal vectors for a mesh."

[source lang = "c#"]
//load the mesh
mesh = Mesh.FromFile(meshFilename, MeshFlags.Managed, device);

//Vertex elements that describe the new format of the mesh
VertexElement[] elements = new VertexElement[]
new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0),
new VertexElement(0, 12, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Normal, 0),
new VertexElement(0, 24, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
new VertexElement(0, 36, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Tangent, 0),
new VertexElement(0, 48, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.BiNormal, 0),
VertexDeclaration decl = new VertexDeclaration(device, elements);
Mesh tempMesh = mesh.Clone(MeshFlags.Managed, elements, device);
mesh = tempMesh;

/* Performs tangent frame computations on a mesh. Tangent, binormal, and optionally normal vectors are generated.
* Singularities are handled as required by grouping edges and splitting vertices.


I hope this helps a bit.

Keep cool.

Share this post

Link to post
Share on other sites
I've tried D3DXCleanMesh, but it fails on my mesh as well! It returns D3DERR_INVALIDCALL (not much information indeed, it can only return this and E_OUTOFMEMORY). As for D3DXComputeTangentFrame, I'm using DX SDK 9.0b, and the compiler tells me there is no such function in this version of DX SDK.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!