From a5571c9f76e1d4d60c527712cc4e9d7dfed94824 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Thu, 26 Dec 2024 13:23:07 +0000 Subject: [PATCH] Fix spotlight direction on models with only a light pos vhot --- KeepersCompound.Lightmapper/Light.cs | 8 ++------ KeepersCompound.Lightmapper/LightMapper.cs | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/KeepersCompound.Lightmapper/Light.cs b/KeepersCompound.Lightmapper/Light.cs index f74dbe8..73cb1ea 100644 --- a/KeepersCompound.Lightmapper/Light.cs +++ b/KeepersCompound.Lightmapper/Light.cs @@ -51,12 +51,8 @@ public class Light Matrix4x4 rotate, Matrix4x4 scale) { - var transform = scale * rotate * translate; - vhotLightPos = Vector3.Transform(vhotLightPos, transform); - vhotLightDir = Vector3.Transform(vhotLightDir, transform); - - Position = Vector3.Transform(Position, rotate) + vhotLightPos; - SpotlightDir = Vector3.Normalize(vhotLightDir - vhotLightPos); + Position = Vector3.Transform(Position, rotate) + Vector3.Transform(vhotLightPos, scale * rotate * translate); + SpotlightDir = Vector3.Normalize(Vector3.Transform(vhotLightDir, scale * rotate)); } public float StrengthAtPoint(Vector3 point, Plane plane) diff --git a/KeepersCompound.Lightmapper/LightMapper.cs b/KeepersCompound.Lightmapper/LightMapper.cs index 6f64240..3862933 100644 --- a/KeepersCompound.Lightmapper/LightMapper.cs +++ b/KeepersCompound.Lightmapper/LightMapper.cs @@ -258,7 +258,7 @@ public class LightMapper } if (model.TryGetVhot(ModelFile.VhotId.LightDirection, out vhot)) { - vhotLightDir = vhot.Position - model.Header.Center; + vhotLightDir = (vhot.Position - model.Header.Center) - vhotLightPos; } } }