As part of an application for some work, I recently tried to make some novel procedural fire effects in Flash. The best I found online was Flash Enabled Blog’s CS3 fire, Which is nice but not quite as flexible as I wanted it to be. What I did like was the perlin noise, though, so that’s where I started off, and ended up with this:
Just move the cursor around and you make fire! If you want to save the image you’ve made, press ‘s’ and then save the file to where you like. I learned a lot making it, not least of which is that I enjoy procedural graphics a lot, and that nowadays, flash is capable of doing a lot of crazy stuff. Rather than just put the source up, which I can do if anyone wants it, I thought it would better to describe the bits and pieces that make it up.
What’s in it
- Accumulation buffer: (with blur) for the haze behind the fire, and the fade from white, to orange to red to black. For other, more awesome applications, see Auditorium.
- Particles: A simple technique but a good one. Random particles with a time-to-live (TTL), which determines their size and opacity.
- Displacement map: There’s a full-frame displacement map on there, which gives you the distortion.
- Perlin Noise: for the displacement map. Perlin noise is great for natural motion because it’s random without looking too jagged like a standard noise map, and has more visually interesting detail than brownian noise.
- Wrapped scrolling: For the Displacement map, so it looks like it’s always moving in unpredictable ways. I wouldn’t mention it but for the fact that flash doesn’t seem to handle it automatically, so I had to write it (but now that I do have it written, I’ll definitely use it again!)
I’ve been writing in flash for a while now, and I have to say I’m extremely surprise at how much can be with it these days. Where available, hardware acceleration has meant that I was able to update three full-size raster effect layers on a per-frame basis. In pushing the system I had built to the limits, I found that it stands up to even 5,000 particles and about as many line segments, so long as nothing else is happening.
I’ve also been playing around a lot with stuff like procedural SVG animation, Processing and Werkkzeug (a tool for on-the-fly animation and modeling). These tools are interesting, but has taken me a long time to overcome my bias against them. I studied Computer Science in university, and I have found that such formally trained people, who I call “real programmers” often scorn languages and tools of this kind as being capable of only the most trivial of tasks. This is certainly an unfair assessment now – I suspect that it always has been – but it persists out of a sense of technical snobbery that formal training never fails to engender.
One of the main outcomes from this gradual introduction of newer and simpler tools is that the barrier to entry is lowered. While you’d think most people would see this as a wonderful development, it means the number of people dabbling with the tools explodes, which can result in result in a lot of chaff being produced. This can be a disappointment, but that shift of the average work to a poorer grade should not be confused with a decline in absolute terms. Very rarely does the introduction of a new tool or technique result in an individual’s skill deteriorating. When flash was introduced with a half-decent scripting language, irritating splash screens plagued the web, and not long after that, unnecessarily complicated image slideshows began making the rounds. At the time, though, there was Jared Tarbell’s levitated project and James Tindall’s The Square Root of -1, which were amazing feats with the web technology of the time. Now that everyone has calmed down a bit, we’re starting to see some Flash 10 applications which are impressive in any context.
This lowering of the barrier to entry isn’t the only thing that happens, though. As the bits and pieces that make up an application become easier to manage, the more choice a developer has over which aspects of a system to focus on. This means that an idea (for a game, a program or a graphic) that would have required much more work in the past can be developed much more easily.
We see a lot of interesting stuff emerging from this. Physicsgames.net is a collection of many of the physics-based games (though no optics-based ones yet!) that have emerged from the development of the Flash physics engines APE and Box2d for Flash. Most of them are basic block-stacking or block-destroying games, but there are also a few really original ideas, and one in particular, Fantastic Contraption, that is so innovative that Chris Hecker of Spore fame cited it as taking physics farther than commercial games. The technology for fantastic contraption has been feasible as a moderately large-budget game since the mid-1990s, but the amount of code and the number of developers required meant it never happened. Now that the programming job can be a one-man task, it and games like it are showing us just how clever these “stupid” languages can be.