Skip to main content

Module lightning

Module lightning 

Source
Expand description

Lightning generation using the Dielectric Breakdown Model (DBM). Solves Laplace’s equation to determine growth direction, with branching and return stroke animation.

Structs§

DielectricBreakdown
Grid for dielectric breakdown simulation.
LightningBolt
A lightning bolt represented as line segments with brightness.
LightningRenderer
Renderer for lightning bolts.

Functions§

add_branches
Add branches to an existing bolt. Each segment has a probability of spawning a short branch.
animate_bolt
Animate a bolt: leader progresses downward, then return stroke brightens. Returns segments with animated brightness at the given time.
bolt_with_return_stroke
Apply a return stroke effect: brighten the main channel.
generate_bolt
Generate a lightning bolt from start to end using the Dielectric Breakdown Model.
laplace_solve
Solve Laplace’s equation ∇²φ = 0 on a grid using Jacobi/SOR iteration. boundary_mask[i] = true means the cell is a fixed boundary.
stepped_leader
Generate a stepped leader: a series of step-wise advances with random jitter.