Compare commits

..

No commits in common. "2e1c90b88a8f24f302c16fec2b0c5ea807f0d40e" and "42daa8a048d2ef0b6dcc2262f8fb11f977faf8e2" have entirely different histories.

2 changed files with 8 additions and 59 deletions

View File

@ -351,9 +351,6 @@ public class WorldRep : IChunk
public Lightmap[] Lightmaps { get; set; }
public int LightIndexCount { get; set; }
public List<ushort> LightIndices { get; set; }
// Bonus data to make parallel iteration of cells easier
public CellZone ZoneInfo { get; set; } = new();
public Cell(BinaryReader reader, int bpp)
{
@ -474,37 +471,6 @@ public class WorldRep : IChunk
}
}
// Readonly for now
public record CellZone
{
private readonly byte _data;
public CellZone()
{
_data = 0;
}
public CellZone(BinaryReader reader)
{
_data = reader.ReadByte();
}
public int GetAmbientLightZoneIndex()
{
return _data >> 4;
}
public int GetFogZoneIndex()
{
return _data & 0x0F;
}
public void Write(BinaryWriter writer)
{
writer.Write(_data);
}
}
public struct BspTree
{
public struct Node
@ -704,8 +670,8 @@ public class WorldRep : IChunk
public WrHeader DataHeader { get; set; }
public Cell[] Cells { get; set; }
public BspTree Bsp { get; set; }
public CellZone[] CellZones { get; set; }
public LightTable LightingTable { get; set; }
private byte[] _unknown;
private byte[] _unreadData;
public void ReadData(BinaryReader reader, DbFile.TableOfContents.Entry entry)
@ -720,14 +686,9 @@ public class WorldRep : IChunk
}
Bsp = new BspTree(reader);
CellZones = new CellZone[Cells.Length];
for (var i = 0; i < Cells.Length; i++)
{
var zone = new CellZone(reader);
CellZones[i] = zone;
Cells[i].ZoneInfo = zone;
}
// TODO: Work out what this is
_unknown = reader.ReadBytes(Cells.Length);
LightingTable = new LightTable(reader);
// TODO: All the other info lol
@ -743,10 +704,7 @@ public class WorldRep : IChunk
cell.Write(writer);
}
Bsp.Write(writer);
foreach (var cellZone in CellZones)
{
cellZone.Write(writer);
}
writer.Write(_unknown);
LightingTable.Write(writer);
writer.Write(_unreadData);
}

View File

@ -19,7 +19,7 @@ public class LightMapper
private struct Settings
{
public Vector3[] AmbientLight;
public Vector3 AmbientLight;
public bool Hdr;
public SoftnessMode MultiSampling;
public float MultiSamplingCenterWeight;
@ -76,19 +76,12 @@ public class LightMapper
Direction = Vector3.Normalize(rendParams.sunlightDirection),
Color = Utils.HsbToRgb(rendParams.sunlightHue, rendParams.sunlightSaturation, rendParams.sunlightBrightness),
};
var ambientLight = rendParams.ambientLightZones.ToList();
ambientLight.Insert(0, rendParams.ambientLight);
for (var i = 0; i < ambientLight.Count; i++)
{
ambientLight[i] *= 255;
}
// TODO: lmParams LightmappedWater doesn't mean the game will actually *use* the lightmapped water hmm
var settings = new Settings
{
Hdr = worldRep.DataHeader.LightmapFormat == 2,
AmbientLight = [..ambientLight],
AmbientLight = rendParams.ambientLight * 255,
MultiSampling = lmParams.ShadowSoftness,
MultiSamplingCenterWeight = lmParams.CenterWeight,
LightmappedWater = lmParams.LightmappedWater,
@ -482,9 +475,7 @@ public class LightMapper
lightmap.Reset(Vector3.One * 255f, settings.Hdr);
continue;
}
var ambientLight = settings.AmbientLight[cell.ZoneInfo.GetAmbientLightZoneIndex()];
lightmap.Reset(ambientLight, settings.Hdr);
lightmap.Reset(settings.AmbientLight, settings.Hdr);
// Get world position of lightmap (0, 0) (+0.5 so we cast from the center of a pixel)
var topLeft = cell.Vertices[cell.Indices[cellIdxOffset]];