From Valve Developer Community
Water is one of the Source engine's most complex shaders. It creates animated, real-time reflective and refractive, fogged, normal-mapped water.
- Expensive and cheap
Watermaterials fall into two groups: expensive and cheap. Expensive water reflects and refracts the world in real-time, while cheap water uses an
$envmapand does not refract. Users can disable expensive
Waterrendering through their video options, so always place env_cubemaps.
- Above and below
Wateractually requires two materials: one for above the surface and one for below. These materials are independent of each other, but of course for proper effect need to correlate in most areas.
Tip:There is no
$basetexturehere. The surface is a combination of fog colour, animated bump map, and reflection.
- Whether this material is used for above or below the water’s surface.
- Required field. This is the material (not texture) to use when underneath the water’s surface. The bottom material must have
$abovewaterdisabled, but can otherwise do whatever it wants.
- Applies a screen overlay when the camera is underwater. Generally used with
$abovewaterto be 0.
- A Du/dv map for DirectX 8 rendering (
$bumpmap), and a bump map for DirectX 9 and above (
$normalmap). These should be animated unless the water is to be perfectly still.
$normalmapcommand is unique to the
Watershader, and uses a normal map. A du/dv map is used for
$bumpmapwhen using the
$dudvmapcommand is obsolete.Tip:Use
$bumptransformwith the TextureScroll proxy to move the normal map.
$scroll1 "[<normal X> <normal Y>]"
$scroll2 "[<normal X> <normal Y>]"
$scroll1is defined and X is not zero, two more instances of the normal map will be drawn in such a way that they are merged together. The first layer is 7x larger and rotated 45°; the second is 2x larger and rotated 90°. The parameters specify the speed and direction that the extra layers will move. (Valve's materials usually contain a third number, but it doesn't have any apparent effect and is most likely obsolete.)
- Frame to start the animated du/dv map and bump map on, respectively. Somewhat confusingly,
$normalmap, which should be pointing to a bump map.
$fogcolor <RGB matrix>
- This is the color of the water’s volumetric fog. Generally this value should match the color used in the bottom material.
- Enable volumetric fog for the water.
- This is the distance in inches from the eye at which water fog ends.
- This is the distance in inches from the eye at which water fog starts.
- Warning: This must be
0for edge fading to work properly.
$envmap <env_cubemap / texture>
- Provides reflections for cheap water. See
- Make this water cheap regardless of the water_lod_control entity's or user's settings. This will disable real-time reflection and instead use
$envmap. Refraction is assumed to be opaquely the water fog color.
- This forces the water to render itself as expensive, regardless of the map's water_lod_control or the user's settings.
- This is the amount of warp for the reflection. Higher values produce more visible reflections.
- Make the water reflect entities. By default, no entities are reflected.
- Texture to use for reflection. For real-time reflections, use
$reflecttextureto get real-time refraction on
$reflecttint <RGB matrix>
- This is the color tint for the real-time reflection and environment map.
- This is the amount of warp for the refraction. Higher values produce more warping.
- Texture to use for refraction. For real-time refractions, use
$reflecttextureto get real-time refraction on
$refracttint <RGB matrix>
- This is the color of the refraction.
- Warning: It is recommended that you set this to white or something close to white so that edge transitions work properly on DX9.
- This is a texture that defines flow velocity by skewing and scrolling the $normalmap. For the preservation of sanity Valve generate theirs with an unreleased Houdini plugin.
- See a clip of the effect on YouTube. For a detailed description of how it all works see Alex Vlachos' SIGGRAPH 2010 paper.
- The size of the normal map in relation to the flow map. Valve often use very high values (e.g. 800). To do: 1 == one normal map repeat for every texel?
- To do: No apparent effect.
- Confirm:Time needed for one complete scroll of the normal map?
- To do
- How rough surface of the water is.
- How fast the water flows over its specified distance.
- A treatment texture used to break up repetition of the normal map.
- To do: Has the same effect as $flow_normaluvscale?
- Replaces the water surface with a literal rendering of the $flowmap texture.
- This is needed to make a map using the material compile properly.
- Tells the physics system that the surface is water. See $surfaceprop.
- Defines the texture Hammer will display in the material browser.
- This connects the water_lod_control entity in a level to the water’s internal parameters. This must be declared in the material for the LOD mechanisms to work properly.