0

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

stevetronix
  • 1,231
  • 2
  • 16
  • 32

1 Answers1

4

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.

warrenm
  • 31,094
  • 6
  • 92
  • 116
  • Excellent! Thanks so much. I had to increase the last parameter in glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 500.0f); to something above 150 (the scale of the skybox). – stevetronix Aug 12 '14 at 18:37
  • 1
    @stevetronix: 0.1 is a very (too?) little distance for the near clip plane. The closer the clip plane, the less your depth buffer resolution. You should always choose the near clip plane distance as far away as possible. – datenwolf Aug 12 '14 at 19:02