How to visualize depth texture in OpenGL?

I am working on a shadow mapping algorithm and I would like to debug the depth map that it generates in my first pass. However, the depth textures do not seem to display correctly in the viewport. Is there an easy way to display the depth texture as an image in grayscale, preferably without using a shader?

+3
source share
3 answers

You may need to change the texture depth settings to display them as grayscale levels:

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

Then you can usually use the texture as a “normal” texture with 2d grayscale, either using a fixed function or in the form of a “sampler2d” shader.

+8

(2D) , . , , . z-near -far, ( , , glTexEnv).

+2

, , 2D-! , , .

OpenGL , . .

0
source

Source: https://habr.com/ru/post/1705359/


All Articles