RGLight: Rob Gougher's Freeware Lightning Generator

RGLight is a LIGHTWAVE 3D plugin for Generating Lightning Strike objects.
Once generated, these objects can be manipulated, surfaced and animated as any other.

A frame from the "Lanaburg in Storm" Scene (included with Lightwave 3D) with RGLight generated lightning.
Click below to download the "Lanaburg In Storm" animation with RGLight Lightning.
 

Loosely based on the Lightning Model section from "Visual Simulation of Lightning" by Reed and Wyvill (Siggraph 94), RGLight's generation algorithm has several tunable parameters including distinct seed values for object generation and also point perturbation. (Perturbation is useful for jittering an object in such a way that points further from the root are more jittered then those which are close - morphing between 2 or more of these perturbed versions of the same object tends to resemble a tree blowing in the wind.)


Plugin Procurement:

Wow Rob, that really kicks some booty! How can I get my own copy to unleash the forces of nature in my own electrifying animations?
Why, I'm so glad you asked fine sir or ma'am! Just click below, download the ZIP file (INTEL ONLY for now), uncompress that puppy into a local directory on your machine and follow the install instructions in the next section.

RGLight.zip


Plugin Installation:

Place contents of RGLight distribution plugin directory (RGLight.p and RGLightB.p) in your Plugins/Modeler directory.
Enter Modeler.
Make sure the Objects tab is selected.
Select the Prefs pulldown (left edge of the screen).
Select Add Plugin.
Make sure you are looking in Plugins\Modeler.
Double Click the file "RGLight.p".

You should see the message:
1 server(s) found in plug-in file "<NewTek Directory\PLUGINS\MODELER\RGLight.p"

Select the Prefs pulldown (left edge of the screen).
Select Add Plugin.
Make sure you are looking in Plugins\Modeler.
Double Click the file "RGLightB.p".

You should see the message:
1 server(s) found in plug-in file "<NewTek Directory\PLUGINS\MODELER\RGLightB.p"


RGLight Usage:

Once installed, RGLight is called from the Tools Panel under Custom Selector.

RGLight User Interface

Left is a screenshot of the user interface for RGLight. Each field is explained below:

Number of Segments: This is the total number of line polygons of which the lightning strike object is to be composed. Since the generation algorithm is recursive, the number of segments represents the simulation's termination point, regardless of recursion depth at the time the target number of segments has been reached. One notable effect of this dynamic is that segments near the top of the generated object are often branches themselves. Since the algorithm generates segments before continuing the current branch, the first few segments of a strike object will not have branches. It is for this reason that most objects, particularly those with a high branch probability, will not have branches close to the root.
RGLight interprets entering 0 for this field as a Cancel.

Random Number Seed: This number seeds the random number generator for the strike generation process. For a given set of constant parameters, a given seed value will always yield the same object.

The length of a segment is determined by randomly selecting a length between the following two values:

Longest Segment (Meters): This is the longest segment possible in the strike object to be generated. The length is measured in Meters.

Shortest Segment (Meters): This is the shortest segment possible in the strike object to be generated. The length is measured in Meters.

A segment's directional change (IE, how much the lightning thread bends at a point), relative to its parent segment is determined by the following three parameters:

Mean Directional Change (Degrees): This is the mean angle between a parent and its child segment. This is also referred to as angle phi between the vertical axis (the parent) and another vector (the child). The unit of measurement is degrees.

Standard Deviation of Directional Change (Degrees): This is the standard deviation of the Directional change. The directional change is drawn from a Gaussian (normal) distribution whose standard deviation is defined to be this value. The tips of the bell curve touch the value (Mean + 3*Std.Dev.) and one side and (Mean - 3*Std.Dev.) on the other.

Spin Type: The directional change phi between segments always takes place such that the endpoint of the child is closest to -Y. An additional spin, around the parent, takes place. This spin may be random or gaussian. The gaussian option insures that most segments will be positioned such that their endpoints are as close as possible to -Y.

Each point in the strike object may have one or two child segments. A point which two segments is a branching point. Branching is controlled by the following two parameters:

Branch Probability: This is the probability that a given point will be the root of a new branch. Legal values are from 0.0 to 1.0. Entering 0 will result in a branchless object. Branch Length Factor: The length of a branch is computed before it is generated. The length will be the a function of the number of segments times this factor. Many branches are never fully generated because the generator terminates when the total number of branches reaches the value entered for Number of Segments.

In case the similarity produced by using various seeds for a given parameter sets does not produce sufficiently similar objects, one can instruct the generator to perturb the individual points of an object. If several objects are created this way, and morphed using MTSE, the effect is sometimes like that of a tree blowing in the wind. Strike perturbation is controlled by the following two values:

Perturbation Seed: This value seeds the random number generator used to perturb object points.

Perturbation Factor: This value is the maximum number of meters you wish a point to deviate from its generation point. The actual perturbation is selected randomly between zero and this value for each axis.

Save Creation File: If this box is checked, the use can enter the location and name of a file which will contain the creation data for a given strike object. For each timestamp in the generation process, the file lists the point created, its parent point (in parenthesis), and the child points to which it is parent.


Sample Output:

The default parameters work well with a segment count of 150.
Below is an image of Modeler with the resulting object:
Segments = 150, all others default

Another good one to try is:
Segments = 150
Seed = 1245
Below is an image of Modeler with the resulting object:
Segments = 150, Seed = 1245, all others default

If you use a lot of points, things start to look very tree-like. Try:
Segments = 1500
Seed = 1245
Branch Probability = .001
Below is an image of Modeler with the resulting object:
Segments = 1500, Seed = 1245, all others default


Error Messages:

Number of Segments must be NonNegative: The acceptable range for number of segments is from 0 to 65535. Entering 0 will cause RGLight to exit.

Longest Segment must be greater than 0: Segments must be of positive length. Additionally, the Longest Segment must be of greater length than the shortest segment. Since the shortest possible value for shortest segment is 0, the shortest possible value for largest segment must be greater than 0. Change the Longest Segment to a value greater than that of the shortest segment.

Shortest Segment must be NonNegative: The shortest possible length for a segment is 0. (I.E. no negative lengths). Change the shortest segment to 0 or greater.

Longest Segment must be greater than Shortest Segment: In order for segment lengths to be positive, this condition must be met. Make sure that the longest segment is greater than the shortest segment.

Standard Deviation must be positive: The standard deviation is an absolute quantity. Change the standard deviation to a value of 0 or greater.

Branching Probability must be between 0 and 1: Use a value between 0 and 1 where 0 is never and 1 is always.

Branching Length Factor must be greater than zero: The Branching Length Factor is the factor by which a randomly selected length is multiplied to arrive at the length of a branch segment. Since segments may not be of negative length, this factor may only be 0 or positive. Change the Branching Length Factor to a nonnegative value.


Limitations:

Your Primary Limitation is memory. RGLight can generate an object with 80000 segments with 32 Megs of RAM, quite a bit of swap space and a lot of patience.

For recommended use (creation of objects with <1000 segments), most systems should be adequate.


RGLightBoltSelect Usage:

When I wrote RGLight, I found that surfacing strike objects can be a royal pain.
To ease this a bit, I wrote RGLightBoltSelect.

Just Select a SINGLE POLYGON at the bottom of a lightning strike created with RGLight.
Then, activate the plug-in by selecting RGLightBoltSelect from the Custom pulldown on the Tools panel.
The plugin should select all polys up to the root.
You can then make those polygons into a unique surface.
That's how I made certain threads of the lightning bolt different colors than others in the example image and animation.
RGLightBoltSelect is a bit of a hack, so be very careful about using it in wierd ways.


Please send any comments or suggestions to:

Robert A. Gougher

Rob Gougher (rglight@robgougher.com)

Last Updated: