Hello all,

I'm trying to implement omni directional shadows using cube map textures. I'm pretty sure I have everything set up alright, but it's not coming out the way I expected.

I create the depth cube maps like this:
Code :
    glDrawBuffer(GL_NONE);
    glReadBuffer(GL_NONE);
    GLfloat borderColor[] = { 1.0, 1.0, 1.0, 1.0 };
    cubeMapBuffer.genTexture();
 
    glBindTexture(GL_TEXTURE_CUBE_MAP, cubeMapBuffer.getID());
 
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_BORDER);
 
    glTexParameterfv(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_BORDER_COLOR, borderColor);
    for(int i = 0; i < 6; i++){
        glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
            0, GL_DEPTH_COMPONENT16, shadowMapW, shadowMapH, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);
    }
    //This is an array of GLuints
    glGenFramebuffers(6, shadowFrameBufferIDs);
    glGenRenderbuffers(6, renderBufferIDs);
    for(int i = 0; i < 6; i++){
        glBindFramebuffer(GL_FRAMEBUFFER, shadowFrameBufferIDs[i]);
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
            cubeMapBuffer.getID(), 0);
 
        glBindRenderbuffer(GL_RENDERBUFFER, renderBufferIDs[i]);
        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, shadowMapW, shadowMapH);
        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderBufferIDs[i]);
 
        switch(glCheckFramebufferStatus(GL_FRAMEBUFFER)){
            case GL_FRAMEBUFFER_UNDEFINED:
                std::cout << "Framebuffer undefined\n";
            break;
            case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
                std::cout << "Framebuffer incomplete attachment\n";
            break;
            case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
                std::cout << "Framebuffer missing attachment image\n";
            break;
            case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
                std::cout << "Framebuffer incomplete layer targets\n";
            break;
            case GL_FRAMEBUFFER_COMPLETE:
                //std::cout << "Framebuffer complete\n";
            break;
        }
    }
 
 
    glDrawBuffer(GL_NONE);
    glReadBuffer(GL_NONE);
    /*
    */
    glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    glBindRenderbuffer(GL_RENDERBUFFER, 0);
    glDrawBuffer(GL_BACK);
    glReadBuffer(GL_BACK);

Which seems to not throw any errors. I don't check every case, but I check the ones I felt were applicable to the problem.

And then I update the ShadowCube every frame:

Code :
GLint viewPort[4];
    glGetIntegerv(GL_VIEWPORT, viewPort);
 
    glViewport(0, 0, shadowMapW, shadowMapH);
 
    glBindTexture(GL_TEXTURE_CUBE_MAP, cubeMapBuffer.getID());
 
    for(int i = 0; i < 6; i++){
        glBindFramebuffer(GL_FRAMEBUFFER, shadowFrameBufferIDs[i]);
 
        glDrawBuffer(GL_NONE);
        glReadBuffer(GL_NONE);
 
        viewProjectionMatrix = glm::perspective <float>(glm::radians(90.0f), shadowMapW / shadowMapH, 1.0f, 500.0f) *  glm::lookAt(myCenterPos, myCenterPos + CameraDirections[i].Target, CameraDirections[i].Up);
 
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, cubeMapBuffer.getID(), 0);
        switch(glGetError()){
            case GL_NO_ERROR:
                std::cout << "No Framebuffer error\n";
            break;
            case GL_INVALID_OPERATION:
                std::cout << "Framebuffer invalid operation\n";
            break;
        }
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        //Grab current view before adjusting
 
        glUseProgram(depthProgID.getID());
        GLuint vpLoc = glGetUniformLocation(depthProgID.getID(), "depthVP");
        glUniformMatrix4fv(vpLoc, 1, GL_FALSE, glm::value_ptr(viewProjectionMatrix));
 
        glUseProgram(skelDepthProgID.getID());
        vpLoc = glGetUniformLocation(skelDepthProgID.getID(), "VP");
        glUniformMatrix4fv(vpLoc, 1, GL_FALSE, glm::value_ptr(viewProjectionMatrix));
 
        DrawAllEntDepth();
    }
    glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    glViewport(viewPort[0], viewPort[1], viewPort[2], viewPort[3]);

Which seems to be fine. I ran it through API trace and it shows nothing in the way of cube map textures, for whatever reason (hence why I needed help).

And then I upload it to the shader as a samplerCube.

The fragment shader then samples it based on the direction between the light and the frag. But I think it returns error, because I return it as the shadow and it makes the entire set of pixels go black, basically breaking the whole renderer. So I'm not sure what went wrong, but I would appreciate help!

Thanks,
Devmane144