6

I'm trying to use opengl texture arrays for storing a lot of shadow maps. Unfortunately, I always get an "incomplete attachment" error on checking the framebuffer. I tried to set up my texture array like in nvidia's cascaded shadow mapping example (see Cascaded Shadow Mapping example by NVIDIA).

So here's some code:

  1. creating the texture:

    glGenTextures(1, &shadowMapArray_);
    glBindTexture(GL_TEXTURE_2D_ARRAY, shadowMapArray_);
    //maxArrayDepth_ = GL_MAX_ARRAY_TEXTURE_LAYERS
    glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_DEPTH_COMPONENT, size_, size_, maxArrayDepth_, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);
    glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LESS);
    glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
    
  2. create FBO:

    glGenFramebuffers(1, &fbo_);
    glBindFramebuffer(GL_FRAMEBUFFER, fbo_);
    glDrawBuffer(GL_NONE);
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    
  3. draw shadow map into layer:

    glUseProgram(programID_);
    glBindFramebuffer(GL_FRAMEBUFFER, fbo_);
    glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, shadowMapArray_, 0, currArraySize_);
    GLView::checkGLFramebuffer("ShadowMapGenerator::createShadowMap()"); //here i get the incomplete attachment
    [...]
    currArraySize_++;
    

System specs:

Debian Squeeze 64bit with Nvidia driver 304.60 and a GTX 560 Ti. The old driver version is due to a shader compiler bug in the newer versions.

maumau
  • 61
  • 2
  • "`maxArrayDepth_ = GL_MAX_ARRAY_TEXTURE_LAYERS`" Do you mean that literally (as in copying the enumerator value) or figuratively (using `glGetIntegerv` with that enumerator and storing it in `maxArrayDepth`)? – Nicol Bolas Apr 23 '13 at 10:23
  • figuratively: glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, (GLint*)(&maxArrayDepth_)); – maumau Apr 23 '13 at 10:27
  • Still no answer after two years? Awesome I must be lucky... – Elias Apr 24 '15 at 05:05
  • And five years later, here we are, still confused. – Danny Sep 23 '20 at 05:11

0 Answers0