@@ -23,7 +23,7 @@ std::string getVersion()
2323 return result;
2424}
2525
26- static void finalizeBufferViews (std::string& json, std::vector<BufferView>& views, std::string& bin, std::string* fallback, size_t & fallback_size, const char * meshopt_ext)
26+ static void finalizeBufferViews (std::string& json, std::vector<BufferView>& views, std::string& bin, std::string* fallback, size_t & fallback_size, const char * meshopt_ext, int attribute_level )
2727{
2828 for (size_t i = 0 ; i < views.size (); ++i)
2929 {
@@ -43,7 +43,7 @@ static void finalizeBufferViews(std::string& json, std::vector<BufferView>& view
4343 switch (view.compression )
4444 {
4545 case BufferView::Compression_Attribute:
46- compressVertexStream (bin, view.data , count, view.stride );
46+ compressVertexStream (bin, view.data , count, view.stride , attribute_level );
4747 break ;
4848 case BufferView::Compression_Index:
4949 compressIndexStream (bin, view.data , count, view.stride );
@@ -885,7 +885,7 @@ static size_t process(cgltf_data* data, const char* input_path, const char* outp
885885 size_t bufferspec_pos = json.size ();
886886
887887 std::string json_views;
888- finalizeBufferViews (json_views, views, bin, settings.fallback ? &fallback : NULL , fallback_size, meshopt_ext);
888+ finalizeBufferViews (json_views, views, bin, settings.fallback ? &fallback : NULL , fallback_size, meshopt_ext, settings. compresskhr ? (settings. compressmore ? 3 : 2 ) : 0 );
889889
890890 writeArray (json, " bufferViews" , json_views);
891891 writeArray (json, " accessors" , json_accessors);
@@ -1106,7 +1106,7 @@ int gltfpack(const char* input, const char* output, const char* report, Settings
11061106 }
11071107 }
11081108
1109- const char * meshopt_ext = settings.compressexp ? " EXTX_meshopt_compression " : " EXT_meshopt_compression" ;
1109+ const char * meshopt_ext = settings.compresskhr ? " KHR_meshopt_compression " : " EXT_meshopt_compression" ;
11101110
11111111 std::string json, bin, fallback;
11121112 size_t fallback_size = 0 ;
@@ -1559,13 +1559,16 @@ int main(int argc, char** argv)
15591559 settings.compress = true ;
15601560 settings.fallback = true ;
15611561 }
1562- else if (strcmp (arg, " -cx " ) == 0 )
1562+ else if (strcmp (arg, " -cz " ) == 0 )
15631563 {
1564- fprintf (stderr, " Warning: experimental compression will produce files that are not compliant with EXT_meshopt_compression\n " );
1565- meshopt_encodeVertexVersion (1 );
15661564 settings.compress = true ;
15671565 settings.compressmore = true ;
1568- settings.compressexp = true ;
1566+ settings.compresskhr = true ;
1567+ }
1568+ else if (strcmp (arg, " -ce" ) == 0 && i + 1 < argc && (strcmp (argv[i + 1 ], " khr" ) == 0 || strcmp (argv[i + 1 ], " ext" ) == 0 ))
1569+ {
1570+ settings.compress = true ;
1571+ settings.compresskhr = strcmp (argv[++i], " khr" ) == 0 ;
15691572 }
15701573 else if (strcmp (arg, " -v" ) == 0 )
15711574 {
@@ -1629,7 +1632,7 @@ int main(int argc, char** argv)
16291632 fprintf (stderr, " \n Basics:\n " );
16301633 fprintf (stderr, " \t -i file: input file to process, .obj/.gltf/.glb\n " );
16311634 fprintf (stderr, " \t -o file: output file path, .gltf/.glb\n " );
1632- fprintf (stderr, " \t -c: produce compressed gltf/glb files (-cc for higher compression ratio)\n " );
1635+ fprintf (stderr, " \t -c: produce compressed gltf/glb files (-cc/-cz for higher compression ratio)\n " );
16331636 fprintf (stderr, " \n Textures:\n " );
16341637 fprintf (stderr, " \t -tc: convert all textures to KTX2 with BasisU supercompression\n " );
16351638 fprintf (stderr, " \t -tu: use UASTC when encoding textures (much higher quality and much larger size)\n " );
@@ -1683,6 +1686,7 @@ int main(int argc, char** argv)
16831686 fprintf (stderr, " \t -mi: use EXT_mesh_gpu_instancing when serializing multiple mesh instances\n " );
16841687 fprintf (stderr, " \n Miscellaneous:\n " );
16851688 fprintf (stderr, " \t -cf: produce compressed gltf/glb files with fallback for loaders that don't support compression\n " );
1689+ fprintf (stderr, " \t -ce ext|khr: use EXT or KHR version of meshopt compression extension for compression\n " );
16861690 fprintf (stderr, " \t -noq: disable quantization; produces much larger glTF files with no extensions\n " );
16871691 fprintf (stderr, " \t -v: verbose output (when used with other options)\n " );
16881692 fprintf (stderr, " \t -v: print version (when used without other options)\n " );
@@ -1694,7 +1698,7 @@ int main(int argc, char** argv)
16941698 fprintf (stderr, " \n Basics:\n " );
16951699 fprintf (stderr, " \t -i file: input file to process, .obj/.gltf/.glb\n " );
16961700 fprintf (stderr, " \t -o file: output file path, .gltf/.glb\n " );
1697- fprintf (stderr, " \t -c: produce compressed gltf/glb files (-cc for higher compression ratio)\n " );
1701+ fprintf (stderr, " \t -c: produce compressed gltf/glb files (-cc/-cz for higher compression ratio)\n " );
16981702 fprintf (stderr, " \t -tc: convert all textures to KTX2 with BasisU supercompression\n " );
16991703 fprintf (stderr, " \t -tw: convert all textures to WebP\n " );
17001704 fprintf (stderr, " \t -si R: simplify meshes targeting triangle/point count ratio R (between 0 and 1)\n " );
0 commit comments