在OpenGL中将纹理映射到球体时出现缝问题 [英] Seam issue when mapping a texture to a sphere in OpenGL

查看:1147
本文介绍了在OpenGL中将纹理映射到球体时出现缝问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在OpenGL中创建几何图形来表示地球。我有什么或多或少的球体(更接近椭圆大地水准面,地球是)。我映射地球表面的纹理(这可能是一个mercator投影或类似的东西)。纹理的UV坐标对应于几何的纬度和经度。我有两个问题,我无法解决。我使用OpenSceneGraph,但我认为这是一个一般的OpenGL / 3D编程问题。

I'm trying to create geometry to represent the Earth in OpenGL. I have what's more or less a sphere (closer to the elliptical geoid that Earth is though). I map a texture of the Earth's surface (that's probably a mercator projection or something similar). The texture's UV coordinates correspond to the geometry's latitude and longitude. I have two issues that I'm unable to solve. I am using OpenSceneGraph but I think this is a general OpenGL / 3D programming question.


  • 有一个纹理接缝非常明显。我相信这发生,因为我不知道如何映射UV坐标到XYZ的缝发生。我只映射UV坐标到最后一个顶点包围...你需要映射两个不同的UV坐标到同一个XYZ顶点,以消除接缝。

  • There's a texture seam that's very apparent. I'm sure this occurs because I don't know how to map the UV coordinates to XYZ where the seam occurs. I only map UV coords up to the last vertex before wrapping around... You'd need to map two different UV coordinates to the same XYZ vertex to eliminate the seam. Is there a commonly used trick to get around this, or am I just doing it wrong?

在杆子上有疯狂的扭曲变形。我猜这是因为我在极点上映射了一个UV点(对于地球,我使用[0.5,1]作为北极,[0.5,0]作为南极)。你还能做什么?

There's crazy swirly distortion going on at the poles. I'm guessing this because I map a single UV point at the poles (for Earth, I use [0.5,1] for the North Pole, and [0.5,0] for the South Pole). What else would you do though? I can sort of live with this... but its extremely noticeable at lower resolution meshes.

我已经附加了

推荐答案

处理的一般方式是使用 >,而不是2D纹理。

The general way this is handled is by using a cube map, not a 2D texture.

但是,如果你坚持使用2D纹理,你必须在网格拓扑中创建一个断点。你得到那条纵线的原因是因为你有一个顶点的纹理坐标为0.9左右,其相邻顶点的纹理坐标为0.0。你真正想要的是0.9一个邻居的1.0纹理坐标。

However, if you insist on using a 2D texture, you have to create a break in your mesh's topology. The reason you get that longitudinal line is because you have one vertex with a texture coordinate of something like 0.9 or so, and its neighboring vertex has a texture coordinate of 0.0. What you really want is that the 0.9 one neighbors a 1.0 texture coordinate.

这样做意味着将位置复制到球体的一条线。所以你在数据中使用了两次相同的位置。一个附加到1.0的纹理坐标,并且邻近的纹理坐标为0.9。另一个具有0.0的纹理坐标,并且与0.1的顶点相邻。

Doing this means replicating the position down one line of the sphere. So you have the same position used twice in your data. One is attached to a texture coordinate of 1.0 and neighbors a texture coordinate of 0.9. The other has a texture coordinate of 0.0, and neighbors a vertex with 0.1.

拓扑上,你需要沿着你的球体纵向切片。

Topologically, you need to take a longitudinal slice down your sphere.

这篇关于在OpenGL中将纹理映射到球体时出现缝问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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