Grim-es / material-combiner-addon

Blender addon for material combining, uv bounds fixing
MIT License
451 stars 36 forks source link

Add Z3 powered packer as an alternative to BinPacker #53

Open 1lann opened 1 year ago

1lann commented 1 year ago

I was trying to pack some 3x 2048x2048 and it unfortunately always produced an atlas that was 4096x8192. I kinda got angry about that, debugged it, and discovered one of the UVs were going slightly beyond the bounds to make one of the textures calculated as 2048x2063 or something. It was still possible to pack it, it's just that the BinPacker heuristic would get unlucky with the ordering and would result in a suboptimal atlas size. So I decided I would improve the way packing works, and I recently learned about Z3, so I used it here to develop a better packing algorithm. I've tried it out and it works great and no longer generates unnecessarily large atlases for me. I think it shines most in "Quadratic" (and "Automatic" which is the same) mode. Here's a PR for it, try it out and let me know what you think.

This change makes the Z3 powered packer the default, with a checkbox you can uncheck to use the old BinPacker.

This change also fixes some minor annoyances to me, like the weirdly large numerical input boxes, and missing dels in unregister (although I've never written a Blender plugin before so I have no idea what I'm doing).