Lighting
Class :Lighting.h
Made By : Steve
Uses : GL_LINES
Complexity : MEDIUM
This effect is used to simulate lightning bolts.
The lightning effect allows a user to input box coordinates and values which randomize the creation of the bolts. The bolts are created using a highly random algorithm created by us, which produces some very impressive results.
The lightning follows the box model, and is initialized as follows :
Lightning l = new Lightning (vector3f coords, vector3f radius, int time, float probability);
The constructor asks the user to supply coordinates and a radius, using the box model, a time and a probability. The time is a value in frames between bolts, and the probability is a chance of branching for each segment. Lightning is drawn with :
l -> drawLightning();
The probability value works best with very small values. The lower the probability, the less branches there will be. Other variables to edit include :
- Energy : Any positive integer will do. Energy is passed down for each segment, one per segment. High energies will result in all branches reaching the ground, while lower energies will have each segment ending potentially earlier.
- Fade : The speed should be between 0 and 1. This is the fade speed per frame.
- Height : This is an integer value representing the height in units of each segment.
Thoughts : This effect is my personal favorite. The algorithm is entirely original, and the results are fantastic in my opinion. The only thing to make it more realistic would be to apply a glow through pixel shaders.