I set up for depth pre-pass as follows:
glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); glDepthFunc(GL_LESS); glClear(GL_DEPTH_BUFFER_BIT); glFramebufferDrawBufferEXT(id, GL_NONE); // id is currently bound framebuffer object glColorMaski(0, GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
I'm not explicitly writing depth in the fragment shader. Should I then have a version of my shader program that has only a vertex shader and no fragment shader? I ask for efficiency reasons, since I don't know whether OpenGL can figure out from either the GL_NONE draw buffer or false color mask that it doesn't need to run the fragment shader. The downside of doing a separate shader program for the depth pre-pass is that I'd have to do it for every shader program that has a different vertex shader.