Skip to content

Commit

Permalink
gltfpack: Update README with frequently used options
Browse files Browse the repository at this point in the history
This change represents a balance between documenting all options in the
README (which feels like excessive duplication) and status quo where
commonly used options may not be discoverable.

The options highlight the most important settings for scene
optimization, and the most important settings that inhibit some types of
optimization that may be needed in certain cases.

Fixes zeux#155.
  • Loading branch information
zeux committed Jun 17, 2020
1 parent 6cb16fa commit 825c6ed
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion gltf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ When using `-c` option, gltfpack outputs compressed `.glb`/`.gltf` files that us

For better compression, you can use `-cc` option which applies additional compression; additionally make sure that your content delivery method is configured to use deflate (gzip) - meshoptimizer codecs are designed to produce output that can be compressed further with general purpose compressors.

gltfpack can also compress textures using Basis Universal format, either storing .basis images directly (`-tb` flag, supported by three.js) or using KTX2 container (`-tc` flag, requires support for `KHR_image_ktx2`). Compression is performed using `basisu` executable that must be available in `PATH`; alternatively the path to the executable can be specified via `BASISU_PATH` environment variable.
gltfpack can also compress textures using Basis Universal format, either storing .basis images directly (`-tb` flag, supported by three.js) or using KTX2 container (`-tc` flag, requires support for `KHR_image_ktx2`). Compression is performed using `basisu` executable that must be available in `PATH`; alternatively the path to the executable can be specified via `BASISU_PATH` environment variable. Textures can also be embedded into `.bin`/`.glb` output using `-te` flag.

When using compressed files, [js/meshopt_decoder.js](https://github.com/zeux/meshoptimizer/blob/master/js/meshopt_decoder.js) needs to be loaded to provide the WebAssembly decoder module like this:

Expand All @@ -39,3 +39,20 @@ var loader = new THREE.GLTFLoader();
loader.setMeshoptDecoder(MeshoptDecoder);
loader.load('pirate.glb', function (gltf) { scene.add(gltf.scene); });
```

## Options

By default gltfpack makes certain assumptions when optimizing the scenes, for example meshes that belong to nodes that aren't animated can be merged together, and has some defaults that represent a tradeoff between precision and size that are picked to fit most use cases. However, in some cases the resulting `.gltf` file needs to retain some way for the application to manipulate individual scene elements, and in other cases precision or size are more important to optimize for. gltfpack has a rich set of command line options to control various aspects of its behavior, with the full list available via `gltfpack -h`.

The following settings are frequently used to reduce the resulting data size:

* -cc: produce compressed gltf/glb files (requires `EXT_meshopt_compression`)
* -tc: convert all textures to KTX2 with BasisU supercompression (using basisu executable; requires `KHR_image_basisu`)
* -mi: use mesh instancing when serializing references to the same meshes (requires `EXT_mesh_gpu_instancing`)
* -si R: simplify meshes to achieve the ratio R (default: 1; R should be between 0 and 1)

The following settings are frequently used to restrict some optimizations:

* -kn: keep named nodes and meshes attached to named nodes so that named nodes can be transformed externally
* -km: keep named materials and disable named material merging
* -ke: keep extras data
2 changes: 1 addition & 1 deletion gltf/gltfpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ int main(int argc, char** argv)
fprintf(stderr, "\t-sa: aggressively simplify to the target ratio disregarding quality\n");
fprintf(stderr, "\nVertices:\n");
fprintf(stderr, "\t-vp N: use N-bit quantization for positions (default: 14; N should be between 1 and 16)\n");
fprintf(stderr, "\t-vt N: use N-bit quantization for texture corodinates (default: 12; N should be between 1 and 16)\n");
fprintf(stderr, "\t-vt N: use N-bit quantization for texture coordinates (default: 12; N should be between 1 and 16)\n");
fprintf(stderr, "\t-vn N: use N-bit quantization for normals and tangents (default: 8; N should be between 1 and 16)\n");
fprintf(stderr, "\nAnimations:\n");
fprintf(stderr, "\t-at N: use N-bit quantization for translations (default: 16; N should be between 1 and 24)\n");
Expand Down

0 comments on commit 825c6ed

Please sign in to comment.