software transform

This topic is 4418 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi, I have a need in my project to 'software transform' some vertices before sending them down to the T&L hw for final transform and projection. However, its been ages since I had to do this (back in the Amiga and 386 days!) and I have obviously forgotten the old skills :( Here is the code: // Transform the normal D3DXVec3Transform(&vec,&Vertex.m_vNormal,&mat); Vertex.m_vNormal.x = vec.x; Vertex.m_vNormal.y = vec.y; Vertex.m_vNormal.z = vec.z; D3DXVec3Normalize&Vertex.m_vNormal,&Vertex.m_vNormal); // Add in translation and scale D3DXMatrixScaling(&scale,0.5f,0.5f,0.5f); D3DXMatrixTranslation(&translation,fX,fY,0.0f); D3DXMatrixMultiply(&mat,&mat,&scale); D3DXMatrixMultiply(&mat,&mat,&translation); // transform the coordinates D3DXVec3Transform(&vec,&Vertex.m_vPos,&mat); Vertex.m_vPos.x = vec.x; Vertex.m_vPos.y = vec.y; Vertex.m_vPos.z = vec.z; And I render the above lot with a identity world matrix so in theory should mean that the end result is transformed by view and projection. Now, if I render the above with the software transform the lighting is darker than without the software transform (with the same rotation/scaling/translation parameters). I am obviously munging up the normal transformation or my basic assumptions are just plain wrong... Can anyone spot the error?

Share on other sites
I can't say I quite understand what you're trying to do, but it seems like you are attempting to transform a normal. Theres a function specifically for that - D3DXVec3TransformNormal, which behaves a bit differently. Note: this matrix should be given the Transpose of the transformation matrix.

Also, when I'm transforming 3 component vectors, I usually get the results I want from using D3DXVec3TransformCoord. Maybe that's the one you mean to be using?

Hope this helps.

Share on other sites
I completely missed those functions - gotta learn to read correctly!

BTW.. Just in case - I missed this out but the lighting model is a directional light.

Share on other sites
Made the changes but the results are same as without the changes.

Share on other sites
Actually - I take that back.

I removed the final normalize is was doing on the normal and all is fine.

Thanks for the help!

• 17
• 11
• 15
• 9
• 49
• Forum Statistics

• Total Topics
631393
• Total Posts
2999774
×