DENTHOR/ASPHYXIA'S VGA TRAINERS PLASMAS
Plasmas are a great way to wow your friends by their weird shapes and forms. I was at one stage going to write a game where the bad guy just had two circular plasmas instead of eyes… I am sure you will find creative and inventive new ways of doing and using plasmas.
DENTHOR, coder for ... _____ _____ ____ __ __ ___ ___ ___ ___ __ _____ / _ \ / ___> | _ \ | |_| | \ \/ / \ \/ / | | / _ \ | _ | \___ \ | __/ | _ | \ / > < | | | _ | \_/ \_/ <_____/ |__| |__| |__| |__| /__/\__\ |__| \_/ \_/ firstname.lastname@example.org The great South African Demo Team! Contact us for info/code exchange!
Grant Smith, alias Denthor of Asphyxia, wrote up several articles on the creation of demo effects in the 90s. I reproduce them here, as they offer so much insight into the demo scene of the time.
These articles apply some formatting to Denthor's original ASCII files, plus a few typo fixes.
How do plasmas work?
I will only cover one type of plasma here: a realtime plasma of course. Other types of plasmas include a static picture with a pallette rotation.
When you get right down to it, this method of realtime plasmas is merely an intersection of four COS waves. We get our color at a particular point by saying:
The trick is getting the four indexes of that cos table array to create something that looks nice. This is how we organize it: have two of them being indexes for vertical movement and two of them being indexes for horizontal movement.
This means that by changing these values we can move along the plasma. To draw an individual screen, we pass the values of the four to another four so that we do not disturb the original values. For every pixel across, we add values to the first two indexes, then display the next pixel. For every row down, we add values to the second two indexes. Sound complex enough? Good, because that what we want, a complex shape on the screen.
By altering the original four values, we can get all sorts of cool movement and cycling of the plasma. The reason we use a cos table is as follows: a cos table has a nice curve in the value of the numbers… when you put two or more together, it is possible to get circular pictures… circles are hard to do on a computer, so this makes it a lot easier…
Okay, now you can have a look at the source file, all I do is put the above into practice. I did add one or two things though…
Background: This is just a large array, with the values in the array being added to the plasma at that pixel.
Psychedelic: This cycles through about 7000 colors instead of just rotating through the base 256.
You will notice when the sample program fades in and out that the colors all reach their destination at the same time … in other words, they don’t all increment by one until they hit the right color then stop. When done in that way the fading does not look as professional.
Here is how we do a step-crossfade:
Each r,g,b value can be between 0 and 64. Have the palette we want to get to in
bob and the temporary pallette in
bob2. For each step, from 0 to 63 do the following:
That means if we are halfway through the crossfade (step=32) and the red value is meant to get to 16, our equation looks like this:
Which is half of the way to where it wants to be. This means all colors will fade in/out with the same ratios… and look nicer.
Rotating the pallette
I have done this one before, I think. Here it is:
And your palette is rotating. Easy huh? Recheck Part 2 for more info on palette rotation.
The tutorial was a bit short this time, but that is mostly because the sample file is self-explanatory. The file can however be speeded up, and of course you can add certain things which will totally change the look of the plasma.