Hi there!
Plasma is a very simple effect to perform. The only thing you need is a couple of sine and cosine functions to generate 2D waves, that when using a upcounting angle will seem to move and even makes the different waves combine at some points. A simple way to create a two-dimensional plasma-map is as follows (C++ pseudo-code):
counter=0;
const ZOOMFACTOR=10;
for(x=0;x<256;x++)
for(y=0;y<256;y++)
{
PlasmaColor[counter]=
30sin(x/(256/2/PI)/ZOOMFACTOR1.283f)+
20cos(y/(256/2/PI)/ZOOMFACTOR2.085f)+
30sin((x+y)/(256/2/PI)/ZOOMFACTOR.031f)
}
Now you have calculated a plasma-map. Oh yeah, those strange float values, those are just some values i thought of while writing this In fact, the whole routine was just made up by me, while writing this )
To make this plasma move (very kewl effect),
just add an upcounting angle to x and y, while calculating the waves, like:
LOOP:
col=sin((x+angle)/(256/2/PI));
angle++;
WHILE NOT DONE, GOTO LOOP
Of course the 256/2/PI should be a precalculated value and you could even generate a sine and cosine list and use a displacement value in the list to make the plasma move, like this:
for(i=0;i<256;i++)
{
sinetable[i]=SINE_CALCULATION;
cosinetable[i]=COSINE_CALCULATION;
}
for(y=0;y<256;y++)
for(x=0;x<256;x++)
{
PlasmaCol[i]=
sinetable[(x+displacement)%256]+
cosinetable[(y+displacement)%256];
}
displacement++;
Just some code-fragments (again made up while writing this ) and i think you got my point.
Btw, in OpenGL, you can use the texture matrix stack to add a plasma effect to a texture you’ve applied to a cube. You could just use the glTranslatef() function to distort the texture coordinates.
Hope you understood all, but i think you can experiment with this all. Just go and experiment with different cosine and sine waves to generate interesting patterns.
Have fun and mail me if you still don’t understand it all.
Ciao,
Niftybitz.