zeux / meshoptimizer

Mesh optimization library that makes meshes smaller and faster to render
MIT License
5.49k stars 473 forks source link

gltfpack: Use vertex attributes to guide simplification #688

Closed zeux closed 3 months ago

zeux commented 3 months ago

When -sv command line argument is specified, we will use vertex colors or vertex normals as part of attribute aware simplification to produce better results. For now the intention is to use a single argument to incorporate multiple different types of attributes with fixed weights, in the future we might expose more detailed control via '-sv?' prefix.

Fixes #652

zeux commented 3 months ago

This PR currently uses either color or normal; implementing support for both will require copying attribute data out of source buffers, but is likely valuable - need to do more tests.

Normal effect, before / after:

Color effect, before / after (this model doesn't use textures):

zeux commented 3 months ago

Left to right: only using normals, only using colors, using normals+colors (equal weight)

The last one is still not ideal but that's probably because the underlying attribute math needs improvements. But incorporating normals is a clear win over just colors on this model.

zeux commented 3 months ago

I think I'm going to merge this as is for now and explore multi stream version separately, as it might also be valuable to do some preprocessing on data (eg linear->sRGB transform for colors for perceptual improvements or some such).