Flipped texture coordinates

Nazara now use a top-left corner origin for UVs (DirectX-like)


Former-commit-id: 550dd76cf15bc731d1e23060d1af15c3cd5cb4fd
This commit is contained in:
Lynix
2014-08-25 22:37:36 +02:00
parent 9b1f63ce11
commit 98aa804de5
6 changed files with 24 additions and 33 deletions

View File

@@ -200,7 +200,10 @@ namespace
{
const unsigned int fixedIndex = indexFix[j];
const MD2_TexCoord& texC = texCoords[triangles[i].texCoords[fixedIndex]];
vertex[triangles[i].vertices[fixedIndex]].uv.Set(static_cast<float>(texC.u) / header.skinwidth, 1.f - static_cast<float>(texC.v)/header.skinheight);
float u = static_cast<float>(texC.u) / header.skinwidth;
float v = static_cast<float>(texC.v) / header.skinheight;
vertex[triangles[i].vertices[fixedIndex]].uv.Set(u, (parameters.flipUVs) ? 1.f - v : v);
}
}

View File

@@ -178,10 +178,7 @@ namespace
}
vertices->position = finalPos;
// Le format MD5 spécifie ses UV avec l'origine en bas à gauche, contrairement au moteur
// dont l'origine est en haut à gauche, nous inversons donc la valeur en Y.
vertices->uv.Set(vertex.uv.x, 1.f - vertex.uv.y);
vertices->uv.Set(vertex.uv.x, (parameters.flipUVs) ? 1.f - vertex.uv.y : vertex.uv.y); // Inversion des UV si demandé
vertices++;
}
@@ -271,7 +268,7 @@ namespace
// On retourne le modèle dans le bon sens
vertex->position = scale * (rotationQuat * finalPos);
vertex->uv.Set(md5Vertex.uv.x, 1.f - md5Vertex.uv.y);
vertex->uv.Set(md5Vertex.uv.x, (parameters.flipUVs) ? 1.f - md5Vertex.uv.y : md5Vertex.uv.y); // Inversion des UV si demandé
vertex++;
}