Water Water Everywhere

An important aspect of many successful platform games is a diversity in their environments.  I spent some time recently creating a nice water effect for any aquatic environments in my game.  The technique used is one that I have had experience with many times before, and can be read about on this great website:

http://freespace.virgin.net/hugo.elias/graphics/x_water.htm

The advantage of the method described is that the water is truly dynamic, allowing ripples and waves can be created at any point on the surface with no speed impact.  This will be important when the player is landing in the water or jumping out of it.  Another advantage is that there is no penalty for having little extras, like waves created by a waterfall that is hitting the waters surface, or little fish creatures jumping in and out of the water.

The original technique was applied as a top down 2D effect which wouldnt be at all suitable since the Tengu engine is for side on platformers.  I therefore have implemented this technique in 1D so that can effectively be run and viewed from the side on perspective.  The raw results of this algorithm can be fairly nasty to look at so I did two things to improve the look of the effect.  Due to the way this water effect operates, it allowed me to update it at a rate less than every frame, and for the in between frames I can then blend between the old state and the new state.  This smooths the animation and gives me a variable control of the speed of animation, which the raw technique never provided for.  The second advancement that I developed was to use cosine interpolation while drawing the water height field and so now the surface appears to have nice round ripples.

I still need to develop A nice final rendering solution to the water so that I really looks great, but as a basis this is a good start.  I made a mockup of the final water render that I want to achieve, and I have also the algorithm in mind that I need to achieve it, so it should easily be possible, and not too slow.  I should also be very much possible that light rays will also really be calculated based on the angle of the water, so this is something that I cant wait to see animated in the engine.

Water

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s