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.Lighting;
|
||||
using Xunit;
|
||||
|
||||
@@ -54,6 +55,29 @@ public class LightmapBuilderTests
|
||||
Assert.Equal(0f, light[5], 5); // за препятствием — тень
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SunShadow_DarkensCellsInTheShadowDirection_FadingFromTheCaster()
|
||||
{
|
||||
var occ = new bool[7];
|
||||
occ[3] = true; // occluder in the middle
|
||||
var light = new float[7];
|
||||
LightmapBuilder.Build(
|
||||
light,
|
||||
7,
|
||||
1,
|
||||
1f,
|
||||
occ,
|
||||
[],
|
||||
sunShadow: new Vector2(3f, 0f),
|
||||
sunShadowStrength: 0.6f
|
||||
);
|
||||
|
||||
Assert.Equal(1f, light[2], 5); // toward the sun (opposite the shadow) — unshadowed
|
||||
Assert.Equal(LightmapBuilder.OccluderShade, light[3], 5); // occluder cell stays self-shaded
|
||||
Assert.True(light[4] < 1f); // in shadow
|
||||
Assert.True(light[4] < light[6]); // darker near the caster, fading along the shadow
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Values_StayWithinUnitRange()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user