将矩形图像数据打包成方形纹理 [英] Packing rectangular image data into a square texture

查看:224
本文介绍了将矩形图像数据打包成方形纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有N个2D图像数据,它们是矩形的,我想尽可能有效地将它们打包成2个纹理的单个幂。

I have N items of 2D image data that will be rectangular and I want to pack them into a single power of 2 texture as efficiently as possible.

一个简单的非常有效和天真地实现一个算法来打包这些rects很容易鞭打,但我相信人们已经提出算法来尽可能地节省空间。我发现了与光照贴图类似的各种参考,它与我正在寻找的相似,但是光照贴图的算法往往会考虑非矩形图像,这实际上使事情变得比我需要的更复杂。

A simple non-efficient and naive implementation of an algorithm to pack these rects would be easy to whip up, but I'm sure people have come up with algorithms to do this as space efficiently as possible. I've found various references to lightmap packing which is similar to what I'm looking for, but the algorithms for lightmapping tend to take non-rectangular images into account which actually complicates things more than I need them to be.

有人有提示吗?算法或纸质作者的名字我应该google吗?

Does anyone have hints? Names of algorithms or paper authors I should google?

谢谢。

推荐答案

我需要做你描述的事情。

I've needed to do this very thing you describe.

这是我使用的Python代码,它是Python Cookbook中的一个食谱:

This is the Python code I used, it's a recipe in the Python Cookbook:

食谱442299:将不同尺寸的多张图像打包成一张图像

这篇关于将矩形图像数据打包成方形纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆