From b73f42f58bf86f0d43740b5bf5816cb78493fd86 Mon Sep 17 00:00:00 2001 From: RaveYard <29225776+MrRaveYard@users.noreply.github.com> Date: Fri, 1 Sep 2023 09:14:44 +0200 Subject: [PATCH] WIP Attempt to fix the temporary ZDRay tracecoder lightmap write --- .../rendering/vulkan/vk_renderdevice.cpp | 8 ---- src/rendering/hwrenderer/doom_levelmesh.cpp | 41 ++++--------------- 2 files changed, 7 insertions(+), 42 deletions(-) diff --git a/src/common/rendering/vulkan/vk_renderdevice.cpp b/src/common/rendering/vulkan/vk_renderdevice.cpp index 9e33dbe545..d6f6e20e91 100644 --- a/src/common/rendering/vulkan/vk_renderdevice.cpp +++ b/src/common/rendering/vulkan/vk_renderdevice.cpp @@ -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 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(); diff --git a/src/rendering/hwrenderer/doom_levelmesh.cpp b/src/rendering/hwrenderer/doom_levelmesh.cpp index f27b6231d2..1f0b70165b 100644 --- a/src/rendering/hwrenderer/doom_levelmesh.cpp +++ b/src/rendering/hwrenderer/doom_levelmesh.cpp @@ -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;