Skip to content

Add the headlight to the golden_line example - #355

Merged
ASDAlexander77 merged 1 commit into
mainfrom
golden-line-headlight
Dec 5, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
golden-line-headlight

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

  • This PR adds the original's headlight to the golden_line example (train/index.js's SpotLight). After dusk, the engine's lamp throws a pool of light on the ballast and rails ahead. It fades in with the engine's lamps.
  • Placement: the lamp sits 0.12 m ahead of the headlamp. It aims 15 m down the line, 0.35 m low, as the original does (TrainRenderer.headlight).
  • Light model: the same as three r187's: cone cos(0.45) fully feathered, decay 1.75 and a 150 m cutoff.
  • Surfaces: terrain, track and structures, trees, grass and the train take the light with plain physical shading. As in the original:
    • the ground's lift and glow and the grass rim light stay the sun's alone;
    • leaf transmission and blade depth apply to every light.
  • By day: the intensity is 0 and the branch is skipped.

Verification

  • Light values: the lamp's position, target and intensity match the original page at both dusk presets (read from the page's scene over CDP).
  • Fixed-lamp compares: with both lamps pinned to the same seven places (overhead, four at 45°, two grazing), the lit ballast matches the page to about 1 level.
  • Builds: gc, own and rc render byte-identical frames, at the dusk presets and the daytime views.
  • Debug layers: a dusk run with the beam on is clean under Vulkan validation and the D3D12 debug layer.
  • Tests: ctest -R golden_line passes 6/6.

Known

  • Pool brightness: with the original's real lamp, the pool is about 4% dimmer than the page on the trackside dusk view and about 8% dimmer from the cab. The fixed-lamp compares above match, so the cause isn't localised yet.
  • Daytime frames: a few pixels per view change by 1 level against main. This is stable from run to run, so it comes from shader codegen around the new branch.
  • Not in this PR: the original multiplies the running specular sum by the ground's share after every light. With the lights in id order (sun, hemisphere, spot), the sun's specular on ground and ballast gets share², where ours applies it once. This is a daytime difference that predates this PR.
  • Not ported yet: the throttle (W/S), photo mode and the sound.

🤖 Generated with Claude Code

After dusk the engine's headlight (train/index.js's SpotLight) throws its
pool on the line ahead: terrain, track, trees, grass and the train take it
with plain physical shading, as the original's lamps keep it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 3d06f8c into main Dec 5, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the golden-line-headlight branch December 5, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant