WIP Attempt to fix the temporary ZDRay tracecoder lightmap write

This commit is contained in:
RaveYard 2023-09-01 09:14:44 +02:00 committed by Christoph Oelckers
parent c842f32941
commit b73f42f58b
2 changed files with 7 additions and 42 deletions

View file

@ -553,21 +553,13 @@ void VulkanRenderDevice::SetLevelMesh(hwrenderer::LevelMesh* mesh)
Printf("Copying data.\n");
// TODO refactor
auto clamp = [](float a, float min, float max) -> float { return a < min ? min : a > max ? max : a; };
// BUG: This is a destructive action as it reorders the surfaces array that is indexed by MeshSurfaces
std::sort(mesh->Surfaces.begin(), mesh->Surfaces.end(), [](const hwrenderer::Surface& a, const hwrenderer::Surface& b) { return a.texHeight != b.texHeight ? a.texHeight > b.texHeight : a.texWidth > b.texWidth; });
RectPacker packer(mesh->LMTextureSize, mesh->LMTextureSize, RectPacker::Spacing(0));
TArray<uint16_t> LMTextureData;
LMTextureData.Resize(mesh->LMTextureSize * mesh->LMTextureSize * mesh->LMTextureCount * 3);
for (auto& surface : mesh->Surfaces)
{
mesh->FinishSurface(mesh->LMTextureSize, mesh->LMTextureSize, packer, surface);
uint16_t* currentTexture = LMTextureData.Data() + (mesh->LMTextureSize * mesh->LMTextureSize * 3) * surface.atlasPageIndex;
FVector3* colorSamples = surface.texPixels.data();

View file

@ -622,62 +622,36 @@ void DoomLevelMesh::SetupLightmapUvs()
sortedSurfaces.push_back(&surface);
}
#if 0
for (const auto& surface : Surfaces)
// VkLightmapper old ZDRay properties
for (auto& surface : Surfaces)
{
hwrenderer::Surface hwSurface;
for (int i = 0; i < surface.numVerts; ++i)
{
hwSurface->verts.Push(MeshVertices[surface.startVertIndex + i]);
surface.verts.Push(MeshVertices[surface.startVertIndex + i]);
}
for (int i = 0; i < surface.numVerts; ++i)
{
hwSurface->uvs.Push(LightmapUvs[surface.startUvIndex + i]);
surface.uvs.Push(LightmapUvs[surface.startUvIndex + i]);
}
hwSurface->boundsMax = surface.bounds.max;
hwSurface->boundsMin = surface.bounds.min;
hwSurface->projLocalToU = surface.projLocalToU;
hwSurface->projLocalToV = surface.projLocalToV;
hwSurface->smoothingGroupIndex = 0;
hwSurface->texHeight = surface.texHeight;
hwSurface->texWidth = surface.texWidth;
hwSurface->translateWorldToLocal = surface.translateWorldToLocal;
hwSurface->type = hwrenderer::SurfaceType(surface.type);
hwSurface->texPixels.resize(surface.texWidth * surface.texHeight);
for (auto& pixel : hwSurface->texPixels)
{
pixel.X = 0.0;
pixel.Y = 1.0;
pixel.Z = 0.0;
}
// TODO push
Surfaces.push_back(hwSurface);
surface.texPixels.resize(surface.texWidth * surface.texHeight);
SurfaceInfo info;
info.Normal = surface.plane.XYZ();
info.PortalIndex = 0;
info.SamplingDistance = (float)surface.sampleDimension;
info.Sky = surface.bSky;
surfaceInfo.Push(info);
}
#endif
{
hwrenderer::SmoothingGroup smoothing;
for (auto& surface : Surfaces)
{
surface.smoothingGroupIndex = 0;
smoothing.surfaces.push_back(&surface);
}
smoothingGroups.Push(std::move(smoothing));
@ -912,7 +886,6 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex
surface.texWidth = width;
surface.texHeight = height;
//surface->texPixels.resize(width * height);
surface.worldOrigin = tOrigin;
surface.worldStepX = tCoords[0] * (float)surface.sampleDimension;
surface.worldStepY = tCoords[1] * (float)surface.sampleDimension;