我的 opengl 纹理底部出现奇怪的细线或点
我制作了一个与此类似的应用程序: http://www.youtube.com/watch ?v=U2uH-jrsSxs(声音有点大,不好听)。问题是每个纹理的底部都会出现一条非常细的线/点/任何东西。它几乎难以察觉,但它就在那里,我不知道为什么。我的纹理尺寸是 256x256。我之前用纹理尺寸 128x128 进行了测试,我认为那里什么也没有,但不确定。这没什么大不了的,因为它很薄,但我觉得很烦人。这是屏幕截图。我用红色选择了这些线。我是 OpenGL(ES) 的菜鸟,所以可能我做错了什么。任何帮助表示赞赏。
I have made an app similar to this one: http://www.youtube.com/watch?v=U2uH-jrsSxs (the sound is a bit loud and bad). The problem is there is a very thin line/dots/whatever appearing at the bottom of every texture. It is almost unnoticeable but it is there and I have no idea why. My texture size is 256x256. I tested earliear with a texture size 128x128 I THINK there was nothing there but not sure. It's not such a big deal as it is very thin but I find it annoying. Here is a screenshot. I have selected with RED those lines. I'm a noob at OpenGL(ES) so probably I did something wrong. Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是由于 OpenGL 平铺纹理来填充指定区域。因此,您看到的细线将是该纹理的最顶部,刚刚开始再次重复。
为了避免这种情况,请告诉纹理“夹紧”,而不是“重复”(重复与平铺同义)。默认情况下,纹理会重复,因此您需要一条类似这样的线:
如果您倾向于这种方式,那么在它周围还有一个不涉及代码的边界方式。只需编辑源图形,使顶部或左侧边缘不存在像素即可。因此,将整个画布在其画布内向下移动一个像素并向右移动一个像素。但是,如果您希望图像出现在完全相同的位置,当然您需要调整坐标。
This will be due to OpenGL tiling the texture to fill the specified area. So the thin line you are seeing will be the very top of that texture just starting to repeat again.
To avoid it, tell the texture to CLAMP, rather than REPEAT (repeat being synonymous with tiling). Textures repeat by default, so you will want a line something like this:
If you're this way inclined, there is also a no-code-involved bodge way around it. Simply edit your source graphics so that no pixels are present in the top or left edges. So move the whole lot down one pixel and right one pixel inside its canvas. But then of course you will need to adjust your coordinates if you want the images to appear in exactly the same place.