This commit is contained in:
2025-12-01 19:35:38 +09:00
parent 637a83bf6f
commit 64528f2c4a
10 changed files with 479 additions and 5 deletions

View File

@@ -237,7 +237,29 @@ bool IBLManager::load(const IBLPaths &paths)
_diff = _spec;
}
// If background is still missing but specular is valid, reuse the specular environment.
if (!paths.background2D.empty())
{
ktxutil::Ktx2D bg{};
if (ktxutil::load_ktx2_2d(paths.background2D.c_str(), bg))
{
std::vector<ResourceManager::MipLevelCopy> lv;
lv.reserve(bg.mipLevels);
for (uint32_t mip = 0; mip < bg.mipLevels; ++mip)
{
const auto &r = bg.copies[mip];
lv.push_back(ResourceManager::MipLevelCopy{
.offset = r.bufferOffset,
.length = 0,
.width = r.imageExtent.width,
.height = r.imageExtent.height,
});
}
_background = rm->create_image_compressed(
bg.bytes.data(), bg.bytes.size(), bg.fmt, lv,
VK_IMAGE_USAGE_SAMPLED_BIT);
}
}
if (_background.image == VK_NULL_HANDLE && _spec.image != VK_NULL_HANDLE)
{
_background = _spec;