Handle lightmap scale
This commit is contained in:
parent
9605c36303
commit
efb15c19dd
|
@ -215,7 +215,7 @@ public partial class Mission : Node3D
|
||||||
var cellIdxOffset = 0;
|
var cellIdxOffset = 0;
|
||||||
for (int polyIdx = 0; polyIdx < maxPolyIdx; polyIdx++)
|
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);
|
rectDataMap.Add(packingRects.Count, lightmapRectData);
|
||||||
|
|
||||||
var light = cell.LightList[polyIdx];
|
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 poly = cell.Polys[polyIdx];
|
||||||
var normal = cell.Planes[poly.PlaneId].Normal.ToGodotVec3();
|
var normal = cell.Planes[poly.PlaneId].Normal.ToGodotVec3();
|
||||||
var vertices = new List<Vector3>();
|
var vertices = new List<Vector3>();
|
||||||
|
@ -266,7 +267,8 @@ 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 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))
|
if (!surfaceDataMap.ContainsKey(textureId))
|
||||||
{
|
{
|
||||||
|
@ -344,6 +346,7 @@ public partial class Mission : Node3D
|
||||||
WorldRep.Cell.LightmapInfo light,
|
WorldRep.Cell.LightmapInfo light,
|
||||||
List<Vector2> textureUvs,
|
List<Vector2> textureUvs,
|
||||||
List<Vector2> lightmapUvs,
|
List<Vector2> lightmapUvs,
|
||||||
|
float lightmapScale,
|
||||||
int cellIdxOffset)
|
int cellIdxOffset)
|
||||||
{
|
{
|
||||||
// TODO: This is slightly hardcoded for ND. Check other stuff at some point. Should be handled in LG side imo
|
// 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 baseU = renderPoly.TextureBases.Item1;
|
||||||
var baseV = renderPoly.TextureBases.Item2;
|
var baseV = renderPoly.TextureBases.Item2;
|
||||||
|
|
||||||
var txUScale = 64.0f / texture.GetWidth();
|
var txUScale = 64.0f / lightmapScale / texture.GetWidth();
|
||||||
var txVScale = 64.0f / texture.GetHeight();
|
var txVScale = 64.0f / lightmapScale / texture.GetHeight();
|
||||||
var lmUScale = 4.0f / light.Width;
|
var lmUScale = 4.0f / light.Width;
|
||||||
var lmVScale = 4.0f / light.Height;
|
var lmVScale = 4.0f / light.Height;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue