From a19b708144b91d6936339b40f93ab7540ee25689 Mon Sep 17 00:00:00 2001 From: ywang Date: Fri, 7 May 2021 16:27:23 -0700 Subject: [PATCH] support both ktx and ktx2 --- code/AssetLib/glTF2/glTF2Exporter.cpp | 8 ++++++-- code/AssetLib/glTF2/glTF2Importer.cpp | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/code/AssetLib/glTF2/glTF2Exporter.cpp b/code/AssetLib/glTF2/glTF2Exporter.cpp index e039bf88a..751508225 100644 --- a/code/AssetLib/glTF2/glTF2Exporter.cpp +++ b/code/AssetLib/glTF2/glTF2Exporter.cpp @@ -526,10 +526,14 @@ void glTF2Exporter::GetMatTex(const aiMaterial* mat, Ref& 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, 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; diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index b109891cb..db5da8813 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -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";