Commit Graph

2 Commits

Author SHA1 Message Date
troytt 536a712816 fix(lighting): resolve wall black-hole self-occlusion, clear-color seam, torch emitters, and vertical UV shift
- LightGrid Radial Ray-Marching (src/game/engine/light-grid.ts):
  * Only count line-of-sight blockers (COLLIDE_VISIBLE | COLLIDE_DOOR) in updateObstacles
    so floor rocks, stairs, and walkable blockers do not create dark spots.
  * Trace radial rays from emitter to target cell (1 <= s < steps) so the emitter's
    own cell is never self-occluded when hugging a wall, wall front-faces receive full
    illumination, and authentic shadows are cast behind walls.

- Ground-Plane Vertical Elevation Compensation (src/render/renderer.ts):
  * Encode vertical sprite elevation (elevationY) in top quad vertices while strictly
    preserving the 10-float vertex stride (FLOATS_PER_VERTEX = 10) so upright walls,
    objects, characters, and monsters sample the lightmap at their ground footprint.

- Scene Lighting & Clear Color Parity (src/scene/act-scene.ts):
  * Set canvas clear color to pure pitch black [0, 0, 0] when lighting is enabled,
    eliminating #08080a diamond void bands around cave boundaries.
  * Scale light radii by SUB_TILES_PER_LIGHT_CELL (8 sub-tiles per cell: player torch 88).
  * Register Objects.txt Lit0..2 emitters (TO, T1, T2, FB, B2, WP, SH, etc.) for cave torches.
  * Map all spell skillIds (including Glacial Spike '55') for dynamic projectile lighting.
2026-09-24 09:14:35 +00:00
troytt b51d839d8c feat(lighting): implement authentic Diablo II v1.13c Glide dynamic lighting system
- P0 Data Contract Fixes:
  * Fix missile additive blending to use authentic 1.13c Missiles.txt trans === 1
  * Strip developmental || 255 fallback from color channels to preserve authentic 0 values
  * Add full 136-level lighting metadata from Levels.txt in levels-meta.ts
  * Wire MonStats2 and Overlay lighting in data-registry.ts

- P1 Reverse Engineering & Math Specification:
  * Reverse engineer D2Client.dll (dLightMap.c) and D2Common.dll (D2Environment.cpp)
  * Implement Alpha-Max-Plus-Beta-Min fast Euclidean distance approximation
  * Implement 16.16 fixed-point linear falloff and obstacle attenuation
  * Implement intensity-weighted color blending with reciprocal lookup table

- P1 Core Modules:
  * LightGrid: 48x48 cell dynamic lightmap with sub-tile bilinear interpolation and RGBA8 export
  * Environment: 25Hz day/night clock, outdoor solar sine curve, Act IV targets, indoor static levels

- P1 Shader & Renderer Integration:
  * Maintain strict 10-float vertex stride (FLOATS_PER_VERTEX = 10)
  * Transform screen coordinates to sub-tiles in vertex shader for v_lightUv
  * Glide diffuse modulation in fragment shader with additive blend bypass
  * Lazy 48x48 lightmap texture allocation ensuring zero overhead for unlit contexts
  * Single-pass draw call batching maintained (drawCalls === 1)

- P1 Scene Integration & Verification:
  * Wire LightGrid and Environment into act-scene.ts
  * Add player torch with subtle flicker, missile lights, explosion flashes, and additive objects
  * Unshaded minimap overlay by resetting lighting prior to minimap.draw
  * Add comprehensive test suites: data-contract-lighting, light-grid, scene-lighting
2026-09-24 08:02:29 +00:00