Compare commits

..

No commits in common. "42daa8a048d2ef0b6dcc2262f8fb11f977faf8e2" and "1b13d92b9949c67adb886d54e11b0144eac3985c" have entirely different histories.

3 changed files with 13 additions and 19 deletions

View File

@ -37,9 +37,9 @@ public class LmParams : IChunk
public DepthMode ShadowDepth { get; set; }
public bool LightmappedWater { get; set; }
public int LightmapScale { get; set; }
public uint AnimLightCutoff { get; set; }
private int _dataSize;
private uint _unknown;
public void ReadData(BinaryReader reader, DbFile.TableOfContents.Entry entry)
{
@ -53,7 +53,7 @@ public class LmParams : IChunk
LightmappedWater = reader.ReadBoolean();
reader.ReadBytes(3);
LightmapScale = reader.ReadInt32();
AnimLightCutoff = reader.ReadUInt32();
_unknown = reader.ReadUInt32();
}
public void WriteData(BinaryWriter writer)
@ -68,6 +68,6 @@ public class LmParams : IChunk
writer.Write(LightmappedWater);
writer.Write(new byte[3]);
writer.Write(LightmapScale);
writer.Write(AnimLightCutoff);
writer.Write(_unknown);
}
}

View File

@ -51,11 +51,15 @@ public class Light
Matrix4x4 rotate,
Matrix4x4 scale)
{
Position = Vector3.Transform(Position, rotate) + Vector3.Transform(vhotLightPos, scale * rotate * translate);
SpotlightDir = Vector3.Normalize(Vector3.Transform(vhotLightDir, scale * rotate));
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);
}
public float StrengthAtPoint(Vector3 point, Plane plane, uint lightCutoff)
public float StrengthAtPoint(Vector3 point, Plane plane)
{
// Calculate light strength at a given point. As far as I can tell
// this is exact to Dark (I'm a genius??). It's just an inverse distance
@ -72,13 +76,6 @@ public class Light
strength *= (Radius - len) / (Radius - InnerRadius);
}
// Anim lights have a (configurable) minimum light cutoff. This is checked before
// spotlight multipliers are applied so we don't cutoff the spot radius falloff.
if (Anim && strength * Brightness < lightCutoff)
{
return 0f;
}
// This is basically the same as how inner radius works. It just applies
// a linear falloff to 0 between the inner angle and outer angle.
if (Spotlight)

View File

@ -25,7 +25,6 @@ public class LightMapper
public float MultiSamplingCenterWeight;
public bool LightmappedWater;
public SunSettings Sunlight;
public uint AnimLightCutoff;
}
private ResourcePathManager.CampaignResources _campaign;
@ -86,7 +85,6 @@ public class LightMapper
MultiSamplingCenterWeight = lmParams.CenterWeight,
LightmappedWater = lmParams.LightmappedWater,
Sunlight = sunlightSettings,
AnimLightCutoff = lmParams.AnimLightCutoff,
};
Timing.TimeStage("Gather Lights", BuildLightList);
@ -260,7 +258,7 @@ public class LightMapper
}
if (model.TryGetVhot(ModelFile.VhotId.LightDirection, out vhot))
{
vhotLightDir = (vhot.Position - model.Header.Center) - vhotLightPos;
vhotLightDir = vhot.Position - model.Header.Center;
}
}
}
@ -274,7 +272,7 @@ public class LightMapper
{
Position = propAnimLight.Offset,
Color = Utils.HsbToRgb(propLightColor.Hue, propLightColor.Saturation, propAnimLight.MaxBrightness),
Brightness = propAnimLight.MaxBrightness,
Brightness = propAnimLight.Brightness,
InnerRadius = propAnimLight.InnerRadius,
Radius = propAnimLight.Radius,
R2 = propAnimLight.Radius * propAnimLight.Radius,
@ -319,7 +317,6 @@ public class LightMapper
{
Position = light.Position,
Color = Utils.HsbToRgb(propLightColor.Hue, propLightColor.Saturation, propSpotAmb.SpotBrightness),
Brightness = propSpotAmb.SpotBrightness,
InnerRadius = light.InnerRadius,
Radius = light.Radius,
R2 = light.R2,
@ -597,7 +594,7 @@ public class LightMapper
if (TraceRay(light.Position, point))
{
strength += targetWeights[idx] * light.StrengthAtPoint(point, plane, settings.AnimLightCutoff);
strength += targetWeights[idx] * light.StrengthAtPoint(point, plane);
}
}