fix(G.3 A7): dungeon lighting — select 8 NEAREST lights, not viewer-in-range (#133)
The active-light selection dropped any point light whose range didn't reach the VIEWER (DistSq > Range^2*slack -> skip). Retail's D3D-style fixed pipeline picks the 8 NEAREST lights and applies the hard range cutoff PER SURFACE in the shader (mesh_modern.frag: if (d < range)). The viewer-range candidacy filter suppressed a torch whenever the player stood outside its range, so a dungeon room with 2227 registered torches lit only the ~1 the player was standing in (activeLights ~= 1, rest of the room at flat 0.2 ambient = the "lighting off" report). Drop the filter; take the nearest 8 regardless of viewer range. Removed the now-unused RangeSlack const; updated the two tests that codified the old filter. Core lighting suite green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d6fb788c96
commit
a80061b0c2
2 changed files with 23 additions and 8 deletions
|
|
@ -60,21 +60,29 @@ public sealed class LightManagerTests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void Tick_DropsLightsOutsideRangeWithSlack()
|
||||
public void Tick_SelectsByDistance_RegardlessOfViewerRange()
|
||||
{
|
||||
// Retail D3D-style: candidacy is distance-only (the nearest 8). A torch
|
||||
// lights its OWN surfaces — the shader applies the hard `d < range` cutoff
|
||||
// PER FRAGMENT (mesh_modern.frag) — so a torch the VIEWER is standing
|
||||
// outside the range of is still selected; it lights the wall it sits on.
|
||||
// Replaces the old viewer-range candidacy filter that suppressed it, which
|
||||
// left dungeon rooms (2227 registered torches) at activeLights≈1 / flat 0.2
|
||||
// ambient — the "dungeon lighting off" report (#133 A7).
|
||||
var mgr = new LightManager();
|
||||
mgr.Register(MakePoint(new Vector3(20, 0, 0), range: 5f)); // far outside its own range
|
||||
mgr.Register(MakePoint(new Vector3(20, 0, 0), range: 5f)); // viewer outside the torch's range
|
||||
|
||||
mgr.Tick(viewerWorldPos: Vector3.Zero);
|
||||
|
||||
Assert.Equal(0, mgr.ActiveCount);
|
||||
Assert.Equal(1, mgr.ActiveCount); // selected by distance; the shader culls per-surface
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Tick_IncludesLightsNearRangeEdge_WithSlack()
|
||||
public void Tick_IncludesNearbyLight()
|
||||
{
|
||||
var mgr = new LightManager();
|
||||
// Light at distance 5.0, range 5.0: distSq=25, rangeSq*1.1^2 = 25*1.21 = 30.25 → included.
|
||||
// A nearby point light is selected (distance-only candidacy; the shader
|
||||
// applies the per-fragment range cutoff).
|
||||
mgr.Register(MakePoint(new Vector3(5, 0, 0), range: 5f));
|
||||
|
||||
mgr.Tick(viewerWorldPos: Vector3.Zero);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue