在OpenGL中绘制共面多边形的技术
我将拥有多个共面多边形的网格,所有多边形都位于某个平面上,我将无法消除它们。
这些多边形具有特定的绘制顺序。一些多边形位于其他多边形后面。如果我关闭深度测试,我将获得我想要的效果,但我希望能够将该网格放置在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需禁用对 z 缓冲区的写入,而不禁用深度测试。
glDepthMask(GL_FALSE);
确保在使用 glDepthMask 渲染任何多边形之前渲染不需要 glDepthMask(GL_FALSE) 的所有多边形(GL_FALSE); 否则对象将被错误定位。
如果你做不到这一点,那么你应该改变你的几何形状或使用纹理。
glDepthMask 文档
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