合并纹理上的 XNA 纹理坐标
我遇到纹理坐标问题。首先我想描述一下我想做什么,然后我会问问题。
我想要一个仅使用一个大纹理就有更多纹理的网格。大纹理合并了网格在其中使用的所有纹理。我制作了一个合并纹理的例程,这没问题,但我仍然需要修改纹理坐标,因此现在仅使用一个纹理而不是多个纹理的网格体的所有内容都放置得很好。
看图片:
在左上角我得到了其中一个纹理(我们称之为 A)我合并成一个大纹理,右边的纹理(B)。 A的左上角是0,0,右下角是1,1。为了方便使用,我们假设 B.width = A.width * 2 ,高度也是如此。所以 B 上的迷你纹理(M 原来是 A)右下角应该是 0.5,0.5。
到目前为止,我在理解这些方面没有任何问题,我希望我能理解它。但这里的问题是,纹理坐标是:
- 以上
- 1 个负值
原始 A 上的
。M 上的这些应该是什么?比方说,A 有 -0.1,0 - 是 B 内 M 上的 -0.05,0 吗?
那么那些 0..1 区域之外的数字呢? A 上的 -3.2,0 是 -1.6 还是 B 上的 -3.1?所以我剪掉 %1 的部分并除以 2(因为我上面说过宽度是双倍的)或者我应该将整个数字除以 2?据我所知,到目前为止,该区域之外的数字是关于镜像纹理的。我该如何管理这个问题,使输出不包含 B 的橙色纹理?
如果我的问题不够清楚(我的英语不太熟练),请询问,我会编辑/回答,只是帮助我消除困惑:)
提前致谢: 彼得
I got a problem with texture coordinates. First I would like to describe what I want to do then I will ask the question.
I want to have a mesh that has more textures using only one big texture. The big texture merges all textures the mesh is using in it. I made a routine that merges textures, that is no problem, but I still have to modify the texture coordinates, so the mesh that now uses only one texture instead of many has everything placed well.
See the picture:
On the upper left corner I got one of the textures (let's call it A) I merged into a big texture, the right one (B). A's top left is 0,0 and bottom right is 1,1. For easy use let's say that B.width = A.width * 2 and so for the height too. So on B the mini texture (M what is the A originally) bottom-right should be 0.5,0.5.
I got no problems understanding these so far and I hope I understood it ok. But the problem here is, that there are texture coordinates that are:
- above 1
- negative
on the original A. What should these be on M?
Let's say, A has -0.1,0 - is that -0.05,0 on M inside B?
What about those numbers that are outside 0..1 region? Is -3.2,0 on A -1.6 or -3.1 on B? So I clip of the part that is %1 and divide by 2 (because I stated above that width is double) or should I divide the whole number by 2? As far I understand so far, numbers outside this region are about mirroring the texture. How do I manage this, so the output does not contain the orange texture from B?
If my question is not clear enough (I am not much skilled in English), please ask and I will edit/answer, just help me clear my confusion :)
Thanks in advance:
Péter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
单个纹理的坐标在 [0-1,0-1] 范围内
新纹理的坐标在 [0-1,0-1] 范围
内 在由四个单个纹理组成的新纹理中,您的算法必须将纹理坐标转换为方式。
0-0.5]范围
在 [0.5-1, 0-0.5] 范围内
A single texture has coordinates in [0-1,0-1] range
The new texture has coordinates in [0-1,0-1] range
In your new texture composed by four single textures, your algoritm has to translate texture coordinates this way.
0-0.5] range
in [0.5-1, 0-0.5] range