Help with Lightning Theory

BlitzMax Forums/BlitzMax Beginners Area/Help with Lightning Theory

SillyPutty(Posted 2005) [#1]
Hi all,

Does anyone here know how to create realistisc lightning effects ?

I would assume you would have a variance term like -5 to 5 on the x axis, and shoot random length lines (y) downwards using random numbers between -5 and 5 for x coords ?

This is assuming the lightning is shooting downwards.


Drago(Posted 2005) [#2]
err, can you explain in more depth what you want, ie 2d or 3D and the effect you are trying to get?


SillyPutty(Posted 2005) [#3]
a 2d effect, using blitzgl. A Lightning effect, where the lightning branches off etc...

Does this make sense ?


Sledge(Posted 2005) [#4]

This is assuming the lightning is shooting downwards.


If you want it realistic then remember that the first visible element of a lightning strike travels from the ground upwards a distance.

Anyway, one thing to consider is what counts as "realistic" in the context of a computer program - if it's an effect in a game you want then you really have to ask if procedurally generating and rendering the downwards path of a strike is going to be any more worthwhile than, say, just alpha'ing in a picture of one. What's the context? Because a player engrossed in a game unlikely to appreciate anything beyond a certain level of realism.


ImaginaryHuman(Posted 2005) [#5]
Also lightning tends not to always move around a whole lot. I mean, sometimes you see it forming extra branches as it moves accross a cloud or something but usually it's pretty static. So as Sledge said, you might get away with just using an image of some lightning or drawing it in pieces, or you could individually rotate/animate each chunk of the image so that it sort of moves about.

For real electricity you'd need some way of modelling the way that arcs are formed and move around. You can simply use some random numbers as a basic technique, maybe draw lines even. I remember the lightning in Project X (Amiga game) was just a bunch of lines branching out down the screen but accompanied by an audio sound of lightning was adequate because it was so brief. It's not as if you're going to be looking at it for a long time, right?

I would maybe suggest having a `base` structure for the general shape of the lighning bolt, and then add or subtract from that a random amount which can go left or right or up or down, drawing lines between to fill in the gaps, because lightning can arc upward as well. This would ensure you'd eventually get to the bottom of the screen even though there are temporary diversions.


SillyPutty(Posted 2005) [#6]
Thanks guys, this really helps me.

I see the choices before me now.

Thinking about it, I am sure they use textures in most games for lightning effects.

The effect I ultimately would like to create is as the one in Knights of The Old Republic, if you are on the dark side, and you can "shock" opponents.

I would think that is an image ? Or an image textured onto quads which are long rectangles.


Amon_old(Posted 2005) [#7]
I would just use an image and do some kind of a bloom effect. It should be possible in BlitzMax using Blitzgl the problem is I wouldnt know how to do it.