Water (shader): Difference between revisions
Line 43: | Line 43: | ||
| <code>$envmap (texture name)</code> | | <code>$envmap (texture name)</code> | ||
|- | |- | ||
|Texture to use for environment mapping (only for | |Texture to use for environment mapping (only for cheap water or water only refracts). Set this value to env_cubemap to use cubemaps placed in the map. | ||
|- | |- | ||
| <code>$fogcolor { R, G, B }</code> | | <code>$fogcolor { R, G, B }</code> | ||
Line 60: | Line 60: | ||
|- | |- | ||
|This is the distance in inches from the eye at which water fog starts. | |This is the distance in inches from the eye at which water fog starts. | ||
Note: This must be | Note: This must be 0.0 for edge fading to work properly. | ||
|- | |- | ||
| <code>$forcecheap (0,1)</code> | | <code>$forcecheap (0,1)</code> | ||
|- | |- | ||
|Make this water | |Make this water cheap regardless of the water_lod_control entity’s setting. This will ignore $reflecttexture and $refracttexture. Reflections will happen with $envmap and refraction is assumed to be opaquely the water fog color. | ||
|- | |- | ||
| <code>$forceexpensive (0,1)</code> | | <code>$forceexpensive (0,1)</code> | ||
|- | |- | ||
|This forces the water to render itself as | |This forces the water to render itself as expensive, regardless of the water_lod_control entity’s setting. | ||
|- | |- | ||
| <code>$normalmap (texture name)</code> | | <code>$normalmap (texture name)</code> | ||
Line 84: | Line 84: | ||
| <code>$reflecttexture (texture name)</code> | | <code>$reflecttexture (texture name)</code> | ||
|- | |- | ||
|Texture to use for reflection. For real-time reflections, use | |Texture to use for reflection. For real-time reflections, use _rt_WaterReflection. | ||
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. | ||
|- | |- | ||
Line 97: | Line 97: | ||
| <code>$refracttexture (texture name)</code> | | <code>$refracttexture (texture name)</code> | ||
|- | |- | ||
|Texture to use for refraction. For real-time refractions, use | |Texture to use for refraction. For real-time refractions, use _rt_WaterRefraction. | ||
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. | ||
|- | |- |
Revision as of 15:40, 6 January 2006
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.
Expensive Water
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.
Cheap Water
For situations where a more simplistic water solution is called for (normally for performance reasons), cheap water may be used. This version of water does not reflect the world around it, making it less realistic, but also much cheaper. Expensive water will fallback to cheap water on video cards that are unable to support the features necessary for it to render properly. It will also fallback to this material if the user overrides the visual quality setting for water’s appearance in the Video options in-game.
Water Volumes
See Adding Water for more information on how to create water volume brushes in your levels.
Creating Water Materials
Water materials are separated into two types: above and below the surface. The bottom material is specified via a parameter inside the above surface material. The above material is displayed when the view is outside of the water looking into it, and the bottom material is displayed when the view is underneath the water and looking out of it. Each material may define its own custom parameters to alter its appearance. Generally the coloration of the water materials should closely correlate. By altering the material parameters for either material type, you can change the opacity of the water, the amount of reflection, the amount of refraction, and the tinting of the water.
Water Material Parameters
$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)
|
Texture to use for environment mapping (only for cheap water or water only refracts). Set this value to env_cubemap to use cubemaps placed in the map. |
$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.
Note: This must be 0.0 for edge fading to work properly. |
$forcecheap (0,1)
|
Make this water cheap regardless of the water_lod_control entity’s setting. This will ignore $reflecttexture and $refracttexture. Reflections will happen with $envmap and refraction is assumed to be opaquely the water fog color. |
$forceexpensive (0,1)
|
This forces the water to render itself as expensive, regardless of the water_lod_control entity’s setting. |
$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)
|
Texture to use for reflection. For real-time reflections, use _rt_WaterReflection.
Note: If you can specify $refracttexture without specying a $reflecttexture to get real-time refraction and cube map reflections. |
$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)
|
Texture to use for refraction. For real-time refractions, use _rt_WaterRefraction.
Note: If you can specify $refracttexture without specying a $reflecttexture to get real-time refraction and cube map reflections. |
$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. |