Skip to content
Dev Archive

The Dam – Water in depth

by Angry Beaver

Archived from the original dev blog and left as it was written, so it reflects the game as it stood in 2008.

Well something took the website down for a couple of minutes and that apparently seems to of killed all the previous comments on the blogs, sorry bout that guys were seeing if there’s a way to restore them but onto the topic. As an aquatic rodent I know a few things about building with Water so this week I’ve decided to impart some of that specific knowledge. I’m going to talk about the different types of water, how you can use them, special waters and typical problems.

Realistically there are two types of water Expensive and Cheap. Expensive water refracts, reflects, reflects dynamically, is partially transparent and looks pretty. Cheap water well… it uses cubemaps, deforms them a bit, and only its mother could think it’s a pretty effect. The actual mechanics of the water is the same but the top surface differs drastically between the two. People sometimes wonder why there’s the two of them, basically its performance. Cheap water is called cheap rather than ugly because it renders much faster than the expensive water effect.

Now there’s one thing that makes using expensive water all the time require a little bit of skill. Expensive water basically takes the top of the water, flips what’s there and puts it into the reflection; however, because of that you cannot have the top of the water at several heights inside the same Potential Viewable Set (PVS). So what does that mean? Basically you can’t be able to see two faces of expensive water if one is higher up than the other, the engine can’t determine what top face to use to approximate the reflected geometry so it ends up causing a graphics glitch in the waters surface itself. The PVS is what’s used to determine if you can view the waters surface and the basically refers to what the game thinks is visible and is rendering rather than what you actually see in front of you. The error only appears when your PVS includes both water heights, until then the engine doesn’t notice the problem, so something like a waterfall cannot have expensive water at both top and bottom because a player would be able to see both and in some areas, unless you constrict the player rather specifically to prevent them from seeing both ends you will see visual glitches.

Now the basic way to create a water brush is to texture a brush all in nodraw and make the top a water face. Simple enough but that doesn’t explain func_water_analog. There’s 2 main reasons to use a func_water_analog, when the water needs to move, or when you need a volume to be water or you want to force a cheap water effect from an expensive material. The func_water_analog can’t take a proper expensive water texture and will turn it down simply because this water can do simple movements like a door and even be attached to parent hierarchy, an expensive water texture on a func_water_analog doesn’t count as cheap water unfortunately. For a water to render properly you MUST compile VIS, if you don’t compile VIS it cannot determine your PVS and the geometry that it might reflect meaning the waters surface wont render. Simply selecting VIS isn’t enough you should ensure there are no leaks or other errors preventing VVIS from being run.