How to visualize a depth texture in OpenGL?

前端 未结 3 1164
面向向阳花
面向向阳花 2021-02-11 01:52

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

3条回答
  •  萌比男神i
    2021-02-11 01:57

    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 )
    

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

提交回复
热议问题