# Simplex Noise Lightning example

Here is an example of SimplexNoise used to generate Lightning.
Perlin.blend (476 KB)
Here is the source for the SimplexNoise algorithm

That is very nice and it can make for interesting Effects (not only Lightings) – though why does it tend to be, well, »bigger« towards one End? (For I would expect the Scale to be distributed relatively even.) I guess it has some Sort of a Fade-In yet little Fade-Out?

The algorithm is weighted to become larger influenced towards the end. To remove this, remove the “i *” from line 32 and add
self.points.insert(0, self.a) in the init constructor

Very nice!

Wow, this is really cool! thanks for share!

Plus, i made it so it always hits the end point. To be honest, iut isn’t quite lightning if it does that so feel free to remove the bit that says points.append(x) in the init part

nice!
a little tweak for spherical falloff so it also fades out:

``````...(math.sin(i * 1.0 / self.steps*math.pi))...
``````

http://dl.dropbox.com/u/11542084/Perlin_lighting.blend

Ô, and exchanging the 1 at the Ende of this Line:
next_particle = points.index(particle) + 1
… gives a wonderful (abstract and very lightning-unlike) Effect! :3

Please someone post a screenshot, i cant reach my pc,i have to wait untill tomorrow to see it!

ok blendingbge

Nice, looks interesting! thanks agoose77 (and martinsh)

Fantastique

also, you don’t have to use drawline - if you use the mesh api, you can set the position of vertices, though i didn’t have much luck last night.

Haha! So cool!

That would be pretty cool: Mixing/Subtracting/etc. one Perlin with another one randomly offset and using the Result for Vertex Manipulation to get a randomly created Terrain.

Well, such a technique is used for random terrain, but it becomes much simpler. A texture output from a perlin algorithm (or in this case simplex noise - a modernised version by same author) can be sampled for height or density values on top of a height map. This is how MineCraft does it.

That’s what I guessed – good to actually know it, thanks.

Hahaha ! That is so cool !

Mesh APi.blend (516 KB)

A much promised update.
This one deforms some mesh vertices; grouping them by the y positions. I had some problems with the mesh api, but i figured out a work around. I need to set the vertices to align to the direction of the bolt, so when the target is moved, the bolt aligns to it. Set “debug” to False or 0 in the text window to hide the green line.

Update; Fixes the alignment.

Mesh APi.blend (470 KB)