Improve Texture Atlas
Current texture atlas generation creates same section size for each texture as image
But some of them are more important than other (for example, body section should be bigger than small details like litlle plant in the head)
We should make the atlas creation consider texture sizes and trait importance to determine it's size in the atlas
Is there any blockers to this or could someone just add a texture packer that takes into account the original texture size?
Here are some commonly used texture packing algorithms, each optimized for different use cases such as minimizing empty space or efficiently arranging UV islands:
1. MaxRects (Maximum Rectangles)
- One of the most popular texture packing algorithms, it divides the texture space into a series of rectangles and tries to fit the UV islands into the largest available rectangles.
- Variants include Best Short Side Fit, Best Long Side Fit, Best Area Fit, and Bottom Left Rule, which use different strategies to decide where to place each UV island.
2. Guillotine Packing
- This algorithm works by splitting the texture space (like slicing it with a guillotine) based on the size of the UV island being packed. After placing a UV island, it recursively splits the remaining space to fit the next islands.
- It can be optimized using Best Area Fit, Best Split Fit, or Best Longest Edge Fit strategies.
3. Shelf Packing
- UV islands are packed into "shelves" of varying heights, starting from the bottom of the texture and working upwards. Each UV island is placed in the current shelf if it fits; otherwise, a new shelf is created.
- Simple but less efficient compared to other methods, as it often leaves a lot of unused space between shelves.
4. Tetris Packing
- Inspired by the game "Tetris," this method attempts to rotate and fit UV islands into available spaces in a compact manner, minimizing wasted texture space by using irregularly shaped gaps.
5. Binary Space Partitioning (BSP)
- The texture space is repeatedly divided into two smaller regions (a process called partitioning), and UV islands are packed into these regions. It’s a simple and efficient way of packing, but may leave more gaps compared to more complex methods.
6. Heuristic Packing (Bottom-Left, Best-Fit)
- This method uses various heuristics to decide where to place each UV island. For example:
- Bottom-Left heuristic places the UV island in the lowest and leftmost available space.
- Best-Fit heuristic places the UV island in the tightest possible space to minimize the gaps left after placement.
7. Strip Packing
- Similar to shelf packing, but instead of shelves, the UV islands are arranged in strips, each of which is as narrow as possible to maximize texture use. It works well for long, narrow UV islands but isn’t optimal for other shapes.
8. Z-Order Curve (Morton Ordering)
- UV islands are packed based on their Z-order curve (Morton order), which arranges 2D coordinates in a way that preserves spatial locality. It’s used in some hierarchical or mipmap-based systems.
9. Simulated Annealing
- An optimization-based approach that explores different packing configurations by randomly swapping or adjusting UV island placements and gradually improving the solution over time.
10. Genetic Algorithms
- This approach simulates evolutionary processes to iteratively improve the texture packing solution. Different packing configurations are "mutated" and "crossed over" to find a more optimized arrangement.
These algorithms balance different factors, such as minimizing unused space, preserving aspect ratio, and ensuring efficient packing, based on your project’s needs.
ideas / inspiration, adding more detail to the face / separating from body + clothes https://web.archive.org/web/20240518002036/https://www.polygonalmind.com/blog/avastars-turning-a-pfp-project-into-interoperable-vrm-avatars
Web gamedev discord mentioned looking into this: https://github.com/donmccurdy/glTF-Transform/discussions/792