What OpenGL ES texture format should I use for better dynamic range on iPad?
I'm developing some software which uses a texture map to store g开发者_JAVA百科eometry. Using GL_RGB for the internal format gives a lot of aliasing, I assume because the texture is being compressed down to GL_RGB4 by default.
On a desktop I can use GL_RGB16 or GL_RGB32F (etc.) to set the internal format, but under OpenGL ES 2.0 there doesn't seem to be any of these formats. Is there an alternative, or extension, that is available under IOS which I can use?
According to Apple (and my own experience) GL_RGB and GL_UNSIGNED_BYTE uses 8:8:8 storage. To drop to lower colour precision you'd need to specify a type of GL_UNSIGNED_SHORT_5_6_5 or one of the other types that packs multiple channels into one short.
If precision problems are creeping in nevertheless then it might be wise to check out the GL_OES_texture_float and GL_OES_texture_half_float extensions. You're limited to GL_NEAREST filtering, but I expect that's what you're using anyway since this is an exercise in data storage, and you can upload your source channels with 16 or 32 bits per pixel.
EDIT: example usage ripped directly from a project (which is uploading a 1 channel/pixel image, but you get the idea):
GLfloat *integralImage;
/* <lots of stuff to allocate storage and fill integralImage here> */
glTexImage2D(
GL_TEXTURE_2D, 0, GL_LUMINANCE,
256, 256, 0,
GL_LUMINANCE, GL_FLOAT,
integralImage);
So, after a bit of research, you can get float textures (as mentioned by @Tommy). What you can't do is access them from a vertex shader under IOS, making it impossible to use them to store geometry.
精彩评论