NFSU.cc / RE Atlas / Rendering & Shaders

Night lighting in Speed.exe

Rendering & Shaders 78 verified Speed.exe addresses Speed.exe (2003, x86)

Sources: Ghidra headless (tools/ghidra/gpar.sh on build/ghidra/proj), Hopper batches build/hopper/{hlproj,carlight,worldflare}.txt, game/fx/*.efx (XOR 0xAA text HLSL). Checked at runtime with RN_WATCH/RN_POKE (native and Chrome).

Graphics options (table 0x700ef0: name, flag, 12 bytes each)

OptionFlagRead byNote
HEADLIGHTS0x700e800x408f00 (adds view 7), 0x40c910 (material remap), 0x409580projected headlight
CARLIGHTING0x700e84nobodydead option
ROADREFLECTION0x700e900x40c910, 0x408f00picks the *reflect techniques
MOTIONBLUR0x700e980x409580, 0x40b3f0, 0x40cb80
LIGHTSTREAKS0x700e9c0x409580, 0x40b3f0, 0x40cb80flare buffer 0x71abb0 (PATCH 0x409bdb)
LIGHTGLOW0x700ea00x409580, 0x570c70 (racers), 0x570d00 (traffic)car light flares
DEPTHOFFIELD0x700eacnobodydead option

Presets: 0x410a00 scores the machine (0x41eff0, score 0x701088; < 0.3 / 0.6 / 0.9 = preset 0 / 1 / 2) and 0x410ce0 clamps each flag to the cap table 0x701040. Preset 1 sets HEADLIGHTS, MOTIONBLUR, LIGHTSTREAKS = 0. At real clock our CPU scores 0.92 (preset 3, all on). RN_TURBO=4 lowers the score: turbo runs have no headlight.

Projected headlight (one, the player's)

worldreflect -> worldheadlightreflect (0x706798).

per-effect setup callbacks 0x702420 + 4*i (0x40e740 worldheadlight, 0x40e900 worldheadlightreflect).

(0x1c) = (0.8, 0.8, 0.9, 0) from 0x7010ac..0x7010b4 (constant, never written).

texels 0..32 = 0, 33..47 = 255, 48..63 = 239..0: light from ~3 m, full to ~50 m, gone at ~100 m.

Car light flares (0x56d8d0, every racer and up to 99 traffic cars, gate LIGHTGLOW)

0xd09091c6, LEFT/RIGHT/CENTRE_BRAKELIGHT 0x31a66786 / 0xbf700a79 / 0xa2a2fc7c.

16 * [car+0x1e4] when > 0.05 (0x6b5dac, 0x6b5db0); everything clamps to 1.0, so a brake goes 0.7 -> 1.0 only. Debug forces: 0x7345e4 (head +1), 0x7345e8 (tail +1). Broken lights (damage state 0xd/0xe) skip a group.

textures from 0x6f4150 (2 per type); then 0x5443f0 draws the quad.

Track lamps (0x544f30 from 0x409580 / 0x409b70)

Per visible track section (0x446fd0) a list of flare records, each to 0x544e90 / 0x5447c0 as above.

Speed blur (0x40cd40, from 0x409580)

Speed = |v| of [0x740500]+0x1e0. t = clamp((speed - [0x702a38]) / ([0x702a3c] - [0x702a38])) + 1.1*[0x73641c], capped by [0x702a40]; [0x73641c] ramps toward [0x73654c] (nitrous) by 0x702a48 / 0x702a4c per frame. The previous frame (0x71ab9c, 0x71aba0) is drawn back zoomed toward the centre (offset x [0x702a44] streak) with that alpha: a zoom feedback blur. web/tune.js presets write 0x702a38..0x702a44.

Bridge host/lights.c (Block 7 parts 1-2, RN_LIGHTS=0 = shipped; F4 Original sets it)

REA (Ghidra 12.1.4, Speed.exe sha256 c0fad450...) checked each target before the patch: 0x6b5da0 has one reader (0x56d9d7, ev_7cff0ca1), 0x7010ac one (0x4102ad in 0x4100a0, ev_0ee4a966), the cave 0x43a7e4 no reference and is CC padding after the jump table at 0x43a7d8 (ev_6a127f7b, ev_a6bf0c32).

(full light to ~73 m). The player's headlight is the 2003 one again; 60 fps were steady in that session (p50 16.7 ms), so the slowness was the look: a long bright beam shows the road far ahead instead of pulling it out of the dark. Chrome: RN_WATCH=6b5da0 reads 0.7 with RN_LIGHTS=0 and 0.35 by default.

Part 3: projected headlights for rivals and traffic (bridge host/lights.c + host/sm1.c SM1_HL_*, web only)

REA (Ghidra 12.1.4) + runtime (RN_LIGHTSLOG, native and Chrome):

VP = [[0x740760]]+0x80, S = T(0.5, 0.5, 0) (0x6cc7dc = 0.5, ev_f9491a5a). The block [0x740760] (0x78b340 at run time): +0 View, +0x40 Proj (near 1, far 100, y flipped), +0x80 View x Proj. 0x40bc10 = rigid inverse T(-p) R^T (ev_575f101e).

(0x740760, enable 0x740768, set by 0x408410 from HEADLIGHTS 0x7364a4; ev_cf65f4e9).

constant over a whole race. So VP_k = W_k^-1 W_p VP; the GPU takes tp_k = tp x M_k, M_k = (VP S)^-1 W_k^-1 W_p VP S.

matrix +0x90 rows 0..2 + position +0x50 (+0x4e0 / +0x520 when bit (1 << view) of +0x530; always 0 seen). The racer list 0x73d6d8 (0x570c70) is empty in a race; it holds the front-end cars. ~17 cars: 4 racers + traffic.

(t1 x t2 x c0 + v0, x t0 x2); worldheadlightreflect vs 102e066d / ps 9bb3f7c7 (+ t3 reflection). Clip ramp 64x1 (0x40e560 CreateTexture 64, 1). t4..t7 are free: 4 more projectors from VS c16..c31.

1 - (1 - Lp) prod(1 - g h_k), g = SM1_HL_GAIN 0.4, each ramp read at 1.5 x depth (SM1_HL_REACH). A/B in Chrome at the start of race 1001: rival cones on the road, no burn.