无需在OpenGL中进行深度测试即可写入深度缓冲区(非着色器) [英] Writing to depth buffer without depth testing in OpenGL (non shader)

查看:86
本文介绍了无需在OpenGL中进行深度测试即可写入深度缓冲区(非着色器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在OpenGL中,可以绘制一系列不检查深度的多边形(因此,相对于其z位置,它们将始终在其他多边形之前绘制)

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.

推荐答案

严格来讲(来自

如果禁用深度测试,则不会更新深度缓冲区.

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);

当然,这样做会得到最后写入的Z,而不是最接近视图的

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

这篇关于无需在OpenGL中进行深度测试即可写入深度缓冲区(非着色器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆