s_lightningRandom
global · gx
- Address
0xcf57b0· 8 bytes, up to0xcf57b7- Type
uint32_t[2]- Meaning
- Holds the random generator state the lightning bolts draw jitter from, seeded with 0 at start-up
- Confidence
- verified, proof one
- Finding
- gx/lightning#bolt-shape
Finding: Bolt shape in gx: lightning
0x7af6d0(points) fills points with the bolt's centre line. With d = end - start, n = ftol(|d| / segment + 2.0) and s = |d| * jitter ([bolt+0x24]), it makes n + 1 points: the first is start, the last is end, and point i from 1 to n - 1 is (start + (d * i) * (1 / n)) + (r1, r2, r3) * s, each r drawn from 0x4531e0 on the file's generator: the low 23 bits of the draw ORed into 0x3f800000 give a float in [1, 2), which becomes f - 2.0 when the draw is non-negative and 2.0 - f when it is negative. Every bolt shares the generator, which starts from seed 0.
The derivation is in the doc.