在OpenGL中绘制共面多边形的技术

发布于 2024-09-13 00:43:19 字数 198 浏览 2 评论 0原文

我将拥有多个共面多边形的网格,所有多边形都位于某个平面上,我将无法消除它们。

这些多边形具有特定的绘制顺序。一些多边形位于其他多边形后面。如果我关闭深度测试,我将获得我想要的效果,但我希望能够将该网格放置在 3D 场景中。

我不信任 glPolygonOffset 因为我可能会有几个重叠的多边形,并且我担心偏移的累积效应。

I'm going to have meshes with several coplanar polygons, all lying in a certain plane, that I'm not going to be able to eliminate.

These polygons have a specific draw order. Some polygons are behind other polygons. If I turn off depth testing I'll have the effect I want, but I want to be able to position this mesh in a 3D scene.

I do not trust glPolygonOffset because I'll potentially have several of these overlapping polygons and am am worried about the cumulative effects of the offset.

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

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

发布评论

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

评论(1

旧人哭 2024-09-20 00:43:20

如果我关闭深度测试,我将获得我想要的效果,但我希望能够将该网格放置在 3D 场景中。

只需禁用对 z 缓冲区的写入,而不禁用深度测试。

glDepthMask(GL_FALSE);

确保在使用 glDepthMask 渲染任何多边形之前渲染不需要 glDepthMask(GL_FALSE) 的所有多边形(GL_FALSE); 否则对象将被错误定位。

如果你做不到这一点,那么你应该改变你的几何形状或使用纹理。

glDepthMask 文档

If I turn off depth testing I'll have the effect I want, but I want to be able to position this mesh in a 3D scene.

Simply disable writing to z-buffer, without disabling depth test.

glDepthMask(GL_FALSE);

Make sure to render all polygons that doesn't require glDepthMask(GL_FALSE) before rendering any polygons with glDepthMask(GL_FALSE); Otherwise object will be incorrectly positioned.

If you can't do that, then you should change your geometry or use texture instead.

glDepthMask documentation

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