glTF-Transform icon indicating copy to clipboard operation
glTF-Transform copied to clipboard

simplify: attribute weighted simplification

Open marwie opened this issue 10 months ago • 7 comments

Hello, currently simplify doesn't take vertex colors into account. Looks like meshoptimizer added this feature recently. Is this already exposed/available in gltf-transform?

https://github.com/zeux/meshoptimizer/issues/652#issuecomment-1922083991

marwie avatar Mar 26 '24 13:03 marwie

Not yet exposed – see #1153. It's marked as an 'experimental' feature, so we would need to do something like that here, as I assume the meshoptimizer API could change at any time. In the meantime, vertex colors only factor in to the extent that they limit welding vertices before simplification.

donmccurdy avatar Mar 26 '24 13:03 donmccurdy

Ok - thanks for the link!

marwie avatar Mar 26 '24 13:03 marwie

Here's also another very very simple model where this would help (it would probably not remove any vertices in this simple case)

BenchSmall.zip

image

marwie avatar Mar 26 '24 13:03 marwie

Also have a look at https://github.com/donmccurdy/glTF-Transform/discussions/992

kzhsw avatar Mar 28 '24 03:03 kzhsw

It looks like there are breaking changes planned for the simplifyWithAttributes API, which is still experimental:

https://github.com/zeux/meshoptimizer/pull/601

I think the rest of this task – supporting simplifyWithAttributes — will need to wait for a 4.1+ release.

donmccurdy avatar Apr 02 '24 14:04 donmccurdy

In case it is useful to the discussion, a recent meshoptimizer PR exposed target_error to gltf_pack https://github.com/zeux/meshoptimizer/issues/494

This change exposes simplification error via command line argument -se, which can be valuable to control simplification more precisely and may also be used to slightly increase the defaults when -sv is used. Also this change completes https://github.com/zeux/meshoptimizer/pull/688 by incorporating both normals and colors when -sv is specified, which improves quality on models with vertex colors further.

jo-chemla avatar Aug 27 '24 12:08 jo-chemla

In case it is useful to the discussion, a recent meshoptimizer PR exposed target_error to gltf_pack zeux/meshoptimizer#494

@jo-chemla glTF-Transform does not directly use the gltfpack tool, it uses the meshoptimizer js api here

kzhsw avatar Aug 28 '24 00:08 kzhsw