Friday, 28 February 2014

Go with the flow

Brief start warm-up before we get to the actual topic at hand: I love Valve. Their games are just fantastic, Team Fortress 2 was the first game I ever started to get competitive in, Half-Life is just a fantastically executed series and Left 4 Dead is one of the greatest examples of co-op games out there. They just do so much in terms of visual styles and gameplay, as evidenced by the numerous breakdowns of TF2 (including the one we watched in-class). So I'm going to overlap my interests with my love here and talk about how Valve flows.

So firstly, let's talk about the two types of water that Valve can employ: The expensive and the cheap. Basically this denotes the overall quality of the water effect because you need to trade off quality for performance in some cases. Really, the main difference between the two is that Expensive water utilizes real-time reflection and refraction which can result in some splendid effects
Just look at that beautiful effect
Meanwhile, Cheap water doesn't get these luxuries and instead uses environment mapping to generate a facsimile of a reflection. It still gets the job done and it's much cheaper, but it's not quite as nice.

Next let's talk about the over under...Or rather the above and the underwater. The Source Engine separates the water into two parts that should be rendered differently. You have the above water, which is the surface that you see when you look over it (i.e. in the picture above) and you have under the water which can affect the view of the game. There's really not much else to say about it.

Now let's talk about one of the bigger additions to the engine (Even though it did happen just over 4 years ago), the ability to control the flow of the water...Naturally this is just a purely visual effect as doing proper fluid dynamics on the scale that they would need it would be quite the challenge for most processors. The method for the actual flow is pretty similar to how one does a normal map, but rather than storing the normal of the surface in a texture we store the direction that the water is flowing in. Here's the guide they use for extracting the direction of the flow:

So how do we use this reference to make the water seem to move? Well, they actually use it to figure out how to manipulate the normal map of the water at that point, using it to denote the direction it should be moving in and how it should be skewed to match the direction. The result is quite impressive as seen in the demo: 

And that's about that on the Valve's water. As a final note, I'll put up some images showing how the flow map actually looks on the maps: 

And with that I'll call it a night. I hope you enjoyed this splashing blog and this flood of information...I almost made it to the end without making water puns but I just couldn't resist.

For a reference I used the Valve Developer Wiki, an invaluable resource for anyone working with the Source Engine whether it be coding to level editing. 

No comments:

Post a Comment