texture layer problem

Hello. I render a cube. There are 6 textures in glTexStorage3D. I have checked every texture inside this storage - the textures are set up good.

So, I want to put the textures on the cube. But, instead of 6 textures, I get 1 texture (#0 in array) for 5 sides, and 1 texture(#5 in array) for 1 side.
Could you correct the code? I have checked gl for error, so no errors reported.

Texture layer index is inputted for every vertex, i.e. 36 vertices, 36 texture layer indices.

vertex shader:


#version 430 core

layout(location = 0) in vec4 position;
layout(location = 1) in vec2 texCoord;
layout(location = 2) in uint tex_layer_index;

layout(location = 0) uniform mat4 mv_matrix; 
layout(location = 1) uniform mat4 proj_matrix; 

out vec2 texture_uv_coordinates;
flat out uint texture_layer_index;

void main(void)   
{
   gl_Position = proj_matrix * mv_matrix * position;
   texture_uv_coordinates = texCoord;
   texture_layer_index = tex_layer_index;
}

fragment shader:


#version 430 core

in vec2 texture_uv_coordinates;
flat in uint texture_layer_index;
   
layout (binding = 0) uniform sampler2DArray textureArray;

out vec4 color;

void main(void)  
{
    color = vec4(texture(textureArray, vec3(texture_uv_coordinates.xy, 
    float(texture_layer_index))));    
}

The shaders look fine, so I’d assume that the problem is in the application code or the data it’s using.

Are you using glVertexAttribIPointer() to pass this attribute? glVertexAttribPointer() causes the data to be converted to floats, so it can’t be used for integer attributes.

Thank you, it works now. glVertexAttribIPointer() makes a difference.