Lighting: directional sun shadows from the day/night sun angle
DayNight.SunShadow returns a cell offset opposite the sun's east-west position, longest near sunrise/sunset (low sun) and zero at noon/night, tilted slightly south so shadows fall in front of occluders. LightmapBuilder gains a directional shadow pass (MaxShadowCells length cap, SunShadowStrength darkening); LightmapSystem feeds it the current sun shadow each rebuild. Tests cover SunShadow's day-arc behaviour and the builder's directional darkening.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using MrGameEng.Core;
|
||||
using MrGameEng.Lighting;
|
||||
using Xunit;
|
||||
@@ -39,6 +40,25 @@ public class DayNightTests
|
||||
Assert.True(dawn < mid && mid < noon, "daylight should rise from dawn to noon");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SunShadow_ZeroAtNight_PointsWestInMorning_EastInAfternoon_ShortAtNoon()
|
||||
{
|
||||
var (clock, dayNight) = Make(); // 1s = 1 in-game hour
|
||||
|
||||
Assert.Equal(Vector2.Zero, dayNight.SunShadow(8f)); // 00:00 — night, no sun
|
||||
|
||||
clock.Advance(7f); // 07:00 — low morning sun in the east
|
||||
var morning = dayNight.SunShadow(8f);
|
||||
Assert.True(morning.X < 0f, "morning shadow points west");
|
||||
Assert.True(morning.Length() > 2f, "low sun casts a long shadow");
|
||||
|
||||
clock.Advance(5f); // 12:00 — sun overhead
|
||||
Assert.True(dayNight.SunShadow(8f).Length() < 1f, "noon sun casts almost no shadow");
|
||||
|
||||
clock.Advance(5f); // 17:00 — afternoon sun in the west
|
||||
Assert.True(dayNight.SunShadow(8f).X > 0f, "afternoon shadow points east");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Ambient_DarkerAtNightThanAtNoon()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user