Can someone tell me if it is possible to store 8 4-bit (grayscale) images in a RGBA8888 texture while still taking advantage of regular mipmapping? In other words, each channel of the 32-bit texture contains two images. The unpacking is to be done in a GLSL shader.
I couldn’t quite work it out myself if this is actually possible.
If you compute mipmaps yourself, and do not filter between mipmaps levels (ex. GL_LINEAR_MIPMAP_NEAREST), it should be fine.
Sweet, I had not thought of that. Tri-linear filtering isn’t that important to me, so that part sounds fair.
How would I unpack the two components from a float value in a GLSL shader? Also, would I need to take special care when packing, to ensure proper filtering?
I also wonder if it can be made DXT5 compatible. Quality will probably be atrocious though.
In fact there should be no filtering at all, and no destructive compression. So that is GL_NEAREST for MAG filter, GL_NEAREST_MIPMAP_NEAREST for MIN filter.
Will your 8 images be notably different from each other ?
Hmm. Admittedly I’m kind of poking in the dark here. I was convinced that there was some way to pack the two components and still be able to filter between two neighboring pixels. I’m probably mistaken.
I was hoping to use this to store a terrain detail texture ‘mixmaps’. 4 different terrain types is often not enough, 8 is typically exactly right, but doubles the storage cost (2x RGBA8888). 8-bit range for blend factor is overkill. But 4-bit (16 steps per mixmap ‘layer’) is perfectly sufficient.
Also, DXT1/5 has proven to have unpredictable accuracy (especially if the mixmap resolution is low, in places leads to ‘bleeding’ to neighboring 4x4 pixels).
Anyway, the interesting thing about these mixmaps is that they are ‘normalized’, that is, all 8 components combined will add up to 1.0 . Perhaps that can be exploited somehow.
You can filter from within the GLSL shader though :
Sample 4 texels, decode each into 8 values, then interpolate.
Right, that’s the only option that will work for sure.
But maybe I’m just better off with 2x GL_RGBA4 textures.