diff --git a/src/common/rendering/hwrenderer/data/hw_levelmesh.h b/src/common/rendering/hwrenderer/data/hw_levelmesh.h index 6959d8cbf4..2e9119e825 100644 --- a/src/common/rendering/hwrenderer/data/hw_levelmesh.h +++ b/src/common/rendering/hwrenderer/data/hw_levelmesh.h @@ -62,7 +62,7 @@ public: // Surface geometry SurfaceType type = ST_UNKNOWN; TArray verts; - TArray uvs; + TArray uvs; //Plane plane; FVector3 boundsMin, boundsMax; @@ -165,6 +165,20 @@ struct Portal class LevelMesh { public: + LevelMesh() + { + // Default portal + PortalInfo portalInfo; + hwrenderer::Portal portal; + + for (int i = 0; i < 16; ++i) + { + portalInfo.transformation[i] = (&portal.transformation[0][0])[i]; + } + + this->portalInfo.Push(portalInfo); + } + virtual ~LevelMesh() = default; TArray MeshVertices; diff --git a/src/common/rendering/vulkan/vk_renderdevice.cpp b/src/common/rendering/vulkan/vk_renderdevice.cpp index 78455612d3..7af974e792 100644 --- a/src/common/rendering/vulkan/vk_renderdevice.cpp +++ b/src/common/rendering/vulkan/vk_renderdevice.cpp @@ -478,7 +478,7 @@ void VulkanRenderDevice::BeginFrame() void VulkanRenderDevice::InitLightmap(int LMTextureSize, int LMTextureCount, TArray& LMTextureData, hwrenderer::LevelMesh& mesh) { - if(mesh.surfaces.size() > 0) + if(false && mesh.surfaces.size() > 0) { Printf("Running VkLightmap.\n"); @@ -495,7 +495,7 @@ void VulkanRenderDevice::InitLightmap(int LMTextureSize, int LMTextureCount, TAr std::sort(mesh.surfaces.begin(), mesh.surfaces.end(), [](const std::unique_ptr& a, const std::unique_ptr& b) { return a->texHeight != b->texHeight ? a->texHeight > b->texHeight : a->texWidth > b->texWidth; }); - RectPacker packer(LMTextureSize, LMTextureSize); + RectPacker packer(LMTextureSize, LMTextureSize, RectPacker::Spacing(0)); for (auto& surface : mesh.surfaces) { diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 5a4b468b39..89ac76e8c1 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -3390,7 +3390,7 @@ void MapLoader::InitLightmap(MapData* map) return buffer.Data() + ((y * width) + x + (height * width * page)) * 3; }; -#if 0 +//#if 0 srand(1337); for (auto& surface : Level->levelMesh->Surfaces) { @@ -3419,7 +3419,7 @@ void MapLoader::InitLightmap(MapData* map) ptr[2] = floatToHalf(0.0f); } - if (Level->levelMesh->TraceSky(surface.worldOrigin - surface.worldStepX - surface.worldStepY + surface.worldStepX * x + surface.worldStepY * y + FVector3(surface.plane.Normal()), Level->SunDirection, 32000.0f)) + /*if (Level->levelMesh->TraceSky(surface.worldOrigin - surface.worldStepX - surface.worldStepY + surface.worldStepX * x + surface.worldStepY * y + FVector3(surface.plane.Normal()), Level->SunDirection, 32000.0f)) { ptr[0] = floatToHalf(Level->SunColor.X); ptr[1] = floatToHalf(Level->SunColor.Y); @@ -3430,11 +3430,11 @@ void MapLoader::InitLightmap(MapData* map) ptr[0] = 0; ptr[1] = 0; ptr[2] = 0; - } + }*/ } } } -#endif +//#endif }; int size = Level->LMTextureSize; diff --git a/src/rendering/hwrenderer/doom_levelmesh.cpp b/src/rendering/hwrenderer/doom_levelmesh.cpp index bcc48afbc2..f8a7459f31 100644 --- a/src/rendering/hwrenderer/doom_levelmesh.cpp +++ b/src/rendering/hwrenderer/doom_levelmesh.cpp @@ -492,28 +492,25 @@ int DoomLevelMesh::SetupLightmapUvs(int lightmapSize) sortedSurfaces.push_back(&surface); } - { - this->portalInfo.Clear(); // TODO portals - - PortalInfo portalInfo; - hwrenderer::Portal portal; - - for (int i = 0; i < 16; ++i) - { - portalInfo.transformation[i] = (&portal.transformation[0][0])[i]; - } - - this->portalInfo.Push(portalInfo); - } for (const auto& surface : Surfaces) { auto hwSurface = std::make_unique(); + for (int i = 0; i < surface.numVerts; ++i) + { + hwSurface->verts.Push(MeshVertices[surface.startVertIndex + i]); + } + + for (int i = 0; i < surface.numVerts; ++i) + { + hwSurface->uvs.Push( + FVector2(LightmapUvs[surface.startUvIndex + i * 2], LightmapUvs[surface.startUvIndex + i * 2 + 1])); + } + hwSurface->boundsMax = surface.bounds.max; hwSurface->boundsMin = surface.bounds.min; - // hwSurface->LightList = // TODO hwSurface->projLocalToU = surface.projLocalToU; hwSurface->projLocalToV = surface.projLocalToV; hwSurface->smoothingGroupIndex = 0; @@ -527,14 +524,9 @@ int DoomLevelMesh::SetupLightmapUvs(int lightmapSize) for (auto& pixel : hwSurface->texPixels) { - pixel.X = floatToHalf(0.0); - pixel.X = floatToHalf(1.0); - pixel.X = floatToHalf(0.0); - } - - for (int i = 0; i < surface.numVerts; ++i) - { - hwSurface->verts.Push(MeshVertices[surface.startVertIndex + i]); + pixel.X = 0.0; + pixel.Y = 1.0; + pixel.Z = 0.0; } // TODO push