Răsfoiți Sursa

support both ktx and ktx2

ywang 4 ani în urmă
părinte
comite
a19b708144

+ 6 - 2
code/AssetLib/glTF2/glTF2Exporter.cpp

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

+ 2 - 2
code/AssetLib/glTF2/glTF2Importer.cpp

@@ -1476,8 +1476,8 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) {
                 if (strcmp(ext, "jpeg") == 0) {
                 if (strcmp(ext, "jpeg") == 0) {
                     ext = "jpg";
                     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
                 else if(strcmp(ext, "basis") == 0) { //basisu
                     ext = "bu";
                     ext = "bu";