开发者

Writing to depth buffer without depth testing in OpenGL (non shader)

In OpenGL, is it possible, to draw a sequence of polygons that doesn't check for depth (so they will always be drawn in front of other polygons drawn before it, regarding of their z position)

but also at 开发者_高级运维the same time, they still write to the depth buffer?

I suppose this is doable using shaders, but right now I have no access to that.


Not strictly speaking (from the man page):

the depth buffer is not updated if the depth test is disabled.

But... you can have the depth test enabled, while not having any fragment fail the test:

glDepthFunc(GL_ALWAYS);
glEnable(GL_DEPTH_TEST);

Of course, you get the last Z written by doing that, not the closest to the view.


You can only achieve that using two passes. First one is to populate the depth buffer only using a color mask:

glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

Second pass you enable color writing again, disable depth test and render your sequence of polygons in order.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜