The first part of the week went fairly quickly: I began and completed the backdrop for the second scene of the introductory cutscene.
However, this scene calls for animated mist, and so, in the second part of the week, I set out to implement that. This was the "slow" part of the week, with a few days given over almost entirely to producing the effect.
As I believe that I've mentioned before, I had been of two minds as to how to go about implementing mist.
Particles seemed like an attractive possibility--they should be fairly straightforward, and their use is a venerable technique for representing smoke and mist. However, I recall that I wasn't convinced that they would readily produce the sort of billowing, evanescent mist that I wanted. For one thing, I think that I was worried that the individual particles would be a little too obvious. On top of this, there was the question of how to make a particle system fit nicely with the workings of the cutscene system.
My other salient idea was to use layered textures, blending them in such a way that they produced interesting billows. I believe that I've seen something like this done before, and think that I even recall having done something similar myself. I hesitated to approach this concept, however; I forget why--perhaps because the concept was too inchoate in my mind, or because I had an intuition that it wouldn't likely produce the effect that I was looking for.
I settled on particles.
One challenge to this approach was that I wanted the mist to be brighter where it billowed up, or was thicker. This could be done via additive blending--but I didn't want the mist to be additive with its environment, only within itself. To achieve this, I had my particle system render additively into an off-screen buffer, then applied the resultant texture to a piece of geometry (with a shader to generate the desired colour and transparency).
This produced promising results. I spent some time tinkering with it, trying to get it right--but it never quite worked as I wanted. In particular, the particles spawned randomly along the length of the emitter, resulting in frequent gaps. This could be reduced by increasing the number of particles--but doing so made the result over-bright, and too homogenous.
I did have my own particle implementation available, which would likely have given me more control over the particle-spawning, but I've found it to be a little heavy on performance.
I turned to my other idea, layered textures, but the results were not promising. One issue that I recall in particular was that the layers were far too visible--the result looked more like multiple textures flowing over each other than a single effect.
3D perlin noise was given brief consideration, but I wasn't sure of how to make such a thing look "painted".
Then a new idea came to me. In a sense, it was a combination of both the "particle" and
"texture" ideas: As in the latter, the central element is a texture, in this case representing a looping "line" of mist, which would be layered multiple times. However, the layers would be treated as something like particles: each would expand outwards, with their starting times staggered, and with random positional offsets. When a layer completed its expansion, it would be reset, expanding again from the start with new offsets. Thus each layer would be essentially a single, huge particle, repeating along the length of the effect.
The layers are multiplied together, but the degree to which a given layer contributes to this is greatest halfway through its expansion, fading to having no effect at its start and end.
After much experimentation and refinement, I found that this worked fairly well.
The next question was that of how to present this new effect on the screen; initial experiementation applied it to a simple rectangle, as I recall, but that wouldn't likely give me the flow that I wanted.
I tried to use a class provided by Panda3D that's generally well-suited to such tasks (and indeed, I've successfully used this class before, I believe), but for some reason the resultant geometry didn't seem to quite match the points that I was using--a frustrating issue that I never did find the cause of. In the end I gave up and switched to generating the geometry myself using lower-level Panda3D classes, a process that seems to have worked.
In the end, the result was the mist-effect shown above. It has a few bugs remaining, and it's not exactly what I had in mind, but I'm overall pretty happy with it.
That's all for this week--stay well, and thank you for reading! ^_^