LightNing effects

Started by
5 comments, last by KalvinB 20 years, 11 months ago
Currently I have a lightning graphic that is stretched over a quarter to half second period to simulate a lightning strike and it looks okay. However, I was wondering if anyone has any better ways to get the effect with older graphics cards. Ben
Advertisement
I have no idea why your method should not work with old cards (are you using a vertex program for the stretch??) but the oldest trick in the book is just to flash the screen pure white for a tenth of a second or so, accompanied with a rolling thunder crack

Sander Maréchal
[Lone Wolves GD][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

I made such an effect in one of the Nehe contest, a year ago. You can get the source here (look for Lightning.h and Lightning.cpp):

http://nehe.gamedev.net/data/contests/2002_lotr/source/flavien_brebion.zip

As far as i remember, i created a tree given some probabilities for branching, and for each segment, created a small billboard-quad with a lightning texture. You can also get the demo binary on Nehe''s LOTR 2002 site.

Y.
a particle system for lighting might look pretty cool and will work with older cards. Maybe you spawn a particle at the start of the lighting (in the sky) and each tick it spawns a few new partices towards the ground (or you could do some detection of highest geometry that is nearby), recrusively do this for each tick (using the leaf nodes) until there are no more leaf nodes. (nodes stop spawning when they hit the ground). You could then use some sort of blending and gl_lines to draw the ligthing (maybe give nodes/edges an age value so when they get older maybe they should become brighter or more saturated)
Maybe you could define a special type of particle that will branch after it dies. When you initialize the particle, give it a random value for Energy, say between 1 and 5 frames, and give it a random downward Velocity without Acceleration. Update it every frame and decrement the Energy. When Energy hits zero, kill the particle, but first create and initialize a random number of new particles, say between 1 and 4, and set their Position to the last Position of the dead particle, with random downward Velocity. Continue the process until your Particle System decides it has created a max number of particles, and then kill the whole system. You could simply draw a big white dot for the particle, and I would think that the process would happen so fast that it would look like a line. If it doesn''t you could store OldPosition along with Position, maybe even a bunch of OldPositons[], and connect the string of points into a bright white/yellow line.

This would cause a cool branching effect. Each bolt of lighting would be completely unique from the rest as well. I think it would look really cool. You could do a lot with the lines, as well, for example instead of using a line primative stretch a bitmap of a single bolt to fit between the two points, and rotate it to fit. Then you could get the lines to have that genuine corona around them, instead of just straight lines.

The other way I could think of would be to store a couple of different bitmaps of lighting, with transparent backgrounds, and billboard them up in the sky at random positions. You would have to make sure that every bolt occurred plenty far away from the camera, though, because if it happened too close it would probably produce some really funky results. Imagine looking up in the sky and seeing a bolt seer across the sky, instead of down.

I can imagine a world without hate, a world without fear, a world without war. And I can imagine us attacking that world, because they would never expect it. -Jack Handy
last time i did a lightning effect, i just used a plus shaped model (actually, possibly a series of them depending on how long the bolt was), and then perturbed the verts dynamically to get the zig-zag effect, pertubing all the verts on a z-facing plane equally. It ended up looking pretty good.

As long as your model does not have too many polys, and you do not have too many bolts on screen at the same time, this is cheap.
take a line at the start...and move it toward the ground, subdividing and adding noise the whole way down...(best for a particle engine) then have it flash away real quick-like. Looks really good in slow-mo
I love me and you love you.

This topic is closed to new replies.

Advertisement