• Advertisement
Sign in to follow this  

Tangent/Binormal calcuation - I think

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

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


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

  • Advertisement