diff --git a/project/code/TMV/Mission.cs b/project/code/TMV/Mission.cs index 6adce01..0345b31 100644 --- a/project/code/TMV/Mission.cs +++ b/project/code/TMV/Mission.cs @@ -215,7 +215,7 @@ public partial class Mission : Node3D var cellIdxOffset = 0; for (int polyIdx = 0; polyIdx < maxPolyIdx; polyIdx++) { - var lightmapRectData = ProcessCellSurfaceData(surfaceDataMap, cell, cellIdx, polyIdx, cellIdxOffset); + var lightmapRectData = ProcessCellSurfaceData(surfaceDataMap, worldRep, cellIdx, polyIdx, cellIdxOffset); rectDataMap.Add(packingRects.Count, lightmapRectData); var light = cell.LightList[polyIdx]; @@ -249,8 +249,9 @@ public partial class Mission : Node3D } } - private LightmapRectData ProcessCellSurfaceData(Dictionary surfaceDataMap, WorldRep.Cell cell, int cellIdx, int polyIdx, int indicesOffset) + private LightmapRectData ProcessCellSurfaceData(Dictionary surfaceDataMap, WorldRep worldRep, int cellIdx, int polyIdx, int indicesOffset) { + var cell = worldRep.Cells[cellIdx]; var poly = cell.Polys[polyIdx]; var normal = cell.Planes[poly.PlaneId].Normal.ToGodotVec3(); var vertices = new List(); @@ -266,7 +267,8 @@ public partial class Mission : Node3D var renderPoly = cell.RenderPolys[polyIdx]; var light = cell.LightList[polyIdx]; - var textureId = CalcBaseUV(cell, poly, renderPoly, light, textureUvs, lightmapUvs, indicesOffset); + var lightmapScale = worldRep.DataHeader.LightmapScale; + var textureId = CalcBaseUV(cell, poly, renderPoly, light, textureUvs, lightmapUvs, lightmapScale, indicesOffset); if (!surfaceDataMap.ContainsKey(textureId)) { @@ -344,6 +346,7 @@ public partial class Mission : Node3D WorldRep.Cell.LightmapInfo light, List textureUvs, List lightmapUvs, + float lightmapScale, int cellIdxOffset) { // TODO: This is slightly hardcoded for ND. Check other stuff at some point. Should be handled in LG side imo @@ -356,8 +359,8 @@ public partial class Mission : Node3D var baseU = renderPoly.TextureBases.Item1; var baseV = renderPoly.TextureBases.Item2; - var txUScale = 64.0f / texture.GetWidth(); - var txVScale = 64.0f / texture.GetHeight(); + var txUScale = 64.0f / lightmapScale / texture.GetWidth(); + var txVScale = 64.0f / lightmapScale / texture.GetHeight(); var lmUScale = 4.0f / light.Width; var lmVScale = 4.0f / light.Height;