Fix light probe uploads
This commit is contained in:
parent
af6ec929cc
commit
7409efd44d
3 changed files with 33 additions and 42 deletions
|
|
@ -395,48 +395,36 @@ void VkTextureManager::CreateLightmap()
|
|||
|
||||
void VkTextureManager::CreateIrradiancemap()
|
||||
{
|
||||
TArray<uint16_t> data;
|
||||
for (int arrayIndex = 0; arrayIndex < 6; arrayIndex++)
|
||||
{
|
||||
data.Push(0);
|
||||
data.Push(0);
|
||||
data.Push(0);
|
||||
}
|
||||
CreateIrradiancemap(1, 1, std::move(data));
|
||||
TArray<uint16_t> data(IrradiancemapSize * IrradiancemapSize * 6 * 3, true);
|
||||
memset(data.data(), 0, data.size() * sizeof(uint16_t));
|
||||
UploadIrradiancemap(1, std::move(data));
|
||||
}
|
||||
|
||||
void VkTextureManager::CreatePrefiltermap()
|
||||
{
|
||||
TArray<uint16_t> data;
|
||||
int size = 1 << MAX_REFLECTION_LOD;
|
||||
for (int arrayIndex = 0; arrayIndex < 6; arrayIndex++)
|
||||
int texsize = 0;
|
||||
for (int level = 0; level <= MAX_REFLECTION_LOD; level++)
|
||||
{
|
||||
for (int level = 0; level <= MAX_REFLECTION_LOD; level++)
|
||||
{
|
||||
int mipsize = size >> level;
|
||||
for (int i = 0; i < mipsize * mipsize; i++)
|
||||
{
|
||||
data.Push(0);
|
||||
data.Push(0);
|
||||
data.Push(0);
|
||||
}
|
||||
}
|
||||
int mipsize = PrefiltermapSize >> level;
|
||||
texsize += mipsize * mipsize;
|
||||
}
|
||||
CreatePrefiltermap(size, 1, std::move(data));
|
||||
|
||||
TArray<uint16_t> data(texsize * 6 * 3, true);
|
||||
memset(data.data(), 0, data.size() * sizeof(uint16_t));
|
||||
UploadPrefiltermap(1, std::move(data));
|
||||
}
|
||||
|
||||
void VkTextureManager::CreateIrradiancemap(int size, int cubeCount, const TArray<uint16_t>& srcPixels)
|
||||
void VkTextureManager::UploadIrradiancemap(int cubeCount, const TArray<uint16_t>& srcPixels)
|
||||
{
|
||||
for (auto& tex : Irradiancemaps)
|
||||
tex.Reset(fb);
|
||||
Irradiancemaps.clear();
|
||||
Irradiancemaps.resize(cubeCount);
|
||||
int createStart = Irradiancemaps.size();
|
||||
if (Irradiancemaps.size() <= (size_t)cubeCount)
|
||||
Irradiancemaps.resize(cubeCount + 1);
|
||||
|
||||
int w = size;
|
||||
int h = size;
|
||||
int w = IrradiancemapSize;
|
||||
int h = IrradiancemapSize;
|
||||
int pixelsize = 8;
|
||||
|
||||
for (int i = 0; i < cubeCount; i++)
|
||||
for (int i = createStart; i < cubeCount; i++)
|
||||
{
|
||||
Irradiancemaps[i].Image = ImageBuilder()
|
||||
.Size(w, h, 1, 6)
|
||||
|
|
@ -505,19 +493,18 @@ void VkTextureManager::CreateIrradiancemap(int size, int cubeCount, const TArray
|
|||
barrier1.Execute(cmdbuffer);
|
||||
}
|
||||
|
||||
void VkTextureManager::CreatePrefiltermap(int size, int cubeCount, const TArray<uint16_t>& srcPixels)
|
||||
void VkTextureManager::UploadPrefiltermap(int cubeCount, const TArray<uint16_t>& srcPixels)
|
||||
{
|
||||
for (auto& tex : Prefiltermaps)
|
||||
tex.Reset(fb);
|
||||
Prefiltermaps.clear();
|
||||
Prefiltermaps.resize(cubeCount);
|
||||
int createStart = Prefiltermaps.size();
|
||||
if (Prefiltermaps.size() <= (size_t)cubeCount)
|
||||
Prefiltermaps.resize(cubeCount + 1);
|
||||
|
||||
int w = size;
|
||||
int h = size;
|
||||
int w = PrefiltermapSize;
|
||||
int h = PrefiltermapSize;
|
||||
int pixelsize = 8;
|
||||
int miplevels = MAX_REFLECTION_LOD + 1;
|
||||
|
||||
for (int i = 0; i < cubeCount; i++)
|
||||
for (int i = createStart; i < cubeCount; i++)
|
||||
{
|
||||
Prefiltermaps[i].Image = ImageBuilder()
|
||||
.Size(w, h, miplevels, 6)
|
||||
|
|
|
|||
|
|
@ -31,10 +31,11 @@ public:
|
|||
void SetLightmapCount(int size, int count);
|
||||
|
||||
void CreateLightmap(int size, int count, const TArray<uint16_t>& data);
|
||||
void CreateIrradiancemap(int size, int cubeCount, const TArray<uint16_t>& data);
|
||||
void CreatePrefiltermap(int size, int cubeCount, const TArray<uint16_t>& data);
|
||||
void DownloadLightmap(int arrayIndex, uint16_t* buffer);
|
||||
|
||||
void UploadIrradiancemap(int cubeCount, const TArray<uint16_t>& data);
|
||||
void UploadPrefiltermap(int cubeCount, const TArray<uint16_t>& data);
|
||||
|
||||
void SetGamePalette();
|
||||
|
||||
VkTextureImage* GetTexture(const PPTextureType& type, PPTexture* tex);
|
||||
|
|
@ -73,6 +74,9 @@ public:
|
|||
int CreateUploadID(VkHardwareTexture* tex);
|
||||
bool CheckUploadID(int id);
|
||||
|
||||
static const int PrefiltermapSize = 128;
|
||||
static const int IrradiancemapSize = 32;
|
||||
|
||||
private:
|
||||
void CreateNullTexture();
|
||||
void CreateBrdfLutTexture();
|
||||
|
|
|
|||
|
|
@ -415,8 +415,8 @@ void VulkanRenderDevice::RenderEnvironmentMap(std::function<void(IntRect& bounds
|
|||
|
||||
void VulkanRenderDevice::UploadEnvironmentMaps(int cubemapCount, const TArray<uint16_t>& irradianceMaps, const TArray<uint16_t>& prefilterMaps)
|
||||
{
|
||||
mTextureManager->CreateIrradiancemap(32, cubemapCount, irradianceMaps);
|
||||
mTextureManager->CreatePrefiltermap(128, cubemapCount, prefilterMaps);
|
||||
mTextureManager->UploadIrradiancemap(cubemapCount, irradianceMaps);
|
||||
mTextureManager->UploadPrefiltermap(cubemapCount, prefilterMaps);
|
||||
}
|
||||
|
||||
void VulkanRenderDevice::PostProcessScene(bool swscene, int fixedcm, float flash, bool palettePostprocess, const std::function<void()> &afterBloomDrawEndScene2D)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue