Original Post
Hi all,
I'm experiencing a very bad issue using GL_TEXTURE_2D_ARRAY and automatic mipmap generation.
I don't really understand what's going on.
Essentially I create a Texture array of 6 elements using
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA8, 512, 384, 6, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
then I fill it with
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 512, 384, 6, GL_RGB, GL_UNSIGNED_BYTE, data);
where data is a linear memory area correctly filled from files.
Then I generate mipmaps calling
glGenerateMipmaps(GL_TEXTURE_2D_ARRAY);
What I experience is that in the fragment shader accessing texture at index 0 is never a problem,
at any LOD level.
Accessing texture at indices > 0 will result in a correct texture when accessing LOD 0 using the textureLod function,
but it results in accessing some random texture memory at bigger lods. I mean that accessing levels > 0
will actually somehow access textures at indices > 0 in the array (with some evident glitch!), just like if I'm overflowing into some near memory. :S.
My shader code is very simple:
uniform sampler2DArray DiffuseTexture;
in vec2 uv;
void main(void)
{
out_Color = texture(DiffuseTexture, vec3(uv, 'hardcoded index'));
}
I've tried a lot of solutions, but none has changed the outcome! I'm really stucked !
(I'm using ATI drivers on Linux with an ATI Mobility Radeon HD 2400).
No error is logged using glGetError.
So before I start posting detailed pieces of code here, maybe someone here already experiences a similar behaviour,
or has some idea for fixing this. I'm afraid I'm completely missing something. (Even though my code perfectly works for standard
2d Textures...).
Thanks a lot!!
Daniele
I'm experiencing a very bad issue using GL_TEXTURE_2D_ARRAY and automatic mipmap generation.
I don't really understand what's going on.
Essentially I create a Texture array of 6 elements using
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA8, 512, 384, 6, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
then I fill it with
glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 512, 384, 6, GL_RGB, GL_UNSIGNED_BYTE, data);
where data is a linear memory area correctly filled from files.
Then I generate mipmaps calling
glGenerateMipmaps(GL_TEXTURE_2D_ARRAY);
What I experience is that in the fragment shader accessing texture at index 0 is never a problem,
at any LOD level.
Accessing texture at indices > 0 will result in a correct texture when accessing LOD 0 using the textureLod function,
but it results in accessing some random texture memory at bigger lods. I mean that accessing levels > 0
will actually somehow access textures at indices > 0 in the array (with some evident glitch!), just like if I'm overflowing into some near memory. :S.
My shader code is very simple:
uniform sampler2DArray DiffuseTexture;
in vec2 uv;
void main(void)
{
out_Color = texture(DiffuseTexture, vec3(uv, 'hardcoded index'));
}
I've tried a lot of solutions, but none has changed the outcome! I'm really stucked !
(I'm using ATI drivers on Linux with an ATI Mobility Radeon HD 2400).
No error is logged using glGetError.
So before I start posting detailed pieces of code here, maybe someone here already experiences a similar behaviour,
or has some idea for fixing this. I'm afraid I'm completely missing something. (Even though my code perfectly works for standard
2d Textures...).
Thanks a lot!!
Daniele