问题描述
我将要具有多个共面多边形的网格,这些多边形都位于某个平面上,因此我将无法消除.
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.
这些多边形具有特定的绘制顺序.一些多边形在其他多边形之后.如果我关闭深度测试,我将获得想要的效果,但是我希望能够将此网格放置在3D场景中.
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.
我不信任glPolygonOffset
,因为我可能会有多个重叠的多边形,并且担心偏移量的累积影响.
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.
推荐答案
只需禁用对z缓冲区的写入,而无需禁用深度测试.
Simply disable writing to z-buffer, without disabling depth test.
glDepthMask(GL_FALSE);
请确保使用 glDepthMask(GL_FALSE)渲染所有不需要 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.
这篇关于在OpenGL中绘制共面多边形的技术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!