Clouds


The last few weeks have involved returning home from Hong Kong, moving into a new place, and getting caught up at my paying job. Whew! That's a lot of business not at all related to Texas and this is the first opportunity in quite some time that I've had to really decompress and get back into the groove of it.

@p I did manage, over the past couple weeks, to get clouds implemented. I was always impressed with the clouds in Wind Wakker:

@p The clouds, if you've played the game, are made up of puffs that kind of moosh in and out and seem to fade and grow/shrink. Everything about this game is striking, and so I say: Zelda The Wind Wakker ho!

@p So I made a similar effect for Texas: clouds made up of puffs that kind of moosh in and out. Here is how it works internally:

@p 1. You have global wind vector and air density function. The air density function is just a 2D noise.

@p 2. You have many "puffs" which are essentially floating rectangles with position and radius data.

@p 3. The puffs move according to the wind vector, plus or minus a certain randomized amount.

@p 4. The puffs grow and shrink, and alpha fade according to the air density.

@p 5. The air density (think: moisture, not really air density) function includes an offset which moves at the wind speed, so it roughly tracks the wind.

@p 6. We render them a bit fancy to get a nice "silver lining" effect and handle transparency.

@p 7. As puffs move off the edge of the screen, they are reborn randomly at the other side. They are uniformly distributed.

@p The effect of the air density and the puffs is the most interesting. What happens is the air density function actually determines where the clouds lie, and the puffs act as a layer to visualize them. Since the puffs move at a slightly different rate as the air density function, the "clouds" appear amorphous and seem to grow in and out. It helps a lot that the puffs don't just fade, but also grow and shrink.

@p That's, my friends, how clouds work! Now I just need to work out some stencil effects for rendering them with area-to-area wipe transitions, and as reflections in ponds. Here we go!

2009-07-16


◀ Back