Compare commits
No commits in common. "49a1b4bfccca4c2b7a90c2aa1adf37f9971c5d47" and "860080ada3936f12feb01043032278db0fef3e57" have entirely different histories.
49a1b4bfcc
...
860080ada3
|
@ -1,5 +1,4 @@
|
||||||
using System.Diagnostics;
|
using System.Numerics;
|
||||||
using System.Numerics;
|
|
||||||
using KeepersCompound.LGS.Database;
|
using KeepersCompound.LGS.Database;
|
||||||
using KeepersCompound.LGS.Database.Chunks;
|
using KeepersCompound.LGS.Database.Chunks;
|
||||||
using TinyEmbree;
|
using TinyEmbree;
|
||||||
|
@ -312,13 +311,10 @@ class Program
|
||||||
});
|
});
|
||||||
|
|
||||||
// cheeky epsilon
|
// cheeky epsilon
|
||||||
// TODO: Some pixels aren't hitting and I'm not sure why
|
|
||||||
var hit = hitResult && Math.Abs(hitResult.Distance - direction.Length()) < 0.001;
|
var hit = hitResult && Math.Abs(hitResult.Distance - direction.Length()) < 0.001;
|
||||||
if (hit)
|
if (hit)
|
||||||
{
|
{
|
||||||
// Calculate light strength at a given point. As far as I can tell
|
// TODO: This isn't perfectly accurate, but it's pretty fucking close tbh
|
||||||
// this is exact to Dark (I'm a genius??). It's just an inverse distance
|
|
||||||
// falloff with diffuse angle, except we have to scale the length.
|
|
||||||
var dir = light.position - pos;
|
var dir = light.position - pos;
|
||||||
var angle = Vector3.Dot(Vector3.Normalize(dir), plane.Normal);
|
var angle = Vector3.Dot(Vector3.Normalize(dir), plane.Normal);
|
||||||
var len = dir.Length();
|
var len = dir.Length();
|
||||||
|
@ -328,23 +324,9 @@ class Program
|
||||||
{
|
{
|
||||||
strength /= 2;
|
strength /= 2;
|
||||||
}
|
}
|
||||||
|
strength = Math.Min(1.0f, strength);
|
||||||
|
|
||||||
// We need to make sure we don't go over (255, 255, 255).
|
|
||||||
// If we just do Max(color, (255, 255, 255)) then we change
|
|
||||||
// the hue/saturation of coloured lights. Got to make sure we
|
|
||||||
// maintain the colour ratios.
|
|
||||||
var c = light.color * strength;
|
var c = light.color * strength;
|
||||||
var ratio = 0.0f;
|
|
||||||
foreach (var e in new float[] { c.X, c.Y, c.Z })
|
|
||||||
{
|
|
||||||
ratio = Math.Max(ratio, e / 255.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ratio > 1.0f)
|
|
||||||
{
|
|
||||||
c /= ratio;
|
|
||||||
}
|
|
||||||
|
|
||||||
lightmap.AddLight(0, x, y, (byte)c.X, (byte)c.Y, (byte)c.Z);
|
lightmap.AddLight(0, x, y, (byte)c.X, (byte)c.Y, (byte)c.Z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue