Interesting Cloud/Marble Effect


The effect that I'm going to describe is really useful. You can do a lot of effects by using the same concept. It's really easy. I bet you have done a lot of those "sin/cos bitmap-wavers", but it is pretty difficult to make them look nice.

1. Set up two different maps of byte, 256x256 will do. Fill them with for instance fractal clouds. :) Or you can just do some nice clouds in Photoshop if you're lazy. Name them xmap & ymap or something like that. :) Colour range 0-255 is excellent.

2. Make a nice bitmap (the one that will be "marbled" or "waved"). A picture which is tileable will look best (as usual :D). If you want to do clouds, simply create clouds in Photoshop using the "Cloud" effect, with the palette going from white to blue.

OK. This is how you will render the frames:

Set up some wave variables (Yes! You will still have to do sin/cos wave :)):

sine = char table[256] containing precalced sin values
cose = char table[256] containing precalced cos values

s2 = frame*3/4;
s3 = sine[(s2&0xFF)] - cose[frame&0xFF];

NOTE: You don't have to use those lines... almost anything will do. :)

For every pixel


    ( x & y = screen cord )

   dy = sine[ (y-s2)&0xF ];
   dx = cose[ (cose[ (x+frame)&0xFF ]) & 0xff ]-s3;
   // Just some shitty waving, hehehe :)

   // Don't have to do this :) Just to make the picture not wave TOO much

   dx += xmap[ (y&0xff)*256+((x+frame)&0xff) ];
   // xmap = our fractal cloud map
   dy += ymap[ ((y+frame)&0xff)*256+((x)&0xff) ];
   // ymap = another fraccloud map

   Just fetch your texel from the bitmap at [x+dx][y+dy] and plot it!!


Hope you'll get this to work... Or else you can cheat and look at a my source code brought to you in the bonus pack. It might not compile OK, but that's because I'm writing in MSVC++ 5.0. :)

DOS Sucks!
WIN Rules!

Anyway... If you're interested in Win XM-Players without the sync delay bug in MIDAS... DFPXMS coded by me, will be released soon. :) It will be free to use, of course.

Dan Nilsson.
Coder of Obscure.