Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Released on --/--/----

Release Notes

System Requirements

  • Windows 10/11 64bit, with Visual Studio 2022 Redistributables installed

  • MacOS 64 bit

    • You’ll need to install pngquant and pngcrush:
      brew install pngquant
      brew install pngcrush

CLI Documentation

Basic Usage

Use --version to print the version and your license information.

Basic usage:

> MeshOptimizer [OPTIONS] -f <path_to_input_file> -o <path_to_output_file>

Use --help to get a list of all available command line flags. Currently the --help output is as follows:

Usage: MeshOptimizer.exe [OPTIONS]

Options:
  -h,--help                   Print this help message and exit
  --config,--ini              Read an ini file
  --version                   Display program version information and exit
  -o,--output_file TEXT       Output filename. If it is not provided, it is auto-generated.
[Option Group: Required]
  Required options
  [At least 1 of the following options are required]
  Options:
    --dump_config{}             Dumps the config file set from current settings (without the input file and output file if given) and immediately exits. Config is either written to console or to file if filepath is provided. E.g. --dump_config config.TOML will write the current settings to config.TOML file.
    -f,--input_file TEXT        Filename to process.
[Option Group: optimization_level]
  Optimization Level
  [At most 1 of the following options are allowed]
  Options:
    -i,--info                   Output only the .json file with model details and quit.
    -c,--convert                -c0: Convert only (no optimization). Same as -c.
                                -c1: Convert only, one level up from '-c' (import/export to/from the internal Scene).
                                -c2: Everything except decimation.

    --tris INT:POSITIVE [50000]
                                Target triangle count, enables decimation.
[Option Group: opt_params]
  Optimization Params
  Options:
    --skip_mesh_merger          Skip mesh merging.
    --skip_decimation Needs: --tris
                                Skip geometry decimation.
    --ignore_parallel_geometry  Skip extra steps that ensure that nearby parallel layers are transformed with the same decimation operations. Appropriate for apparel and footwear CAD assets.
    --ignore_crossing_check     Skip extra steps that prevent decimation to create new intersections.
    --sanitize_normals          Compute missing vertex normals from geometry and make polygons with suspect winding double sided.
    --remove_obstructed_geometry
                                Remove geometry that is obstructed.
    --constrain_decimation_at_uv_boundaries
                                Preserve UV boundaries and don't decimate near them. By default decimation is allowed and any UV stretching is resolved by local UV remapping.
    --bake_small_features       Detect and bake small features into textured quads.
    --detect_instances Excludes: --freeze_transforms
                                Detect identical mesh instances.
    --freeze_transforms Excludes: --detect_instances
                                Bake node transforms into vertex attributes and set all node transforms to identity. Will clone meshes if instances exist. Implicitly turns on --reset_scaling.
    --force_float_vert_attribs  Forces 4 byte floating point data for all vertex attributes.
    --dont_export_tangents      Tangent vertex attribute won't be exported even if the primitive's material has a normal map. This may cause normals from textures to be oriented incorrectly.
    --ignore_polygon_intersections
                                Do not split the geometry on intersections.
    --force_poly_count          Don't stop decimation until poly count is hit. This ignores shininess and doesn't bound the error norm.
    --scanned_model             Perform operations specific to scans like crease smoothing.
[Option Group: runtime]
  Runtime
  Options:
    -j UINT [32]                Number of threads to run. Use -j0 for the single-threaded algorithm. Allocating fewer threads than CPU cores is useful if you want to run other tasks on the machine.
    -v                          Verbosity, number of times specified equals to verbosity level. E.g. -vvv is verbosity level 3
    --skip_scene_validation     Skip scene data validation that happens after each task.
[Option Group: misc]
  Miscellanious
  Options:
    --scale FLOAT               Scale the scene to the target scale.
    --remove_animations         Remove all unsupported animations and animation data present in the model, including skinning and vertex morphing.
    --reset_center{center} :value in { none, center, bottom }
                                The center of the scene is set to the origin of the coordinate system, or the bottom of the scene aabb. Specifying 'none' is the same as not setting the flag. Can use it with -c1, -c2 or with optimization.
    --reset_scaling             Remove reflection transforms from the scene.
    --remove_cameras            Remove any existing cameras from the file.
    --remove_lights             Remove any existing lights from the file.
    --tex_transform_rot_radians Convert the gltf texture transform rotations to radians.
    --one_primitive_per_mesh    Allow a maximum of one primitive per one mesh in the glTF output.
[Option Group: matTex]
  Texture and Material Settings
  Options:
    --convert_spec_gloss        Convert glTF's KHR_materials_pbrSpecularGlossiness to standard pbr workflow.
    --max_tex_size INT [2048]  Excludes: --skip_tex_resize
                                Maximum texture size. Textures larger than this size will be scaled down to it.
    --skip_material_visibility  Skip material visibility computation.
    --skip_uv_island_splitting Excludes: --skip_stray_uv_fixing
                                Skip splitting of poorly filled UV islands.
    --pot_textures              Force all textures to power of two dimensions.
    --square_textures Needs: --pot_textures
                                Force all textures to square dimensions.
    --skip_tex_fill             Skip unused texture area filling.
    --skip_alpha_boost          Skip alpha mask boosting designed to prevent alpha tested textures from vanishing at a distance.
    --aggressive_alpha_removal  Relaxes the conditions to remove alpha channels based on alpha value threshold and total opaque area covered by a material.
    --skip_material_data_cleanup
                                Skip duplicate, unused and redundant material data cleanup. Requires -c1 and --skip_tex_opt.
    --skip_alpha_mode_cleanup   Skip alpha mode cleanup based on uv coverage.
    --skip_normal_map_sanitization
                                Skip sanitization of normal maps. Most importantly clamping them so that they do not point away from the vertex normals.
    --skip_normal_baking Excludes: --minimize_materials --force_uv_unwrap
                                Skip normal baking.
    --max_baking_resolution INT Maximum resolution of textures to be baked.
    --atlas_padding INT:INT bounded to [0 - 10]
                                Number of pixels to be used in atlas padding.
    --skip_extra_uv_layer_removal
                                Skip removal of unused and duplicate uv layers.
    --skip_stray_uv_fixing Excludes: --skip_uv_island_splitting
                                Skip stray uv polys relocation in order to compactify uv space.
    --skip_uv_unoverlapping     Skip unoverlapping uv polys. This may result in bad texture baking results.
    --minimize_materials Excludes: --skip_normal_baking
                                Undertake processes which aim to minimize the number of materials present in the output file, potentially at the expense texture space and rendering performance.
    --force_uv_unwrap Excludes: --skip_normal_baking
                                Force unwrapping of tiled UVs
    --remove_occlusion_maps     Remove all ambient occlusion maps from all materials in the input file.
    --skip_ao_baking            Skip ambient occlusion baking.
    --force_alpha_mode ENUM:value in { none, opaque, mask, blend }
                                Force all materials in the scene to the specified alpha mode. none is the default and doesn't change any alpha modes.
    --force_max_one_uv_layer    Crash if there is more than one UV layer legitimately used in any material. Don't create new UV layers in AO baking.
[Option Group: texOpt]
  Texture Optimization
  Options:
    --skip_tex_resize Excludes: --max_tex_size
                                Skip texture resizing.
    --skip_tex_opt              Skip texture optimization.
    --skip_tex_crop             Skip texture cropping.
    --skip_texel_density        Skip texel density based texture resizing.
    --target_tex_density :POSITIVE
                                Target texel density to be used in texture optimization in pixels/maximum_scene_dimension. If undefined median is used.
    --tex_opt_compression INT:INT bounded to [0 - 100] [80]  Excludes: --lossless_tex_opt
                                Texture compression level, 100 being max quality.
    --norm_opt_compression INT:INT bounded to [0 - 100] [80]  Excludes: --lossless_norm_opt
                                Normal map compression level, 100 being max quality.
    --lossless_tex_opt Excludes: --tex_opt_compression
                                Use lossless texture compression.
    --lossless_norm_opt Excludes: --norm_opt_compression
                                Use lossless texture compression for normal maps.
    --skip_atlassing            Skip arranging textures into atlases.
    --use_ktx                   Use KTX2 as output texture format, instead of JPEG/PNG.
    --alpha_mask_tex_density    Enables texel density based resize for alpha mask materials.

Configuration Files

Instead of specifying lengthy command lines, configuration files may be used. To use a config file add a path to it via the --config flag:

> MeshOptimizer --config=<path_to_config_file> -f <path_to_input_file> -o <path_to_output_file>

To convert a command line to a config file, --dump_config option can be used:

> MeshOptimizer [OPTIONS] --dump_config=<path_to_config_file>

Below are a number of config files corresponding to pipelines on the VNTANA Platform. They all feature reasonable defaults for optimizing assets based on what their source is. Some specifics of these configurations include:

  • CLO - Sets a high target texel density because CLO files often feature very tiled UV spaces

  • BW - Converts specularGlossiness materials to metallicRoughness

  • 3D_SCAN - passes the --scanned_asset flag to the optimizer, which tells it to perform some techniques specifically useful to 3D scans (see examples below)

  • STITCH_BAKING_ONLY - only bakes the small features present in the asset into textured quads (see examples below)

  • OTHER - use this if no other config file fits

  • NO_BAKING - disables texture and normal baking

  • KEYSHOT - suitable for Keyshot CAD assets

  • FORCE_BAKING - forcefully bakes textures, even if UV spaces are very tiled

Config files are easily editable in any text editor.

Examples

Obstructed Geometry Removal (--remove_obstructed_geometry)

Removes all polygons that are not visible from outside of the asset. E.g. for this asset:

The results with (left) and without (right) OGR are:

Small Feature Baking (--bake_small_features)

Bakes small features in the asset (such as stitches) into alpha masked quads.

Before:

After:

Instance Detection (--detect_instances)

Detects mesh copies which are then stored as a single mesh with multiple instances with different node transforms.

Before:

After:

Forcing polygon limit (--force_poly_count)

By default, MeshOptimizer will not honor the target polygon count (--tris) if its internal error norm becomes too large. This is done to prevent optimized assets having poor visuals or decimation errors. With the --force_poly_count flag this default behavior will be overridden and more effort will be put into achieving the desired poly limit.

Without poly limit forcing:

With:

Scanned Model Decimation (--scanned_model)

This flag will enable crease smoothing via edge flipping, as creases are often present on scanned models:

Ambient Occlusion Baking (--skip_ao_baking)

On by default, can be skipped with the --skip_ao_baking flag. Will not overwrite occlusion maps already present in the asset, unless --remove_occlusion_maps is passed as well.

  • No labels