在 OpenGL ES 2.0 中,如何绘制除相邻共面面上的线之外的三角形线框?

发布于 2024-11-27 03:50:49 字数 641 浏览 3 评论 0原文

我依稀记得在 OpenGL 中看到过一些东西(不是 ES,当我遇到这个问题时,它在 iPhone 上仍处于 v1.0,这就是为什么我从未使用过它),它让我指定多边形的哪些边被视为轮廓,哪些边被视为轮廓构成脸部的内部。因此,这与整个模型的轮廓不同(我知道该怎么做),而是一个平面的轮廓,其所有三角形基本上混合成一个多边形。例如,在由三角形组成的立方体中,每个面实际上是两个三角形。我想渲染正方形的轮廓,而不是面部的对角线。六边形也是如此。这需要四个三元组,但只需要一个脸部轮廓。

现在是的,我知道我可以简单地测试所有边缘,看看它们是否共享共面的面,但我可以发誓我记得在定义三网格数据时在某个地方看到过,你可以说“这条线勾勒出一个面,而这个”一个在脸里面。这样,在渲染时,您可以设置一个标志,基本上是“给我一个线框,但只有完整面边缘周围的线,而不是构成它们的三边形周围的线。”

顺便说一句,我的目标是所有支持 OpenGL ES 2.0 的平台,但我的开发平台是 iOS。再说一次,我非常确定这个功能最初是在 OpenGL 中使用的,一旦着色器出现,可能就会被贬值,但我什至找不到对此功能的引用来检查是否是这种情况。

我现在知道的唯一方法是拥有一组顶点,但有两组独立的索引......一组用于渲染三角形,另一组用于渲染面的线框。这真的很痛苦,因为我最终手动编码了很多这样的内容,同样,我 99% 确定您可以在渲染线条时定义。

I vaguely remember seeing something in OpenGL (not ES, which was still at v1.0 on the iPhone when I came across this, which is why I never used it) that let me specify which edges of my polygons were considered outlines vs those that made up the interior of faces. As such, this isn't the same as the outline of the entire model (which I know how to do), but rather the outline of a planar face with all its tris basically blended into one poly. For instance, in a cube made up of tri's, each face is actually two tris. I want to render the outline of the square, but not the diagonal across the face. Same thing with a hexagon. That takes four tris, but just one outline for the face.

Now yes, I know I can simply test all the edges to see if they share coplanar faces, but I could have sworn I remember seeing somewhere when you're defining the tri mesh data where you could say 'this line outlines a face whereas this one is inside a face.' That way when rendering, you could set a flag that basically says 'Give me a wireframe, but only the wires around the edges of complete faces, not around the tris that make them up.'

BTW, my target is all platforms that support OpenGL ES 2.0 but my dev platform is iOS. Again, this Im pretty sure was originally in OpenGL and may have been depreciated once shaders came on the scene, but I can't even find a reference to this feature to check if that's the case.

The only way I know now is to have one set of vertices, but two separate sets of indices... one for rendering tris, and another for rendering the wireframes of the faces. It's a real pain since I end up hand-coding a lot of this, which again, I'm 99% sure you can define when rendering the lines.

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

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

发布评论

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

评论(1

蓝海 2024-12-04 03:50:52

OpenGL ES 不支持 GL_QUADS、glEdgeFlag 和 glPolygonMode。

您可以使用 LINES 来绘制线框:要获得隐藏线,首先绘制黑色实心三角形(启用 DEPTH),然后使用 GL_LINES 绘制您感兴趣的边缘。

GL_QUADS, glEdgeFlag and glPolygonMode are not supported in OpenGL ES.

You could use LINES to draw the wireframe: To get hidden lines, first draw black filled triangles (with DEPTH on) and then draw the edges you are interested in with GL_LINES.

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