纹理边缘的颜色准确性

发布于 2024-12-05 17:54:59 字数 968 浏览 1 评论 0原文

我正在 lwjgl (java opengl) 中制作一个游戏,其中包含纹理立方体的网格。

我已经修复了边缘纹理坐标不准确的常见错误,我的坐标 100% 准确。

在场景中移动时,亮红色四边形边缘上的像素会闪烁青色(这恰好是我的透明颜色),仅在很短的时间内与绿色四边形重叠。绿色重叠部分后面肯定还有其他四边形。

问题仅在于立方体顶部的近侧和远侧。

在你问之前,我的纹理中没有蓝色像素。

我的最小/放大过滤器在绿色重叠处修复了一条棕色线。但我认为这可能是问题的一部分。

如何让这些像素保持红色或绿色?

或者更具体地说,如何使混合仅使用最接近的颜色而不进行任何组合?

这是我的参数:

            GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glAlphaFunc(GL11.GL_GREATER, (float) 0.9);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4f(255, 255, 255, 1.0f);
        GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
        GL11.glTexParameterf( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);

I'm making a game in lwjgl (java opengl) which contains a mesh of textured cubes within it.

I have already fixed the common error of texture coordinates being inaccurate on the edges, my coordinates are 100% accurate.

While moving through the scene, the pixels on the edges of my bright red quads flash teal(which happens to be my clear color) at overlaps with green quads only for a very short moment. There are definately other quads behind the overlaps colored green.

The problem is only with the near and far sides of the top of the cube.

Before you ask, there are NO blue pixels in my texture.

My min/mag filters fixed a brown line at the overlaps of green. but I think this could be part of the problem.

How can I get these pixels to either stay red, or go green?

Or to be more specific, how can I make the blend only use the nearest color and not do any combining?

Here are my params:

            GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glAlphaFunc(GL11.GL_GREATER, (float) 0.9);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4f(255, 255, 255, 1.0f);
        GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
        GL11.glTexParameterf( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长亭外,古道边 2024-12-12 17:54:59

哇,解决了。从屏幕截图来看,实际上是我的眼睛用青色幻影欺骗了我,因为随着屏幕移动和像素估计的变化,边框从红色闪烁到白色。盯着红色看足够长的时间,闭上眼睛,你就会看到青色。我将查找一些抗锯齿指南或更改滤镜以混合颜色。

Wow, solved. From looking at screenshots, it's actually my eyes tricking me with teal phantoms, as the borders flash from red to white as the screen moves and the pixel estimation changes. Stare at red long enough, close your eyes, and you'll see teal. I'll be looking up some anti-aliasing guides or changing my filter to blend the colors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文