Simplify, Reorder, Quantize and Compress: Meshoptimizer + Babylon Sandbox

The GLB Optimizer now supports Meshopt Compression! - https://glb.babylonpress.org/

Open Settings after uploading a model.
The Meshoptimizer part is here

image

Simplify - MeshoptSimplifier implements mesh simplification, producing a mesh with fewer triangles/points that resembles the original mesh in its appearance. The simplification algorithms are lossy and may result in significant change in appearance, but can often be used without visible visual degradation on high poly input meshes or for level of detail variants far away.
The algorithm aims to reach the target ‘ratio’, while minimizing error. If error exceeds the specified ‘error’ threshold, the algorithm will quit before reaching the target ratio. Examples:

  • ratio=0.0, error=0.0001: Aims for maximum simplification, constrained to 0.01% error.
  • ratio=0.5, error=0.0001: Aims for 50% simplification, constrained to 0.01% error.
  • ratio=0.5, error=1: Aims for 50% simplification, unconstrained by error.

The last option parameter, lockBorder, defines whether to lock topological borders of the mesh. May be necessary when adjacent ‘chunks’ of a large mesh (e.g. terrain) share a border, helping to ensure no seams appear and individual levels of detail can be stitched together later without gaps.

Reorder - Pre-processes GLB model to improve index and vertex locality which increases compression ratio before quantization and compression.

Quantize - Quantizes vertex attributes with KHR_mesh_quantization, reducing the size and memory footprint of the file. KHR_mesh_quantization extension will be added to the resulting GLB file.

If you want to apply Meshopt Compression there is no need to check reorder and quantize checkboxes (in order to avoid double quantization which may be too lossy). Reorder and quantize are already included into the Meshopt function (but one may use them separately as well, without Meshopt Compression).
One may choose from 2 available Meshopt Compression levels: “high” and “medium”. EXT_meshopt_compression extension will be added to the resulting GLB file.

Both extensions, KHR_mesh_quantization and EXT_meshopt_compression, are supported by Babylon GLTF Loader.

More info about the GLB Optimizer and how to use it - GLB Optimizer for Geometry and Texture Conversion (WEBP and KTX2)

11 Likes

I didn’t even know about this utility :slight_smile: Helpful one!

thanks!

1 Like

Meshopt decoding is considerably faster than Draco decoding.
It is also included into GLTF-Transform - EXTMeshoptCompression | glTF Transform

1 Like

Does this implement ISimplifier and thus integrate into mesh.simpify() side-by-side with BABYLON.QuadraticErrorSimplification?

(I’m not intending to highjack your thread. I’m happy to split this into another thread if you prefer.)

Maybe I misunderstand mesh.simplify, but have observed that it (and the associated ISimplificationSettings) don’t seem abstracted enough to capture parameters likely needed with different simplify routines. In particular, a single “quality” number is passed and an optional “optimizeMesh” boolean is used to run (or not) a separate optimize function. I think there’s an opportunity to iterate on that abstraction if MeshoptSimplifier were integrated. In addition, ISimplifier does not seem conducive to being used outside of LOD given that LOD levels and distance are integrated/implied instead of attached after an abstracted simplification/optimization run. I had to go through some extra steps when using QuadraticErrorSimplification to clean up an imported mesh: instead of calling and reurning a mesh, I extracted the new optimized mesh from the existing meshes LOD (then disposed the original).

For reference: when QuadraticErrorSimplification is used separately, the following properties can be assigned after instantiating

  • aggressiveness
  • boundingBoxEpsilon
  • decimationIterations
  • syncIterations (number of parallel threads)

I don’t see a way to assign those through mesh.simplify, and the defaults don’t seem to work super well.

Edit: a good discussion, including extracting a simplified mesh from LOD is here.

No, this algorithm uses WebAssembly module - meshoptimizer/js/meshopt_simplifier.js at master ¡ zeux/meshoptimizer ¡ GitHub - and works much faster.

@labris you should definitely put an “Apply optimizations” button somewhere (or the press R key info). :stuck_out_tongue:

@roland Yes, I think I’ll add some info about the ‘R’ key to the main screen in addition to the Help info.

1 Like

That’s great. Means we can now just do shit modelling, disregarding everything, and just run the tool :joy: I’d rather think some have already ‘anticipated’ this new feature :rofl:

That’s where I found after a while of searching how to apply the changes :stuck_out_tongue:

@roland Here we are :slight_smile: - https://glb.babylonpress.org/

1 Like

Most of free 3D models are done according this principle :slight_smile:

2 Likes

Last time I said this, I got bullied :ox: :sweat_smile: :rofl:
I had to rectify: "

Not all free models are (a piece of cr*p). I believe - as in everything - 15 to 20% of them are at least “acceptable”; 5% are “good” and about 1 to 2% are “great”.

Essentially, I think when downloading a model or template - being free OR paid - one should not admit that this will save him/her from doing anything more :grin: As per my experience, 95% of the external sources I get/gather, require at least a level of ‘adaptation’, be it just ‘normalizing’ or making it ‘consistent’ for the use in my project.