Updated code for generating cubemap:
#include "UltraEngine.h"
using namespace UltraEngine;
// https://www.ultraengine.com/community/blogs/entry/2780-building-a-single-file-4k-hdr-skybox-with-bc6-compression/
int main(int argc, const char* argv[])
{
//Settings
const bool compression = true;
// Load required plugin
auto fiplugin = LoadPlugin("Plugins/FITextureLoader");
auto cplugin = LoadPlugin("Plugins/ISPCTexComp");
// Load cube faces output from https://matheowis.github.io/HDRI-to-CubeMap/
std::vector<std::shared_ptr<Pixmap> > mipchain;
WString files[6] = { "px.hdr", "nx.hdr", "py.hdr", "ny.hdr", "pz.hdr", "nz.hdr" };
for (int n = 0; n < 6; ++n)
{
auto pixmap = LoadPixmap(files[n]);
Assert(pixmap);
if (pixmap->format != VK_FORMAT_R16G16B16A16_SFLOAT)
{
pixmap = pixmap->Convert(TextureFormat(VK_FORMAT_R16G16B16A16_SFLOAT));// this step is required for BC6H conversion
}
while (true)
{
auto mipmap = pixmap;
if (compression) mipmap = mipmap->Convert(TEXTURE_BC6H);
Assert(mipmap);
mipchain.push_back(mipmap);
auto size = pixmap->size;
if (size.x == mipmap->blocksize and size.y == mipmap->blocksize) break;
size /= 2;
pixmap = pixmap->Resize(size.x, size.y);
Assert(pixmap);
}
}
// Save cubemap
SaveTexture("skybox.dds", TEXTURE_CUBE, mipchain, 6);
return 0;
}