Fire effect

Started by
12 comments, last by yue feng 22 years, 1 month ago
The fire can be low at times. The colour palette may limit how high you fire can go. That''s why I use a 768 custom colour palette.

A solution would be to average less pixels, especially the pixels above the one you are trying to average for.

Try this:

Take Out: (Or rem out)

fire_buffer[fireoffset-640]
fire_buffer[fireoffset-641]
fire_buffer[fireoffset-639]

Then divide by 5.
That should get your fire to be higher because it is not throwing in as many dark pixels into the averaging algo.

Guy


"Who lives in a pineapple under the sea ?"
Advertisement
quote:Original post by Arion
Try this:

Take Out: (Or rem out)

fire_buffer[fireoffset-640]
fire_buffer[fireoffset-641]
fire_buffer[fireoffset-639]

Then divide by 5.

Try to stick with powers of two when you're doing the averaging. That means you can avoid divisions per pixel (yuck!), using >> right bit-shifting instead - your computer will thank you for it, trust me!

As a test, I took some unoptimised code I did a while back and replaced a "shr 2" (it's in Delphi, in case you're wondering) with a "div 5". Now, ignoring the obvious visual difference (smaller fire), it whacked 40 frames per second off (and if I'd optimised it, that would get even larger)!

The compiler is probably smart enough to catch dividing with powers-of-two and turn it into shift code, so you don't even need to do much to get the benefits other than use the right numbers.

[edited by - Alimonster on March 19, 2002 6:44:44 PM]
Good point Alimonster.
But it is not always so easy to get the desired effect.
It sometimes takes trial and error.

I guess you could take out
fire_buffer[fireoffset+640]
and divide by four.

If you take too many pixels out,
the fire looses it''s effect.

One thing I did to average three pixels was:

( x + (y<<1) + z ) >>2;
Where y was the pixel under the one I was averaging for.
It turned out pretty good, and fairly fast. That would be
fire_buffer[fireoffset+640] in that algo. The other two would be the ones to the left and right of that pixel.

Guy


"Who lives in a pineapple under the sea ?"
Sorry but the height hasn''t improved much.(perhaps 5% higher,it only occupy one 50th of my screen)

I have no idea why?

This topic is closed to new replies.

Advertisement