Advertisement Jump to content
Sign in to follow this  
SiliconMunky

Texture coordinate transformations

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

Hello, I've been having some difficulty with texture coordinate transformations. The sdk docs says "Microsoft Direct3D devices can transform the texture coordinates for vertices by applying a 4x4 matrix." Yet it doesn't seem to be the case. From what I can tell D3D is multiplying [u, v, 1] against a 3x3 maxtrix.
//This matrix properly translates u and v by 0.5
matTrans._11 = 1.00f; matTrans._12 = 0.00f; matTrans._13 = 0.00f;
matTrans._21 = 0.00f; matTrans._22 = 1.00f; matTrans._23 = 0.00f;
matTrans._31 = 0.50f; matTrans._32 = 0.50f; matTrans._33 = 1.00f;

//This matrix does nothing and just acts like the identity matrix
matTrans._11 = 1.00f; matTrans._12 = 0.00f; matTrans._13 = 0.00f; matTrans._14 = 0.00f;
matTrans._21 = 0.00f; matTrans._22 = 1.00f; matTrans._23 = 0.00f; matTrans._24 = 0.00f;
matTrans._31 = 0.00f; matTrans._32 = 0.00f; matTrans._33 = 1.00f; matTrans._34 = 0.00f;
matTrans._41 = 0.50f; matTrans._42 = 0.50f; matTrans._43 = 0.00f; matTrans._44 = 1.00f;
Is the documentation misleading or am I missing something?

Share this post


Link to post
Share on other sites
Advertisement
I had the exact same problem. Yes, DirectX is multiplying your coordinates by a 3x3 matrix. To transform 2D texture coordinates in DirectX, the translation components of the matrix need to be in the third row, rather than the fourth row.

Here's the newsgroup post that I found, when trying to fix the problem.

link

Share this post


Link to post
Share on other sites
Just a quick note for anyone else looking at this, even though D3D is multiplying the coordinates by the 3x3 that's inside the D3DMatrix, make sure you still put 0's in the 4th row and column because if you're going to combine that matrix with another matrix you'll end up having problems like me. :)

Thanks for the help Oxyacetylene

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net 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!