gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

OffTopic > Move over Britney ... this is eyecandy to die for

#31250 - keldon - Thu Dec 09, 2004 5:31 am

http://diegofraga.f2g.net/Files/Plasma.zip
N.B. do not view this when tired, sleepy or before driving. Do not look at it for more than 30 minutes; or they may be your last sane 30 minutes.

Enjoy !!

#31252 - DekuTree64 - Thu Dec 09, 2004 5:45 am

Ooh, it's just like you have your face smashed against the screen, only you don't have to burn your eyes out^_^

Did you make it yourself?
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#31253 - keldon - Thu Dec 09, 2004 5:46 am

Oh no I had nothing to do with it; it's by someone on another board I'm on. He's done an amazing fire demo too called Fuego.

#31281 - Lupin - Thu Dec 09, 2004 3:37 pm

it's just a plasma effect, isn't it? even on a GBA i wouldn't be too impressed sorry =.="
_________________
Team Pokeme
My blog and PM ASM tutorials

#31293 - bahnhof - Thu Dec 09, 2004 6:21 pm

I don't really mean to be sarcastic but your friend is at least twelve years late.. I expected some kind of new plasma effect but this is a standard plasma in it's most basic form.

#31297 - Lord Graga - Thu Dec 09, 2004 6:54 pm

bahnhof wrote:
I don't really mean to be sarcastic but your friend is at least twelve years late.. I expected some kind of new plasma effect but this is a standard plasma in it's most basic form.


I am laughing at your sarcasm-spotting skills. (Sorru, it could have been anyone).

I like the plasma though. Now do it on GBA or die a horrible and painful death due to my unholy hammerthrow.

#31355 - mymateo - Fri Dec 10, 2004 10:27 am

Lupin wrote:
it's just a plasma effect, isn't it? even on a GBA i wouldn't be too impressed sorry =.="


Hmm... bit of a depressing response. Since I'm still new at programming in general, effects like that are still impressive to me, and will remain that way until I figure out how to do them, or find something (document / readme / tutorial / have someone else tell me) to help me figure it out / tell me how it's done. But, hey, if it's so unimpressive, maybe you can make something WAY cooler, and impress the pants off me! Do that, and I'll send you pics! ;) (Just kidding...)

#31388 - Abscissa - Fri Dec 10, 2004 7:28 pm

As standard as plasma effects are, it's still a pretty nice one. I like the color theme (various bright colors in between portions of black) and the "oversized pixels with spaces in between". I agree it's not very impressive on a technical level, but I do appreciate it asthetically (sp?). It reminds me a little bit of "Our Demo" by Outracks (see scene.org).

mymateo wrote:
Hmm... bit of a depressing response. Since I'm still new at programming in general, effects like that are still impressive to me, and will remain that way until I figure out how to do them, or find something (document / readme / tutorial / have someone else tell me) to help me figure it out / tell me how it's done. But, hey, if it's so unimpressive, maybe you can make something WAY cooler, and impress the pants off me! Do that, and I'll send you pics! ;) (Just kidding...)


I would point you to a tutorial that I saw a while ago, but I don't have a clue anymore where it was.

Basically what you do is set up a color palette that's a gradient, one that maybe goes smoothly through a few different colors (You can do it in a non-palettized mode, but palettes make it easier to explain). Then, for each pixel on the screen you have an equation. Basically, "color = some function involving the pixel's x and y coordinate". As a simple example, you can get interesting effects with color = x * y, or color = x ^ y, although those are not plasmas. Remember this stuff, I'll get back to it.

Getting a plasma involves averaging together a bunch of sine waves. I don't know how much trig you're familiar with so if you already know all about them just skip this paragraph. The basic sine function (for plotting the wave on the screen) is y = sin(x) (where x is usually in terms of degrees or radians, but you can just plug in screen coordinates for degrees). A more complete equation that allows you to tweak all sorts of aspects of the sine wave is y = a*sin((x/b) + c) + d, where a,b,c,d are values you can arbitrarily pick and tweak to change different things about the wave. For a plasma, a and d are probably not very useful, so ignore them (ie, a=1, d = 0). b changes the frequency and wavelength of the wave, and c shifts the whole wave left and right. So you can have different waves like y=sin((x/3)+20) or y=sin((x*2)+90).

You can get more complex sine waves by averaging two or more together (like "y = ( sin((x/3)+C1) + sin((x*2)+C2) ) / 2" ). Now, what starts to get more interesting is if you keep plotting that wave every frame, and each frame you change C1 and C2 by different amounts (such as, C1 += 3 and C2 -= 1 every frame). That makes the wave squiggle around all funky-like ;).

Now, imagine if you took that wave, and instead of looking at it from the side, look at it from the top. You'd basically just see a straight horizontal line. So imagine if you used a different color for each hight value, basically just like a heightmap. And use the gradient color palette I mentioned before. So, instead of using the equation y = blah, you're just keeping y at 0 (or any y value, really) and using color = blah. Then, what you'll have is a single row of pixels all moving and pulsating around. What you have is the top row of pixels of a plasma.

Now for the rest of the screen. You'll need two more sine waves, with C3 and C4 (non-explosive, though ;) ), just like the others had C1 and C2. And for these sine waves, use y instead of x. So, just as an example, we have sin((x/3)+C1), sin((x*2)+C2), sin((y/3)+C3), and sin((y*2)+C4). Now we have a complete equation of the form "color = some function involving the pixel's x and y coordinate", which is "color = the average of the sine waves", or in this example, "color = ( sin((x/3)+C1) + sin((x*2)+C2) + sin((y/3)+C3) + sin((y*2)+C4) ) / 4". And you just compute that for every pixel on the screen, increment C1 through C4 by different amounts, and then do it again. And then you have a plasma :)

So the steps are:
1. Create/Load an interesting gradient palette.
2. For each pixel, set the color to the average of a bunch of sine waves.
3. Increment each of the C values by different amounts.
4. Repeat from Step 2.

Since you're doing all of that calculating for every pixel, you can see how it can take a lot of processing, at least without optimizations. Also, you'll probably want to use more than four sine waves like I did, probably more like nine or so. The more you use the better it'll look, but the more processing it'll take.

mymateo wrote:
But, hey, if it's so unimpressive, maybe you can make something WAY cooler, and impress the pants off me!


If you have a huge stockpile of pants you can afford to loose, take a look around Scene.org. I recommend the stuff by Outracks, Farb-Rausch, 3State, Conspiracy, and Kewlers, just off the top of my head. Oh, and check out the Text Mode Demo Competition, too.

#31398 - Lupin - Fri Dec 10, 2004 8:04 pm

nice explanation Abscissa!

For nice prods i can also recommend this site (it's an affilate of scene.org anyways):
http://www.pouet.net/

Check out the farbrauch demos (also GBA demos), they are the best demo group.
_________________
Team Pokeme
My blog and PM ASM tutorials

#31426 - Abscissa - Fri Dec 10, 2004 10:40 pm

Lupin wrote:
nice explanation Abscissa!


Thanks! ^_^