The S-Fire Implementation
Glen Pawley / Shock Sector
The classic fire algorithm, while being an all-round funky piece of work, has a severe problem, mainly that of fluidness: The flames look more the type you're likely to get by switching on a lighter than by making a fire because the algorithm is too smooth. (There are some implementations that fix this by taking random pixels to blur, but this makes it slower, and it stills doesn't look good enough).
The S-Fire implementation solves this problem: The flames generated with it look almost like a real blaze. The 'burning' is not smooth at all, and the flames do not fade gradually but seemingly randomly.
Also, the S-Fire implementation looks much more realistic at no speed expense. Its execution time is equivalent to the classic implementation. In addition, it is so easy to implement that you can get it up and running on already existing fire code in minutes.
For a simple working example of the S-Fire implementation, look at the zip file in the bonus archive which contains a small executable and its source code in Pascal.
For those who implement it - here's a couple of tips:
(1) Use backbuffers. Not just because they are faster to access but because if you copy the buffer to screen after you have blurred it you soften the peppering of the random pixels which is the only real downside to this implementation.
(2) Start with a backbuffer that is cleared with color 255 except for a row of say 5 pixels at the bottom with color zero. This will create the effect that the fire is rising, as in the classic implementation. If you don't do this the first few moments in the loop will not look like fire. Also make sure that the last row is color 0, especially if you do not process this line while you are blurring.
(3) Do not show the last few rows of the backbuffer.
(4) While inverting the palette so that the starting colors are brighter and the ending colors are darker, make sure you leave color 0 as black.
Any comments or questions are extremely welcome - email@example.com or firstname.lastname@example.org. Preferrably to the first address.
Oh, and if anybody uses this implementation for anything or suggests it to anyone I would appreciate it if you just mentioned my name in passing. Thanks!
- Glen Pawley is a member of the coding group Shock Sector. Watch out for cool stuff from us soon!