Generating Seamless Plasma Clouds

Hamburg (Germany), the 10nd. June 1997. Written by Nils Pipenbrinck aka Submissive/Cubic & $eeN

Introduction

I suggest that you already know what a plasma is.. If not take a look at the pictures. This tutorial deals with the algorithms need to make seamless plasmas. Seamless images have one good property: the left and right side, and the upper and lower side fit seamless. That's a very important property in 3d graphics because you can map them onto objects without having to worry about the texture edges. I know, that this is pretty old stuff, but I've been asked to explain how it works, so I spend my free day writing some stuff about it.

The recrusive subdivision

Plasmas are generated with a recrusive algorithm. I drawed a picture which shows you the first 4 generation steps (from top left to bottom right).

plasma pics

We will only generate images where the size is a power of two.. To keep it easy I'll suggest that you start with a 256x256 image. In the first step you draw 4 random dots onto the image. The pixels should bound the upper left rectangle of the texture. Now we want to calculate new pixels. We put the pixels directly between the previous calculated. (green dots). There are two cases we should handle:

In the right and lower half of the image you have to do some special processing to keep the image seamless. Since you don't have any pixels at the bottom and right line you use the values from the left and top line. This is a little bit tricky to code, but gives good results.

Controlling The Roughness

How many random should you add to the values? This depends on the step of recrusion you're working in.. In the first step, where you directly put the 4 seed pixels you can use a range from 0 to 255. In the second step you have to scale these values down.. Otherwise your image will more look like a detuned television rather than a smooth plasma. So, it is a good idea to use randoms between 0 to 127 in the second step, 0 to 63 in the third and so on. However, this choice is just the way I do it.. you might want to use a logarithmic scale or do other fancy stuff. Just make sure that the amount of random decreases with the order of subdivision.

Implementation Notes

I've not implemented a C code for this algorithm. Rather I'll over you to download the same code I used in the marble texture tutorial. However, this code was optimized for size and you will have problems to extract the algorithm. It also doesn't work recrusive but subdivides in a loop. You can download it here

If you have any comments, notes or found any bugs please contact me. I'll continue writing tutorials as long as I get some feedback and know that writing this stuff isn't just wasted time. As always you might want to contact me.


© by submissive Valid XHTML 1.1!