compressonator icon indicating copy to clipboard operation
compressonator copied to clipboard

Problem with using BC6H_SF compression for Normals map

Open native-engine opened this issue 6 years ago • 6 comments

All negative values in texture when rendering is equal to zero. Values range is -1.0 to 1.0. Texture using in OpenGL as GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT.

unsigned uiTextureSize = texWidth * texHeight * (Texture.texBPP / 8)
std::vector<float> vFloatDataBuffer(uiTextureSize);
glGetTexImage(GL_TEXTURE_2D, level, GL_RGBA, GL_FLOAT, vFloatDataBuffer.data());

CMP_Texture srcTexture;
srcTexture.dwSize = sizeof(CMP_Texture);
srcTexture.dwWidth = texWidth;
srcTexture.dwHeight = texHeight;
srcTexture.dwPitch = (((Texture.texBPP * texWidth) + Texture.texBPP - 1) / Texture.texBPP) * (Texture.texBPP / 8);
srcTexture.format = CMP_FORMAT_ARGB_32F;
srcTexture.dwDataSize = uiTextureSize;
srcTexture.pData = (CMP_BYTE*)vFloatDataBuffer.data();

CMP_Texture destTexture;
destTexture.dwSize = sizeof(CMP_Texture);
destTexture.dwWidth = texWidth;
destTexture.dwHeight = texHeight;
destTexture.dwPitch = 0;
destTexture.format = CMP_FORMAT_BC6H_SF;
destTexture.dwDataSize = CMP_CalculateBufferSize(&destTexture);
std::vector<CMP_BYTE> destTextureData(destTexture.dwDataSize);
destTexture.pData = destTextureData.data();

CMP_CompressOptions options = {0};
options.dwSize = sizeof(CMP_CompressOptions);
options.fquality = 0.05f;
options.dwnumThreads = 8;

CMP_ERROR cmp_status = CMP_ConvertTexture(&srcTexture, &destTexture, &options, &CompressionCallback, 0, 0);

native-engine avatar Oct 12 '19 21:10 native-engine

CMP_FORMAT_RGBA_32F don`t working and CMP_FORMAT_ARGB_32F working as CMP_FORMAT_RGBA_32F. Loading and rendering of uncompressed signed float Normals is correct. All other types of compression don't cause any problems.

native-engine avatar Oct 16 '19 08:10 native-engine

@daniilpetrov
Thank you for the details of the issue. The source texture format input setting is been investigated for BC6H.

NPCompress avatar Oct 16 '19 11:10 NPCompress

In new release of library problem with negative values is remain...

native-engine avatar Dec 21 '19 01:12 native-engine

The issue has not been resolved. It is still pending work.

NPCompress avatar Dec 22 '19 16:12 NPCompress

When can you resolve my issue? I would like to solve it.

native-engine avatar Apr 02 '20 08:04 native-engine

@daniilpetrov "When can you resolve my issue?" The BC6H codec is been reworked, it will take some time to complete. There is a release scheduled for next week, but the new code for BC6H will not be available until the release after that.

NPCompress avatar May 07 '20 14:05 NPCompress

@daniilpetrov In the next release the negative value issue should be resolved. Also, the BC6H codec assumes the input data is in RGBA order, so ARGB won't work as you might want. To that end, CMP_FORMAT_RGBA_32F should no longer fail in the next release.

denislevesqueAMD avatar Oct 17 '22 14:10 denislevesqueAMD

The issue has been resolved in current release

NPCompress avatar Jul 19 '23 19:07 NPCompress