#pragma once #include "zvulkan/vulkanobjects.h" #include "vectors.h" #include "vulkan/textures/vk_imagetransition.h" class VulkanRenderDevice; class FString; class ShaderIncludeResult; struct IrradianceMapPushConstants { FVector3 dir; float padding0; FVector3 up; float padding1; FVector3 side; float padding2; }; struct PrefilterMapPushConstants { FVector3 dir; float roughness; FVector3 up; float padding0; FVector3 side; float padding1; }; class VkLightprober { public: VkLightprober(VulkanRenderDevice* fb); ~VkLightprober(); void RenderEnvironmentMap(std::function renderFunc); bool GenerateIrradianceMap(TArrayView& databuffer); bool GeneratePrefilterMap(TArrayView& databuffer); private: void CreateBrdfLutResources(); void CreateEnvironmentMap(); void CreateIrradianceMap(); void CreatePrefilterMap(); void GenerateBrdfLut(); std::unique_ptr CompileShader(const std::string& name, const std::string& filename, const char* debugName); static FString LoadPrivateShaderLump(const char* lumpname); static FString LoadPublicShaderLump(const char* lumpname); static ShaderIncludeResult OnInclude(FString headerName, FString includerName, size_t depth, bool system); struct { std::unique_ptr shader; std::unique_ptr descriptorSetLayout; std::unique_ptr descriptorPool; std::unique_ptr descriptorSet; std::unique_ptr pipelineLayout; std::unique_ptr pipeline; std::unique_ptr image; std::unique_ptr view; } brdfLut; struct { enum { textureSize = 256 }; std::unique_ptr cubeimage; std::unique_ptr cubeview; std::unique_ptr zbuffer; std::unique_ptr zbufferview; VkTextureImage renderTargets[6]; } environmentMap; struct { std::unique_ptr shader; std::unique_ptr descriptorSetLayout; std::unique_ptr descriptorPool; std::unique_ptr descriptorSets[6]; std::unique_ptr pipelineLayout; std::unique_ptr pipeline; std::unique_ptr sampler; std::unique_ptr images[6]; std::unique_ptr views[6]; } irradianceMap; struct PrefilterMap { enum { maxlevels = 5, levelsSize = DFrameBuffer::prefilterMapLevelsSize }; std::unique_ptr shader; std::unique_ptr descriptorSetLayout; std::unique_ptr descriptorPool; std::unique_ptr descriptorSets[6 * maxlevels]; std::unique_ptr pipelineLayout; std::unique_ptr pipeline; std::unique_ptr sampler; std::unique_ptr images[6 * maxlevels]; std::unique_ptr views[6 * maxlevels]; } prefilterMap; VulkanRenderDevice* fb = nullptr; };