如何在OpenGL中可视化深度纹理? [英] How to visualize a depth texture in OpenGL?

查看:443
本文介绍了如何在OpenGL中可视化深度纹理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究阴影映射算法,我想调试它在第一次通过时生成的深度图.但是,深度纹理似乎无法正确呈现到视口.是否有任何简便的方法可以将深度纹理显示为灰度图像,最好不使用着色器?

I'm working on a shadow mapping algorithm, and I'd like to debug the depth map that it's generating on its first pass. However, depth textures don't seem to render properly to the viewport. Is there any easy way to display a depth texture as a greyscale image, preferably without using a shader?

推荐答案

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

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.

这篇关于如何在OpenGL中可视化深度纹理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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