diff --git a/libraries/gpu/src/gpu/Texture.h b/libraries/gpu/src/gpu/Texture.h index 5dc8871e9d..3c82f67c86 100755 --- a/libraries/gpu/src/gpu/Texture.h +++ b/libraries/gpu/src/gpu/Texture.h @@ -35,6 +35,7 @@ namespace ktx { namespace gpu { extern const std::string SOURCE_HASH_KEY; +const uint8 SOURCE_HASH_BYTES = 16; // THe spherical harmonics is a nice tool for cubemap, so if required, the irradiance SH can be automatically generated // with the cube texture diff --git a/libraries/gpu/src/gpu/Texture_ktx.cpp b/libraries/gpu/src/gpu/Texture_ktx.cpp index 89b7b86768..6828af4cc4 100644 --- a/libraries/gpu/src/gpu/Texture_ktx.cpp +++ b/libraries/gpu/src/gpu/Texture_ktx.cpp @@ -13,7 +13,10 @@ #include "Texture.h" #include +#include + #include + using namespace gpu; using PixelsPointer = Texture::PixelsPointer; @@ -312,7 +315,10 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) { auto hash = texture.sourceHash(); if (!hash.empty()) { - keyValues.emplace_back(SOURCE_HASH_KEY, static_cast(hash.size()), (ktx::Byte*) hash.c_str()); + // the sourceHash is an std::string in hex + // we use QByteArray to take the hex and turn it into the smaller binary representation (16 bytes) + auto binaryHash = QByteArray::fromHex(QByteArray::fromStdString(hash)); + keyValues.emplace_back(SOURCE_HASH_KEY, static_cast(binaryHash.size()), (ktx::Byte*) binaryHash.data()); } auto ktxBuffer = ktx::KTX::create(header, images, keyValues);