WIP VkLightmap integration

This commit is contained in:
RaveYard 2023-08-31 19:15:15 +02:00 committed by Magnus Norddahl
commit 651903fe71
12 changed files with 262 additions and 41 deletions

View file

@ -3219,7 +3219,7 @@ void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position)
Level->levelMesh = new DoomLevelMesh(*Level);
InitLightmap(map);
screen->InitLightmap(Level->LMTextureSize, Level->LMTextureCount, Level->LMTextureData);
screen->InitLightmap(Level->LMTextureSize, Level->LMTextureCount, Level->LMTextureData, *Level->levelMesh);
for (int i = 0; i < MAXPLAYERS; ++i)
{
@ -3332,7 +3332,7 @@ void MapLoader::SetSideLightmap(const LightmapSurface &surface)
}
}
#include "halffloat.h"
#include "vulkan/accelstructs/halffloat.h"
void MapLoader::InitLightmap(MapData* map)
{
@ -3347,6 +3347,10 @@ void MapLoader::InitLightmap(MapData* map)
Level->SunColor = FVector3(1.f, 1.f, 1.f);
Level->SunDirection = FVector3(0.45f, 0.3f, 0.9f);
// TODO keep only one copy?
Level->levelMesh->SunColor = Level->SunColor;
Level->levelMesh->SunDirection = Level->SunDirection;
Level->LMTextureCount = Level->levelMesh->SetupLightmapUvs(Level->LMTextureSize);
@ -3391,7 +3395,7 @@ void MapLoader::InitLightmap(MapData* map)
return buffer.Data() + ((y * width) + x + (height * width * page)) * 3;
};
#if 0
srand(1337);
for (auto& surface : Level->levelMesh->Surfaces)
{
@ -3399,9 +3403,9 @@ void MapLoader::InitLightmap(MapData* map)
float g;
float b;
r = rand() % 32 / 32.0;
g = rand() % 32 / 32.0;
b = rand() % 32 / 32.0;
r = rand() % 32 / 32.0f;
g = rand() % 32 / 32.0f;
b = rand() % 32 / 32.0f;
for (int y = 0; y <= surface.texHeight; ++y)
{
@ -3435,6 +3439,7 @@ void MapLoader::InitLightmap(MapData* map)
}
}
}
#endif
};
int size = Level->LMTextureSize;