Rendering to cube mipmaps

I’m trying to manually generate mipmaps for a cube map to avoid the seams that come with automatic cube mipmap generation.

I’m using a geometry shader to target all the faces of the cube map with one draw call, and I have my cube map bound to an FBO.

When I render to mip level 0, everything works as expected. When all I do is change the mip level parameter of glFrameBufferTexture, then only the positive x face gets rendered. The other faces are unchanged.

Does anyone know if this is a known bug or is there something else I have to change to correctly render to the mipmaps? I’m on OSX 10.9.2 and using the OpenGL 4.1 core profile on a GTX 680MX chip.

Let me know if you need to see any of the code. Thanks :slight_smile:

Could you please post your code…
However, if you are trying to avoid the seams, you can use seamless cubemap filtering.

It’s not a seam in rendering the base level (I think that’s what you’re referring to). The seam is apparent when rendering higher mipmap levels when they are generated with glGenerateMipmap - I don’t think that function takes into account neighboring sides when downsampling cube maps.

There’s a lot of code to get everything set up, but here’s the main part where the problem occurs. This method was basically pulled out of the framebuffer object spec. SkyTex is the render target for SkyFbo, and the target for skyTex is GL_TEXTURE_CUBE_MAP. The geometry shader in skyMipShader emits six copies of the cube, one for each layer.

    skyFbo.beginCapture( );
    int nLevels = int(log2(skyTex.getWidth()));
    for ( int level = 1; level <= nLevels; ++level )
      const int w = skyTex.getWidth() >> level;
      const int h = skyTex.getHeight() >> level;
      glViewport(0, 0, w, h );
                           skyTex.getTexture(), level);
      glTexParameteri(skyTex.getTarget(), GL_TEXTURE_BASE_LEVEL, level-1);
      glTexParameteri(skyTex.getTarget(), GL_TEXTURE_MAX_LEVEL, level-1);
      skyGeometry->render( );
                         skyTex.getTexture(), 0);
    glTexParameteri(skyTex.getTarget(), GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    glTexParameteri(skyTex.getTarget(), GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    glTexParameteri(skyTex.getTarget(), GL_TEXTURE_BASE_LEVEL, 0);
    glTexParameteri(skyTex.getTarget(), GL_TEXTURE_MAX_LEVEL, nLevels-1);
    skyFbo.endCapture( );

In testing, I changed the skyMipShader to just render out red. When I do this, only the positive x face of the mipmaps ends up red. However, if I change the loop to start at 0 instead of 1, then the base level does become red on all faces (as expected).