Hello,
I recently decided to switch my point lights from using PCF to VSM. So, I now need a color cube map instead of just a depth cube map. I create the FBO like so:
{
#ifdef DEBUG
int result;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &result);
size_t uResult = static_cast<unsigned>(result);
assert(resolution > 0 && resolution <= uResult);
#endif
m_resolution = resolution;
glGenTextures(1, &m_cubeMapID);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_cubeMapID);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glGenFramebuffers(1, &m_fboID);
glBindFramebuffer(GL_FRAMEBUFFER, m_fboID);
// Create all faces
for(unsigned int i = 0; i < 6; i++)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, internalFormat, m_resolution, m_resolution, 0, textureFormat, dataType, NULL);
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
// Render buffer creation for depth buffer
glGenRenderbuffers(1, &m_depthID);
glBindRenderbuffer(GL_RENDERBUFFER, m_depthID);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_resolution, m_resolution);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthID);
// Check that the buffer was properly created
#ifdef DEBUG
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
std::cerr << "Could not create cube map FBO!" << std::endl;
#endif
// Unbind
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
However, I can’t seem to get the depth test to work anymore. I made sure that glDepthMask, glDepthFunc, and GL_DEPTH_TEST where all properly set. Geometry is rendering out of order!
What am I doing wrong?
Thank you for any help you can offer!