且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在OpenGL中可视化深度纹理?

更新时间:2023-11-18 09:14:46

您可能需要更改深度纹理参数才能将其显示为灰度级别:

You may need to change the depth texture parameters to display it as greyscale levels :

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE )
glTexParameteri( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE )

然后,您可以通过固定功能或"sampler2d"着色器制服将纹理正常用作常规"灰度2d纹理.

You can then normally use the texture as a 'normal' greyscale 2d texture, either via fixed function, or a 'sampler2d' shader uniform.