Water (shader)

From Valve Developer Community
Revision as of 20:57, 8 April 2005 by Erik Johnson (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Water is a very complex shader inside of the Source engine: it is animated, reflective, fogged, refractive, and bump mapped. With this complexity come rules and restrictions on how it is placed and what sort of water is used in different situations.

=

This sort of water is the best looking, but also carries the most cost. This shader will reflect the world around it, refract and fog the world beneath it (based on the line integral through the water volume), and animate a bump mapped texture on the surface. While the results are photo-realistic, the cost can sometimes be too prohibitive for complex scenes.

=


Water Volumes

See Adding Water for more information on how to create water volume brushes in your levels.

Creating Water Materials

Water Material Parameters

Note: If you can specify $refracttexture without specying a $reflecttexture to get real-time refraction and cube map reflections. Note: If you can specify $refracttexture without specying a $reflecttexture to get real-time refraction and cube map reflections.
$abovewater (0,1)
Whether this material is used for above or below the water’s surface.
$bottommaterial (material name)
Required field. This is the material to use when underneath the water’s surface. The bottom material must have $reflecttexture disabled and can have unique parameters for rendering the underwater scene. The bottom material should also set $abovewater to 0.
$bumpframe (integer)
Used for the texture animation proxy to declare the starting frame of the animated water surface.
$bumpmap (texture name)
This is the DUDV map for the water. It is generated from a normal map. $bumpmap is used for dx8 water, and $normalmap is used for dx9. You should specify both so that you’ll get the correct results on both versions of the water shader.
%compilewater(0,1)
This is needed for the compilation tools.
$envmap (texture name)
$fogcolor { R, G, B }
This is the color of the water’s volumetric fog. Generally this value should match the color used in the bottom material.
$fogenable (0,1)
Enable volumetric fog for the water.
$fogend (float)
This is the distance in inches from the eye at which water fog ends.
$fogstart (float)
This is the distance in inches from the eye at which water fog starts.
$forcecheap (0,1)
$forceexpensive (0,1)
$normalmap (texture name)
This is the normal map for the water. This is used by the dx9 water shader.
$reflectamount (float)
This is the amount of warp for the reflection. Higher values produce more visible reflections.
$reflectentities (0,1)
Make the water reflect entities. By default, no entities are reflected.
$reflecttexture (texture name)
$reflecttint { R, G, B }
This is the color tint for the real-time reflection and environment map.
$refractamount (float)
This is the amount of warp for the refraction. Higher values produce more warping.
$refracttexture (texture name)
$refracttint { R, G, B }
This is the color of the refraction.

Note: It is recommended that you set this to white or something close to white so that edge transitions work properly on dx9.

$surfaceprop "water"
Used by the physics system to define this surface as water.
%tooltexture (texture name)
Declares the texture to be used in Hammer when editing.
WaterLOD proxy
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.