Search code examples
openglskybox

OpenGL Skybox black triangles where edges meet


I'm getting black triangles along the edges of my skybox. They disappear as I approach them and get bigger when I move further away from them with the camera. Where might my problem be? Thanks

    mat4 VP = camera[currentCamera]->GetViewProjectionMatrix();
    glm::mat4 S = glm::scale(glm::mat4(1),glm::vec3(150.0, 150.0, 150.0));
    glm::mat4 MVP = VP*S;   
    skybox->Render(glm::value_ptr(MVP));

And the render function is:

 void Renderable::Render(const GLfloat* MVP) 
{
    shader.Use();               
        glUniformMatrix4fv(shader("MVP"), 1, GL_FALSE, MVP);
        SetCustomUniforms();
        glBindVertexArray(vaoID);
            glDrawElements(primType, totalIndices, GL_UNSIGNED_INT, 0);
        glBindVertexArray(0);
    shader.UnUse();
}

enter image description here


Solution

  • It looks like your skybox geometry is getting clipped by the far plane of the viewing frustum. You should probably increase the distance to the far plane, which is probably configurable on your camera class.