PDA

View Full Version : How to setup texture cube map array?



Xiongmao
03-17-2015, 03:53 AM
How to setup texture cube map array? I need some example.


HiGL_TexStorage3D(
GL_TEXTURE_CUBE_MAP_ARRAY,
Data->GetMipMap(),
DestFormat,
Data->GetWidth(),
Data->GetHeight(),
6 * Data->GetDepth()
);
//how to fill data in cube map array???????
//i need some code example.

Thanks in advance :)

GClements
03-17-2015, 07:20 AM
How to setup texture cube map array?
Either:

1. call glTexImage2D() for each face and mipmap level, using target parameters of GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, etc, or

2. call glTexStorage2D() with a target parameter of GL_TEXTURE_CUBE_MAP, then call glTexSubImage2D() for each face and mipmap level to provide the texture data.

Alfonse Reinheart
03-17-2015, 08:11 AM
Structurally, cubemap array textures are really just 2D array textures (https://www.opengl.org/wiki/Array Texture). So you should upload data to them like you would 2D array textures.

The main difficulty is understanding the difference between cubemap array layers and cubemap array layer-faces. Layers are the number of individual cubemaps in the array. Layer-faces are the number of 2D images in the array, so it's the number of layers * 6. From the OpenGL side, you're dealing primarily with layer-faces.


Either:

1. call glTexImage2D() for each face and mipmap level, using target parameters of GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, etc, or

2. call glTexStorage2D() with a target parameter of GL_TEXTURE_CUBE_MAP, then call glTexSubImage2D() for each face and mipmap level to provide the texture data.

You answered the wrong question. He's asking how to send data to the cubemap array after creating storage for it, not how to create storage for it (which is code he already has).

Also, that's the wrong answer for how to create storage for a cubemap array texture (https://www.opengl.org/wiki/Cubemap_Texture#Cubemap_array_textures). His code is correct for that.

Xiongmao
03-17-2015, 08:11 AM
Either:

1. call glTexImage2D() for each face and mipmap level, using target parameters of GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, etc, or

2. call glTexStorage2D() with a target parameter of GL_TEXTURE_CUBE_MAP, then call glTexSubImage2D() for each face and mipmap level to provide the texture data.

I want to create cubemap array, not cubemap. This is my assume


GLenum CubeFace[] = {
GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
};
glTexStorage3D(
GL_TEXTURE_CUBE_MAP_ARRAY,
Data->GetMipMap(),
DestFormat,
Data->GetWidth(),
Data->GetHeight(),
6 * Data->GetDepth()
);
for (size_t ai = 0; ai < Data->GetDepth(); ai++)
{
for (size_t fi = 0; fi < 6; fi++)
{
glTexSubImage3D(
CubeFace[fi], 0, 0, 0, ai, Data->GetWidth(), Data->GetHeight(), 1,
...
);
}
}

But from this:
https://www.opengl.org/sdk/docs/man/html/glTexSubImage3D.xhtml
glTexSubImage3D target must be GL_TEXTURE_3D or GL_TEXTURE_2D_ARRAY, Very Confused to me. i don't know to create cubemap array.
Thanks for reply. :)

Alfonse Reinheart
03-17-2015, 08:19 AM
But from this:
https://www.opengl.org/sdk/docs/man/html/glTexSubImage3D.xhtml
glTexSubImage3D target must be GL_TEXTURE_3D or GL_TEXTURE_2D_ARRAY, Very Confused to me.

That's because the documentation is wrong. It also take GL_TEXTURE_CUBE_MAP_ARRAY.

Xiongmao
03-17-2015, 08:25 AM
That's because the documentation is wrong. It also take GL_TEXTURE_CUBE_MAP_ARRAY.

Thanks. :)