Reputation: 21
According documentation i can create HDR compressed texture, so i do this:
funcs->glGenTextures(1, &newCompressedTexture);
funcs->glActiveTexture(GL_TEXTURE0 + g_cTileTextureUnit);
funcs->glBindTexture(GL_TEXTURE_2D, newCompressedTexture);
funcs->glTexStorage2D(GL_TEXTURE_2D, 1, oglTileInfo.m_compressedInternalFormat, g_cTileWidthWithBorder, g_cTileWidthWithBorder);
funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, g_cTileWidthWithBorder, g_cTileWidthWithBorder, GL_RED, GL_FLOAT, getUncompressedData().rData()._m_data.data());
Where oglTileInfo.m_compressedInternalFormat is GL_COMPRESSED_RED_RGTC1 or GL_COMPRESSED_RGBA_ASTC_4x4_KHR. There is no any gl errors, shader works correctly, but value which i am getting by texture() is clamped between [0,1] and its depth only 8 bit. Everything works ok if i use GL_R32F as texture internal format, but i need compression. Thanks.
Upvotes: 0
Views: 876
Reputation: 474116
If your OpenGL implementation supports ASTC textures, you can upload pre-compressed ASTC data to the texture. However, ASTC support does not require implementations to compress texture data for you, so uploading uncompressed data is simply not allowed. You have to compress your data elsewhere before uploading it.
Also, good ASTC compression is not particularly fast, so if you're generating this floating-point data in your application, that's going to be problematic.
As for GL_COMPRESSED_RED_RGTC1
, that is a normalized format. So while implementations are required to compress data for you, it's still going to clamp that data to [0, 1].
BPTC requires implementations to be able to compress such textures inline. So using one of its floating-point formats would probably be functional. However, such compression will not be particularly fast nor will it be particularly good.
Upvotes: 1