Fix incorrect lightmap scale multiplier

This commit is contained in:
Jarrod Doyle 2024-08-27 08:02:10 +01:00
parent bb617ffc52
commit cbf309aaa4
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 11 additions and 1 deletions

View File

@ -29,6 +29,16 @@ public class WorldRep : IChunk
DataSize = reader.ReadUInt32(); DataSize = reader.ReadUInt32();
CellCount = reader.ReadUInt32(); CellCount = reader.ReadUInt32();
} }
public readonly float LightmapScaleMultiplier()
{
return Math.Sign(LightmapScale) switch
{
1 => LightmapScale,
-1 => 1.0f / LightmapScale,
_ => 1.0f,
};
}
} }
public struct Cell public struct Cell

View File

@ -267,7 +267,7 @@ public partial class Mission : Node3D
var renderPoly = cell.RenderPolys[polyIdx]; var renderPoly = cell.RenderPolys[polyIdx];
var light = cell.LightList[polyIdx]; var light = cell.LightList[polyIdx];
var lightmapScale = worldRep.DataHeader.LightmapScale; var lightmapScale = worldRep.DataHeader.LightmapScaleMultiplier();
var textureId = CalcBaseUV(cell, poly, renderPoly, light, textureUvs, lightmapUvs, lightmapScale, indicesOffset); var textureId = CalcBaseUV(cell, poly, renderPoly, light, textureUvs, lightmapUvs, lightmapScale, indicesOffset);
if (!surfaceDataMap.ContainsKey(textureId)) if (!surfaceDataMap.ContainsKey(textureId))