opengl-tutorials/ogl

ShadowTutorial: glTexImage2D depthTexture, wrong internal format

Opened this issue · 0 comments

I'm not sure, but maybe this should look like this:

glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, 1024, 1024, 0,GL_DEPTH_COMPONENT, GL_FLOAT, 0);

or

glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, 1024, 1024, 0,GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 0);

I used your code for an Android project and in OpenGL ES 3.0 the depth texture didn't work until I changed it. I'm very new in OpenGL, but maybe this is helpful.

References:
https://www.khronos.org/opengl/wiki/Common_Mistakes#Depth_Buffer_Precision
https://www.khronos.org/opengl/wiki/Image_Format#Depth_formats
https://stackoverflow.com/questions/37071584/opengl-fbo-depth-format-and-type-confusion