Lightning Work and Obsession Stone

Electric Toad Engineering

The formula for the electric field of a line charge, modeling the electric blue ionization of the air with a pink noble gas fringe.

I did look around the asset store before I started to see if there was already a nice lightning effect I could use for our game – but all the ones I saw fell short in some way.  Here’s what I was looking for in a nice effect:

-Should have controllable forkedness

-Should look volumetric, not flat, without any visible knobs or artifacts where the segments are joined together.

-Should be fractal both in the path and the fork tree.

-The bolt should animate smoothly, smoothly tracking targets and flicking around- the bolt should not appear as a sequence of unrelated lightning bolts but a continuously animating one.

And this is the effect I came up with.  I actually ended up using the equation for the electric field of a line charge to draw the lightning segments, which gives you a couple nice things.  First, it looks right.  Second, since electric fields add together linearly, two line charges will join together perfectly and look exactly the same as a single, longer line charge, so you don’t get artifacts.

As far as the forking goes, the physically correct way to do it would have been to create a field in three dimensions defining the exact electric potential at each point based on the shape of the source and target fields.  That might be possible on some future hardware set, but not today, so I approximated the field as being two point charges, one at the source and one at the target, and I added some fractal directional noise to the position at the source and target points.