Tangent/Binormal calcuation - I think

Started by
2 comments, last by circlesoft 19 years, 1 month ago
Hi, I've finally finished my shader and it's meant to look like this but actually looks like this. I think this is due to not calculating tangents and binormals. I see that directx has a helper function on the mesh class - ComputeTangent. Is this what I want? If so, how on earth do I use it? : Any help will be useful! - aCiD2
Ollie"It is better to ask some of the questions than to know all the answers." ~ James Thurber[ mdxinfo | An iridescent tentacle | Game design patterns ]
Advertisement
Yes, that function would help. But if you're using a newer SDK, you should use D3DXComputeTangentFrame(Ex) because it will give much better results.

neneboricua
I agree, you need to calculate the tangents with D3DXComputeTangent or D3DXComputeTangentFrame. To do this you will need to have your data stored in an ID3DXMesh. This will calculate the tangents and binormals for the mesh. Remember you can calculate binormals in the vertex shader by taking the cross(Tangent, Normal).

Remember that the mesh vertex declaration must specify tangent and/or binormal fields in order for D3DXComputeTangent to work.
game development is liek a state of mind man.. it's liek when you liek... think... and then you liek make it fun++

- Yes I'm drunk.
Quote:Original post by noaktree
Remember that the mesh vertex declaration must specify tangent and/or binormal fields in order for D3DXComputeTangent to work.

And if your ID3DXMesh doesn't have those vertex elements, you can call ID3DXMesh::Clone() and create a mesh that does. Then, call D3DXComputeTangentFrame() and generate your normals.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )

This topic is closed to new replies.

Advertisement