Handle lightmap scale

This commit is contained in:
Jarrod Doyle 2024-08-26 16:53:01 +01:00
parent 9605c36303
commit efb15c19dd
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 8 additions and 5 deletions

View File

@ -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<int, MeshSurfaceData> surfaceDataMap, WorldRep.Cell cell, int cellIdx, int polyIdx, int indicesOffset)
private LightmapRectData ProcessCellSurfaceData(Dictionary<int, MeshSurfaceData> 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<Vector3>();
@ -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<Vector2> textureUvs,
List<Vector2> 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;