support both ktx and ktx2

pull/3893/head
ywang 2021-05-07 16:27:23 -07:00
parent 2b9d88c943
commit a19b708144
2 changed files with 8 additions and 4 deletions

View File

@ -526,10 +526,14 @@ void glTF2Exporter::GetMatTex(const aiMaterial* mat, Ref<Texture>& texture, aiTe
if(memcmp(curTex->achFormatHint, "jpg", 3) == 0)
mimeType += "jpeg";
else if(memcmp(curTex->achFormatHint, "ktx", 3) == 0) {
useBasisUniversal = true;
mimeType += "ktx";
}
else if(memcmp(curTex->achFormatHint, "kx2", 3) == 0) {
useBasisUniversal = true;
mimeType += "ktx2";
}
else if(memcmp(curTex->achFormatHint, "bu", 3) == 0) {
else if(memcmp(curTex->achFormatHint, "bu", 2) == 0) {
useBasisUniversal = true;
mimeType += "basis";
}
@ -544,7 +548,7 @@ void glTF2Exporter::GetMatTex(const aiMaterial* mat, Ref<Texture>& texture, aiTe
}
else {
texture->source->uri = path;
if(texture->source->uri.find(".ktx2")!=std::string::npos ||
if(texture->source->uri.find(".ktx")!=std::string::npos ||
texture->source->uri.find(".basis")!=std::string::npos)
{
useBasisUniversal = true;

View File

@ -1476,8 +1476,8 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) {
if (strcmp(ext, "jpeg") == 0) {
ext = "jpg";
}
else if(strcmp(ext, "ktx2") == 0) { //basisu
ext = "ktx";
else if(strcmp(ext, "ktx2") == 0) { //basisu: ktx remains
ext = "kx2";
}
else if(strcmp(ext, "basis") == 0) { //basisu
ext = "bu";