ADD: IBL added

This commit is contained in:
2025-11-13 17:46:14 +09:00
parent 24e83061b4
commit ac4e437934
21 changed files with 837 additions and 54 deletions

View File

@@ -8,18 +8,17 @@ class EngineContext;
struct IBLPaths
{
std::string specularCube; // .ktx2 (GPU-ready BC6H or R16G16B16A16)
std::string diffuseCube; // .ktx2
std::string brdfLut2D; // .ktx2 (BC5 RG UNORM or similar)
std::string diffuseCube; // .ktx2
std::string brdfLut2D; // .ktx2 (BC5 RG UNORM or similar)
};
// Minimal IBL asset owner with optional residency control.
class IBLManager
{
public:
void init(EngineContext* ctx) { _ctx = ctx; }
void init(EngineContext *ctx) { _ctx = ctx; }
// Load all three textures. Returns true when specular+diffuse (and optional LUT) are resident.
bool load(const IBLPaths& paths);
bool load(const IBLPaths &paths);
// Release GPU memory and patch to fallbacks handled by the caller.
void unload();
@@ -27,13 +26,22 @@ public:
bool resident() const { return _spec.image != VK_NULL_HANDLE || _diff.image != VK_NULL_HANDLE; }
AllocatedImage specular() const { return _spec; }
AllocatedImage diffuse() const { return _diff; }
AllocatedImage brdf() const { return _brdf; }
AllocatedImage diffuse() const { return _diff; }
AllocatedImage brdf() const { return _brdf; }
AllocatedBuffer shBuffer() const { return _shBuffer; }
bool hasSH() const { return _shBuffer.buffer != VK_NULL_HANDLE; }
// Descriptor set layout used by shaders (set=3)
VkDescriptorSetLayout descriptorLayout() const { return _iblSetLayout; }
// Build descriptor set layout without loading images (for early pipeline creation)
bool ensureLayout();
private:
EngineContext* _ctx{nullptr};
EngineContext *_ctx{nullptr};
AllocatedImage _spec{};
AllocatedImage _diff{};
AllocatedImage _brdf{};
VkDescriptorSetLayout _iblSetLayout = VK_NULL_HANDLE;
AllocatedBuffer _shBuffer{}; // 9*vec4 coefficients (RGB in .xyz)
};