How to get specific cubemap out of 'samplerCubeArray'?

I’m trying to get depth cubemap out of cubemap array for point shadows.
I used to create multiple framebuffers with depth cubemaps (GL_TEXTURE_CUBE_MAP) and bind each one of them to different GL_TEXTURE (e.g GL_TEXTURE_24, GLTEXTURE_25 and so on.).
Now, I’m creating cubemap array (GL_TEXTURE_CUBE_MAP_ARRAY), binding it to single GL_TEXTURE_24 and passing it to shaders through ‘samplerCubeArray’.
I don’t have any problem with creating or rendering to framebuffer, but I can’t access cubemap layers in shader.


for (int i = 0; i < 4; i = i + 1)
	glActiveTexture(GL_TEXTURE24 + i);
	glBindTexture(GL_TEXTURE_CUBE_MAP, FBuffer[i].Texture);

for (int i = 0; i < 4; i = i + 1)
	// SetInt() function = glUniform1i()
	ShadowShader.SetInt("map_depth[" + std::to_string(i) + "]", 24 + i); // So shadow cubemaps is assigned to GL_TEXTURE24-GL_TEXTURE27
// Index points to desired cubemap.
// Index 0 - GL_TEXTURE24, Index 1 - GL_TEXTURE25, Index 2 - GL_TEXTURE26, Index 3 - GL_TEXTURE27
uniform samplerCube map_depth[4];
// ...
float closestDepth = texture(map_depth[Index], fragToLight + gridSamplingDisk[i] * diskRadius).r;


glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, FBuffer.Texture);

ShadowShader.SetInt("point_shadows_cubemap_array", 24);
uniform samplerCubeArray point_shadows_cubemap_array;
// ...
float closestDepth = texture(point_shadows_cubemap_array, vec4(vec3(fragToLight + gridSamplingDisk[i] * diskRadius), Index)).r;

How do I get specific cubemap out of array?
Googling says “texture(cubeMapArray, vec4(texCoord, 0));” where 0 is cubemap layer, but setting it to different values doesn’t give different result.

The fourth component of the texture coordinates selects the cube map.

The code you posted appears fine. Check the code which creates the texture and passes the index.