Water (shader): Difference between revisions
mNo edit summary |
(Fixed a typo, edited some page info a little, and added new parameters from Left 4 Dead 2, Portal 2 and Counter-Strike: Global Offensive, some need confirmation on what they do.) |
||
Line 17: | Line 17: | ||
=== Textures === | === Textures === | ||
{{ | {{note|In Orange box games and below, there is no <code>[[$basetexture]]</code>, The surface is a combination of fog color, animated bump map, reflection and refraction.}} | ||
; <code>$abovewater <[[bool]]></code> | ; <code>$abovewater <[[bool]]></code> | ||
Line 32: | Line 32: | ||
; <code>$bumpframe <int></code> | ; <code>$bumpframe <int></code> | ||
: Frame to start the animated du/dv map and bump map on, respectively. Somewhat confusingly, <code>$bumpframe</code> affects <code>$''normal''map</code>, which should be pointing to a [[bump map]]. | : Frame to start the animated du/dv map and bump map on, respectively. Somewhat confusingly, <code>$bumpframe</code> affects <code>$''normal''map</code>, which should be pointing to a [[bump map]]. | ||
; {{l4d2 add|<code>$flashlighttint <[[int]]></code>}} | |||
: {{confirm|How much projected textures should tint the water?}} | |||
; {{p2 add|<code>$pseudotranslucent <[[bool]]></code>}} | |||
: {{todo|What does this do exactly?}} | |||
; {{p2 add|<code>$waterblendfactor <[[float]]></code>}} | |||
: {{todo|What does this do exactly? Seems like it's related to $pseudotranslucent.}} | |||
; {{CSGO add|<code>$waterdepth <[[int]]></code>}} | |||
: {{todo|What does this do exactly? Seems like it's related to $waterblendfactor, Found in liquids/nuke_water.vmt.}} | |||
; {{CSGO add|<code>$depth_feather <[[int]]></code>}} | |||
: {{todo|What does this do exactly? Found in liquids/nuke_water.vmt.}} | |||
; {{CSGO add|<code>$nofresnel <[[bool]]></code>}} | |||
: Disable fresnel on the water. {{todo|Check if this does anything, as it's commented out in liquids/nuke_water.vmt, and isn't used anywhere else so far.}} | |||
; {{CSGO add|<code>$forcefresnel <[[int]]></code>}} | |||
: Force this amount of fresnel on the water. {{todo|Check if this does anything, as it's commented out in liquids/nuke_water.vmt, and isn't used anywhere else so far.}} | |||
=== Fog === | === Fog === | ||
Line 48: | Line 62: | ||
=== Reflection/Refraction === | === Reflection/Refraction === | ||
; {{p2 add|<code>$forceenvmap <[[bool]]></code>}} | |||
: Forces the water to use $envmap for reflections. | |||
; <code>[[$envmap]] <env_cubemap / texture></code> | ; <code>[[$envmap]] <env_cubemap / texture></code> | ||
: Provides reflections for cheap water. See <code>[[$envmap]]</code> | : Provides reflections for cheap water. See <code>[[$envmap]]</code> | ||
Line 56: | Line 72: | ||
; {{p2 add|<code>$reflect2dskybox</code>}} | ; {{p2 add|<code>$reflect2dskybox</code>}} | ||
: Makes this water reflect the [[skybox]] material ''in addition'' to other reflections. | : Makes this water reflect the [[skybox]] material ''in addition'' to other reflections. | ||
; {{l4d2 add|<code>$reflectskyboxonly</code>}} | |||
: Makes this water reflect the [[skybox]] only. | |||
; {{p2 add|<code>$reflectonlymarkedentities <[[bool]]></code>}} | |||
: Whether or not to reflect only entities and static props with "Render in Fast Reflections" on. | |||
; <code>$reflectamount <float></code> | ; <code>$reflectamount <float></code> | ||
: This is the amount of warp for the reflection. Higher values produce more visible reflections. | : This is the amount of warp for the reflection. Higher values produce more visible reflections. | ||
Line 65: | Line 85: | ||
; <code>$reflecttint <RGB matrix></code> | ; <code>$reflecttint <RGB matrix></code> | ||
: This is the color tint for the real-time reflection and environment map. | : This is the color tint for the real-time reflection and environment map. | ||
; {{l4d2 add|<code>$refract <bool></code>}} | |||
: Whether the material should refract at all. | |||
; <code>$refractamount <float></code> | ; <code>$refractamount <float></code> | ||
: This is the amount of warp for the refraction. Higher values produce more warping. | : This is the amount of warp for the refraction. Higher values produce more warping. | ||
Line 98: | Line 120: | ||
==== Basetexture Flow ==== | ==== Basetexture Flow ==== | ||
; {{p2 add|<code>$ | ; {{p2 add|<code>$basetexture <texture></code>}} | ||
: Used to create the floating debris and sludge inside test chambers. | : Used to create the floating debris and sludge inside test chambers. | ||
Revision as of 12:28, 11 April 2018
Water
is one of the Source engine's most complex shaders. It creates animated, real-time reflective & refractive, fogged, normal-mapped, and flowing water.
Special behaviour
- Expensive and cheap
Water
materials fall into two groups: expensive and cheap. Expensive water reflects and refracts the world in real-time, while cheap water uses an$envmap
and does not refract. Users can disable expensive water rendering through their video options, so always place env_cubemaps.- Above and below
Water
actually 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.- Flow Mapping
- Water can flow in arbitrary directions. It's very tricky to create a flow map by hand however, and the tool Valve used internally hasn't been released.
Shader parameters
Textures

$basetexture
, The surface is a combination of fog color, animated bump map, reflection and refraction.$abovewater <bool>
- Whether this material is used for above or below the water’s surface.
$bottommaterial <material>
- Required field. This is the material (not texture) to use when underneath the water’s surface. The bottom material must have
$reflecttexture
and$abovewater
disabled, but can otherwise do whatever it wants. - Template:EP2 add
- Applies a screen overlay when the camera is underwater. Generally used with
effects\water_warp01
. Requires$abovewater
to be 0. $bumpmap <texture>
$normalmap <texture>
- 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. Note:The
$normalmap
command is unique to theWater
shader, and uses a normal map. A du/dv map is used for$bumpmap
when using theWater
shader. The$dudvmap
command is obsolete.Tip:Use
$bumptransform
with the TextureScroll proxy to move the normal map.$dudvframe <int>
$bumpframe <int>
- Frame to start the animated du/dv map and bump map on, respectively. Somewhat confusingly,
$bumpframe
affects$normalmap
, which should be pointing to a bump map. - Template:L4d2 add
Confirm:How much projected textures should tint the water?
- Template:P2 add
- Todo: What does this do exactly?
- Template:P2 add
- Todo: What does this do exactly? Seems like it's related to $pseudotranslucent.
- Template:CSGO add
- Todo: What does this do exactly? Seems like it's related to $waterblendfactor, Found in liquids/nuke_water.vmt.
- Template:CSGO add
- Todo: What does this do exactly? Found in liquids/nuke_water.vmt.
- Template:CSGO add
- Disable fresnel on the water. Todo: Check if this does anything, as it's commented out in liquids/nuke_water.vmt, and isn't used anywhere else so far.
- Template:CSGO add
- Force this amount of fresnel on the water. Todo: Check if this does anything, as it's commented out in liquids/nuke_water.vmt, and isn't used anywhere else so far.
Fog
$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.
- Template:L4d2 add
- Allows the fog to receive lightmaps, so that static objects can cast shadows onto the water. Must be enabled when the map is compiled.
$fogenable <bool>
- 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.
Warning:Must be
0
for edge fading to work properly.
Reflection/Refraction
- Template:P2 add
- Forces the water to use $envmap for reflections.
$envmap <env_cubemap / texture>
- Provides reflections for cheap water. See
$envmap
$forcecheap <bool>
- 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. $forceexpensive <bool>
- This forces the water to render itself as expensive, regardless of the map's water_lod_control or the user's settings.
- Template:P2 add
- Makes this water reflect the skybox material in addition to other reflections.
- Template:L4d2 add
- Makes this water reflect the skybox only.
- Template:P2 add
- Whether or not to reflect only entities and static props with "Render in Fast Reflections" on.
$reflectamount <float>
- This is the amount of warp for the reflection. Higher values produce more visible reflections.
$reflectentities <bool>
- Make the water reflect entities. By default, no entities are reflected.
$reflecttexture <texture>
- Texture to use for reflection. For real-time reflections, use
_rt_WaterReflection
. Tip:Specify
$refracttexture
without$reflecttexture
to get real-time refraction on$envmap
reflections.$reflecttint <RGB matrix>
- This is the color tint for the real-time reflection and environment map.
- Template:L4d2 add
- Whether the material should refract at all.
$refractamount <float>
- This is the amount of warp for the refraction. Higher values produce more warping.
$refracttexture <texture>
- Texture to use for refraction. For real-time refractions, use
_rt_WaterRefraction
. Tip:Specify
$refracttexture
without$reflecttexture
to get real-time refraction on$envmap
reflections.$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.
Flowing water
- Template:EP2 add
- Template:EP2 add
- If
$scroll1
is 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.)
Flowmaps
Template:MatVar Template:MatVar Template:MatVar Template:MatVar Template:MatVar Template:MatVar Template:MatVar Template:MatVar Template:MatVar Template:MatVar
Basetexture Flow
- Template:P2 add
- Used to create the floating debris and sludge inside test chambers.
Template:MatVar Template:MatVar Template:MatVar Template:MatVar
- Todo: Better explanation
Authoring a flow map
Overall, trying to create a flow map manually is a nightmare. Painting the flowmap, fitting it into the world, and painting foam, is extremely difficult.
But if you do want to give it a try, flow direction is read from the red and green channels of the flow map. 50% tone means no movement.
The texture scale of any faces using a water texture with a flow map appear to have a direct correlation on the flow map. The fewer water faces or planes you use the easier the process of authoring a custom flow map will be (selecting all of your water faces and using 'treat as one' when using the fit scaling may also be an option)
- Red channel
- X axis
- Green channel
- Y axis
- Alpha channel
- In Portal 2, Controls basetexture blend (water/sludge)
- There are now tools to assist in painting flowmaps.
- Flow field editor from algoholic.eu : http://algoholic.eu/another-flow-field-editor-update/
- Flowmap generator (paid): http://www.superpositiongames.com/products/flowmap-generator
- Creating flowmaps using Houdini (UDK) : https://www.dropbox.com/s/ii2x077vj64lyhl/Water%20Flow%20For%20UDK.pdf
Other
%compilewater <bool>
- This is needed to make a map using the material compile properly.
$surfaceprop water
- Tells the physics system that the surface is water. See $surfaceprop.
%tooltexture <texture>
- Defines the texture Hammer will display in the material browser.
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.
See also
- Adding Water (in Hammer)
- Creating a Waterfall Material
- Making a wall of water
- True reflections under CSS (French)