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:
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);
create FBO:
glGenFramebuffers(1, &fbo_); glBindFramebuffer(GL_FRAMEBUFFER, fbo_); glDrawBuffer(GL_NONE); glBindFramebuffer(GL_FRAMEBUFFER, 0);
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.