像素间隙在哪里来自OpenGL? [英] Where do pixel gaps come from in OpenGL?

查看:63
本文介绍了像素间隙在哪里来自OpenGL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,渲染的场景中有一些像素似乎丢失/不可见,因此与我的透明色具有相同的颜色颜色.有趣的是,只有在关闭MSAA的情况下才会发生这种情况.

The problem that I have is, that there are some pixles in my rendered scene that seem to be missing/invisible and therefore have the same color as my clear color. Interestingly, this only happens if MSAA is turned off.

我的第一个想法是,可能与所有三角形都重叠且投影矩阵以某种方式扭曲的事实有关,但是这些伪像似乎仅出现在直线上,而不是在边缘上.

My first thought was, that it could have something to do with the fact, that all the triangles are overlapping and somehow distorted by the projection matrix but these artifacts only seem to occur on lines rather than edges.

我读到有关对另一个问题中的所有内容仅应用1.00001的比例,但这对我来说似乎是便宜的黑客,它可能会导致其他问题.尽管在使用硬件多重采样时这些伪像似乎有所减少,但我想知道是否还有其他方法可以解决此问题.

I read about just applying a scale of 1.00001 to everything in another question but that seems like a cheap hack to me that could cause other problems. Although these artifacts seem to be reduced when using hardware multisampling, I want to know if there is any other way to solve this.

尼科尔·波拉斯(Nicol Bolas):

OpenGL(和所有其他硬件光栅化器)仅在边缘完全匹配时才能保证两个三角形之间的边缘无间隙渲染.这意味着您不能仅在另一个三角形的边缘旁边有一个三角形.两个三角形在它们之间的共享边上必须具有相同的顶点.

OpenGL (and all other hardware rasterizers) only guarantees gapless rendering of the edge between two triangles if the edges exactly match. And that means you can't just have one triangle next to the edge of another. The two triangles must have identical vertices on the shared edge between them.

因此,如果在短三角形旁边有一个长三角形,您要做的就是将长三角形分成几个三角形,以便在两个三角形之间正确共享边缘的共享部分.

So if you have a long triangle next to a short triangle, what you have to do is split the long triangle into several triangles, so that the shared portion of the edge is properly shared between two triangles.

如前所述,一种可能的解决方案是将大三角形分成小三角形,以确保所有重叠的顶点都是相同的(即取消贪婪的网格划分).但就我而言,由于性能方面的原因,我希望保持贪婪的网格划分.

As stated, a possible solution is to split the big triangles into small ones to ensure that all overlapping vertecies are identical (i.e. abolishing the greedy meshing). But in my case I want to keep the greedy meshing due to performance aspects.

推荐答案

OpenGL(和所有其他硬件光栅化器)仅在边缘完全匹配的情况下保证两个三角形之间的边缘无缝呈现.这意味着您不能仅在另一个三角形的边缘旁边有一个三角形.两个三角形之间的共享边必须具有相同的顶点.

OpenGL (and all other hardware rasterizers) only guarantees gapless rendering of the edge between two triangles if the edges exactly match. And that means you can't just have one triangle next to the edge of another. The two triangles must have identical vertices on the shared edge between them.

因此,如果在短三角形旁边有一个长三角形,您要做的就是将长三角形分成几个三角形,以便在两个三角形之间正确共享边缘的共享部分.

So if you have a long triangle next to a short triangle, what you have to do is split the long triangle into several triangles, so that the shared portion of the edge is properly shared between two triangles.

由于您似乎正在构建一个由多维数据集构成的世界,因此这对您来说应该相当容易.

Since you seem to be building a world made of cubes, this should be fairly easy for you.

您要做的另一件事是确保两个三角形之间的两个共享顶点是 binary same .顶点着色器的 gl_Position 输出必须完全相同.因此,如果要计算VS中多维数据集的顶点的位置,则需要以保证二进制相同的结果的方式进行操作.

The other thing you have to do is make certain that the two shared vertices between the two triangles are binary identical. The gl_Position output from the vertex shader needs to be the exact same value. So if you're computing the position of the cube's vertices in the VS, you need to do that in a way that will guarantee binary identical results.

但是在我的情况下,由于性能方面的原因,我希望保持贪婪的网格划分.

But in my case I want to keep the greedy meshing due to performance aspects.

然后,您需要确定哪个更重要:性能或正确性.由于无法强制,光栅化器无法使这些边缘无间隙.这是浮点精度之类的问题,在不同的硬件上,它总是会有所不同.

Then you need to decide which is more important: performance, or correctness. Because there's no way to force the rasterizer allow such edges to be gapless. It's a matter of floating-point precision and such, which will always be different on different hardware.

这篇关于像素间隙在哪里来自OpenGL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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