Procedural Lightning Textures And A Chain Lightning Attack
Creating a C++ algorithm to procedurally generate lightning textures
As I was playing a few old Warcraft III custom maps with some friends, I was reminded of one of the more iconic attacks in the game: a chain lightning attack. So obviously I wanted to add one to my game as well. But how to create an animated lightning texture? I might be able to create one in Photoshop or Blender, but it would take me a really long time and a lot of manual work to get a decent result. And then what if I wanted to change the color or another detail, it would take a lot of work again to change it. But luckily there is another solution for me: write a small C++ program that procedurally generates an almost infinite amount of different lightning textures. Sure, it might take a bit longer to create the program than it would take to create a texture in photoshop, but once it is finished I can create new textures in a matter of minutes of even seconds.
Procedural Lightning Textures
Starting the project the first thing I worked on was to draw a simple straight line in a lightning style. After trying a few different versions I ended up with three lines of varying size, opacity and hardness on top of each other. First there is a soft and almost transparent blue shine, then comes a smaller and more opaque cyan light and the center is completely white, because even colored light sources appear white when they are very bright and only the shine…