I am using the latest autodesk FBX Importer SDK, but whatever I do, I am unable to get the uvs right. Some parts are textured properly while others are not.
I am using Direct3D9 and Direct3D11 (same result in both).
Image:
360 image: https://i.gyazo.com/5a2e5f6e127521915508c9c300eb03e5.mp4
The model uses a single texture and a single material shared among 4 meshes.
Is there someone who sees immediately what the problem could be? Or is there someone who can replicate the issue for me and figure out what I am missing?
FBX Test File: http://www.4shared.com/rar/o_WG0Crpce/Peach64FBX.html
My UV reading method:
int vertexCounter = 0;
for (int j = 0; j < nbPolygons; j++) {
for (int k = 0; k < 3; k++) {
int vertexIndex = pFbxMesh->GetPolygonVertex(j, k);
Vector2 uv;
_readUV(pFbxMesh, vertexIndex, pFbxMesh->GetTextureUVIndex(j, k), uv);
pVertices[vertexIndex].uv.x = uv.x;
pVertices[vertexIndex].uv.y = 1.0 - uv.y;
vertexCounter++;
}
}
void _readUV(fbxsdk::FbxMesh* pFbxMesh, int vertexIndex, int uvIndex, Vector2& uv) {
fbxsdk::FbxLayerElementUV *pFbxLayerElementUV = pFbxMesh->GetLayer(0)->GetUVs();
if (pFbxLayerElementUV == nullptr) {
return;
}
switch (pFbxLayerElementUV->GetMappingMode()) {
case FbxLayerElementUV::eByControlPoint:
{
switch (pFbxLayerElementUV->GetReferenceMode()) {
case FbxLayerElementUV::eDirect:
{
fbxsdk::FbxVector2 fbxUv = pFbxLayerElementUV->GetDirectArray().GetAt(vertexIndex);
uv.x = fbxUv.mData[0];
uv.y = fbxUv.mData[1];
break;
}
case FbxLayerElementUV::eIndexToDirect:
{
int id = pFbxLayerElementUV->GetIndexArray().GetAt(vertexIndex);
fbxsdk::FbxVector2 fbxUv = pFbxLayerElementUV->GetDirectArray().GetAt(id);
uv.x = fbxUv.mData[0];
uv.y = fbxUv.mData[1];
break;
}
}
break;
}
case FbxLayerElementUV::eByPolygonVertex:
{
switch (pFbxLayerElementUV->GetReferenceMode()) {
// Always enters this part for the example model
case FbxLayerElementUV::eDirect:
case FbxLayerElementUV::eIndexToDirect:
{
uv.x = pFbxLayerElementUV->GetDirectArray().GetAt(uvIndex).mData[0];
uv.y = pFbxLayerElementUV->GetDirectArray().GetAt(uvIndex).mData[1];
break;
}
}
break;
}
}
}
I am doing V = 1.0 - uv.y because I am using Direct3D11.
NOTE: the MappingMode is always eByPolygonVertex and ReferenceMode is always eIndexToDirect
- Rendering Info:
- Rendered as a Triangle List
- Uv wrapping mode: Wrap (Repeat)
- Culling: None