Apply HDR mapping to ambient light

This commit is contained in:
Jarrod Doyle 2024-09-24 21:48:45 +01:00
parent ce7002477e
commit 5957b5b53f
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 9 additions and 3 deletions

View File

@ -243,7 +243,7 @@ class Program
var info = cell.LightList[polyIdx]; var info = cell.LightList[polyIdx];
var lightmap = cell.Lightmaps[polyIdx]; var lightmap = cell.Lightmaps[polyIdx];
ResetLightmap(ambientLight, lightmap); ResetLightmap(ambientLight, lightmap, hdr);
// Get world position of lightmap (0, 0) (+0.5 so we cast from the center of a pixel) // 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]]; var topLeft = cell.Vertices[cell.Indices[cellIdxOffset]];
@ -367,18 +367,24 @@ class Program
Console.Write("\n"); Console.Write("\n");
} }
private static void ResetLightmap(Vector3 ambientLight, WorldRep.Cell.Lightmap lightmap) private static void ResetLightmap(Vector3 ambientLight, WorldRep.Cell.Lightmap lightmap, bool hdr)
{ {
for (var i = 0; i < lightmap.Pixels.Length; i++) for (var i = 0; i < lightmap.Pixels.Length; i++)
{ {
lightmap.Pixels[i] = 0; lightmap.Pixels[i] = 0;
} }
var c = ambientLight;
if (hdr)
{
c /= 2.0f;
}
for (var y = 0; y < lightmap.Height; y++) for (var y = 0; y < lightmap.Height; y++)
{ {
for (var x = 0; x < lightmap.Width; x++) for (var x = 0; x < lightmap.Width; x++)
{ {
lightmap.AddLight(0, x, y, (byte)ambientLight.X, (byte)ambientLight.Y, (byte)ambientLight.Z); lightmap.AddLight(0, x, y, (byte)c.X, (byte)c.Y, (byte)c.Z);
} }
} }
} }