Water (shader): Difference between revisions
m (Fixed another link) |
Deprecated (talk | contribs) (Major rewrite/reordering, documented $bumptransform, $envmapframe, $cheapwaterstart/enddistance, $blurrefract, $color_flow_timescale, documented what $pseudotranslucent & $waterblendfactor do, $forcefresnel & basetexture flow are in AS, many other changes) |
||
Line 1: | Line 1: | ||
[[File:Ep2 jalopy.jpg|thumb|200px|Water [[#Reflection/Refraction|reflecting]] entities in real-time in [[Episode Two]].]] | |||
[[File:L4d2 flowmap user.jpg|thumb|200px|[[Left 4 Dead 2]] introduced [[#Flowing water|flowing water]].]] | [[File:L4d2 flowmap user.jpg|thumb|200px|[[Left 4 Dead 2]] introduced [[#Flowing water|flowing water]].]] | ||
'''<code>Water</code>''' is | '''<code>Water</code>''' is a [[material]] [[shader]] used for water. Water in Source is complex, and can be animated, refract and reflect the world in real-time, and flow throughout a map. | ||
== Special behaviour == | == Special behaviour == | ||
Line 17: | Line 17: | ||
=== Textures === | === Textures === | ||
{{note|In | {{note|In games before {{As}}, 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> | ||
: Whether this material is used for above or below the water’s surface. | : Whether this material is used for above or below the water’s surface. | ||
; <code>$bottommaterial <material></code> | ; <code>$bottommaterial <[[material]]></code> | ||
: Required field. This is the material ('''not''' texture) to use when underneath the water’s surface. The bottom material must have <code>$reflecttexture</code> and <code>$ | : Required field. This is the material ('''not''' texture) to use when underneath the water’s surface. The bottom material must have <code>$reflecttexture</code>, <code>$abovewater</code> and <code>$envmap</code> disabled, but can otherwise do whatever it wants. | ||
; | ; <code>$underwateroverlay <material></code> {{EP2 add}} | ||
: Applies a screen overlay when the camera is underwater. Generally used with <code>effects\water_warp01</code>. Requires <code>$abovewater</code> to be 0. | : Applies a refracting screen overlay when the camera is underwater. Generally used with <code>effects\water_warp01</code>. Requires <code>$abovewater</code> to be 0. | ||
; <code>[[Du/dv_map|$bumpmap]] <texture></code> | ; <code>[[Du/dv_map|$bumpmap]] <[[texture]]></code> | ||
; <code>[[normalmap|$normalmap]] <texture></code> | ; <code>[[normalmap|$normalmap]] <texture></code> | ||
: A [[Du/dv map]] for DirectX 8 rendering (<code>$bumpmap</code>), and a [[bump map]] for DirectX 9 and above (<code>$normalmap</code>). These should be animated unless the water is to be perfectly still. | : A [[Du/dv map]] for DirectX 8 rendering (<code>$bumpmap</code>), and a [[bump map]] for DirectX 9 and above (<code>$normalmap</code>). These should be animated unless the water is to be perfectly still or you're using a flowmap, which makes an animated bump map redundant. | ||
: {{note|The <code>[[normalmap|$normalmap]]</code> command is unique to the <code>Water</code> shader, and uses a [[normalmap|normal map]]. | : {{note|The <code>[[normalmap|$normalmap]]</code> command is unique to the <code>Water</code> shader, and uses a [[normalmap|normal map]]. A [[Du/dv_map|du/dv map]] is used for <code>[[$bumpmap]]</code> when using the <code>Water</code> shader. The <code>[[Du/dv_map|$dudvmap]]</code> command is obsolete.}} {{tip|Use <code>$bumptransform</code> with the [[TextureScroll]] proxy to move the normal map in pre-2006 engine branches.}} | ||
; <code>$dudvframe <[[int]]></code> | ; <code>$dudvframe <[[int]]></code> | ||
; <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]]. | ||
; {{ | ; <code>$bumptransform <[[matrix]]></code> | ||
: Transforms the bump map texture. | |||
{{VMT UVtransform}} | |||
; <code>$scale <vector2></code> | |||
: {{todo|What does this do?}} | |||
; <code>$flashlighttint <[[float]]></code> {{l4d2 add}} | |||
: {{confirm|How much projected textures should tint the water?}} | : {{confirm|How much projected textures should tint the water?}} | ||
; | ; <code>$waterdepth <float></code> {{CSGO add}} | ||
: {{todo|What does this do exactly? Seems like it's related to $waterblendfactor, Found in liquids/nuke_water.vmt. Found in 2006/2007 code, does it do anything there?}} | |||
; <code>$depth_feather <int></code> {{CSGO add}} | |||
: {{todo|What does this do exactly? Seems like it's related to $waterblendfactor, Found in liquids/nuke_water.vmt.}} | |||
; | |||
: {{todo|What does this do exactly? Found in liquids/nuke_water.vmt.}} | : {{todo|What does this do exactly? Found in liquids/nuke_water.vmt.}} | ||
=== Fog === | === Fog === | ||
; <code>$fogcolor <[[RGB]] matrix></code> | ; <code>$fogcolor <[[RGB]] matrix></code> | ||
: | : Color of the water’s volumetric fog. Generally this value should match the color used in the bottom material. | ||
; {{ | ; <code>$fogenable <bool></code> | ||
: Enable volumetric fog for the water. | |||
; <code>$fogstart <float></code> | |||
: Distance in inches from the eye at which water fog starts. | |||
: {{warning|Must be 0 for edge fading to work properly.}} | |||
; <code>$fogend <float></code> | |||
: Distance in inches from the eye at which water fog ends. | |||
; <code>$lightmapwaterfog <[[bool]]></code> {{l4d2 add}} | |||
: Allows the fog to receive [[lightmap]]s, so that static objects can cast shadows onto the water. Must be enabled when the map is compiled. | : Allows the fog to receive [[lightmap]]s, so that static objects can cast shadows onto the water. Must be enabled when the map is compiled. | ||
=== Reflection | === Reflection === | ||
; | ; <code>$reflecttexture <texture></code> | ||
: | : Texture to use for reflection. For real-time reflections, use <code>[[_rt_WaterReflection]]</code>. | ||
; <code>$envmap <[[env_cubemap]] / [[texture]]></code> | ; <code>$envmap <[[env_cubemap]] / [[texture]]></code> | ||
: See <code>[[$envmap]]</code>. Provides reflections for cheap water. | : See <code>[[$envmap]]</code>. Provides reflections for cheap water. | ||
; <code>$forcecheap < | : {{Note|Don't use this on underwater materials.}} | ||
: | ; <code>$envmapframe <int></code> | ||
; <code>$forceexpensive < | : The frame to start an animated cubemap on. | ||
: | ; <code>$forceenvmap <bool></code> {{p2 add}} | ||
; | : Forces the water to use <code>$envmap</code> for reflections. | ||
: | ; <code>$forcecheap <bool></code> | ||
; | : Force the water to render itself as [[cheap]], regardless of the map's {{ent|water_lod_control}} entity settings or the user's settings. This will disable real-time reflection and instead use <code>$envmap</code>. Refraction is assumed to be opaquely the water fog color. | ||
: Added | ; <code>$forceexpensive <bool></code> | ||
: Force the water to render itself as [[expensive]], regardless of the map's <code>water_lod_control</code> entity settings or the user's settings. | |||
; <code>$cheapwaterstartdistance <float></code> | |||
; | : Distance from the eye in inches that the shader should start transitioning to a cheaper water shader. | ||
: | ; <code>$cheapwaterenddistance <float></code> | ||
: Distance from the eye in inches that the shader should finish transitioning to a cheaper water shader. | |||
; <code>$reflect2dskybox</code> <bool> {{p2 add}} | |||
; <code>$reflectentities < | : Make the water reflect the [[skybox]] material ''in addition'' to other reflections. | ||
; <code>$reflect3dskybox</code> <bool> {{CSGO add}} | |||
: Make the water reflect the 3D skybox in addition to other reflections. Added in the Danger Zone update and used on ''dz_blacksite.'' | |||
: {{Note|Requires a {{ent|sky_camera}} entity to be placed in the map, otherwise this might cause crashes.}} | |||
; <code>$reflectskyboxonly <bool></code> {{l4d2 add}} | |||
: Make the water reflect only the [[skybox]]. | |||
; <code>$reflectentities <bool></code> | |||
: Make the water reflect entities. By default, no entities are reflected. | : Make the water reflect entities. By default, no entities are reflected. | ||
; <code>$ | ; <code>$reflectonlymarkedentities <bool></code> {{p2 add}} | ||
: | : Make the water reflect only entities and static props with "Render in Fast Reflections" enabled. | ||
; <code>$reflectamount <float></code> | |||
: Amount of warp for the reflection. Higher values produce more visible reflections. | |||
; <code>$reflecttint <[[RGB]] matrix></code> | ; <code>$reflecttint <[[RGB]] matrix></code> | ||
: | : Color tint for the real-time reflection and environment map. | ||
; {{ | ; <code>$reflectblendfactor <float></code> | ||
: {{todo|What does this do?}} | |||
; <code>$nofresnel <bool></code> {{EP1 add}} | |||
: Disable the fresnel on the water's reflection. | |||
: {{Bug|Does not do anything in any engine branch.}} | |||
; <code>$forcefresnel <float></code> {{AS add}} | |||
: Force this amount of fresnel on the water. Higher values usually cause the water to appear brighter. {{bug|Does not work properly in {{insurgency}}{{doi}}.}} | |||
; <code>$basereflectance <float></code> | |||
: {{todo|What is this?}} | |||
; <code>$maxreflectance <float></code> | |||
: {{todo|What is this?}} | |||
===Refraction=== | |||
; <code>$refract <bool></code> {{l4d2 add}} | |||
: Whether the material should refract at all. | : Whether the material should refract at all. | ||
; <code>$refractamount < | ; <code>$refractamount <float></code> | ||
: | : Amount of warp for the refraction. Higher values produce more warping. | ||
; <code>$refracttexture < | ; <code>$refracttexture <texture></code> | ||
: Texture to use for refraction. For real-time refractions, use <code>[[_rt_WaterRefraction]]</code>. | : Texture to use for refraction. For real-time refractions, use <code>[[_rt_WaterRefraction]]</code>. | ||
: {{tip|Specify <code>$refracttexture</code> without <code>$reflecttexture</code> to get real-time refraction on <code>$envmap</code> reflections.}} | : {{tip|Specify <code>$refracttexture</code> without <code>$reflecttexture</code> to get real-time refraction on <code>$envmap</code> reflections.}} | ||
; <code>$refracttint <[[RGB]] matrix></code> | ; <code>$refracttint <[[RGB]] matrix></code> | ||
: | : 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.}} | : {{warning|It is recommended that you set this to white or something close to white so that edge transitions work properly on DX9.}} | ||
; <code>$ | ; <code>$blurrefract <bool></code> {{EP2 add}} {{dx9}} | ||
: {{ | : Applies a blur to the refraction when underwater. | ||
; <code>$ | : {{warning|Underwater materials only; this will cause buggy behavior on any material with <code>$abovewater</code> set to 1.}} | ||
; <code>$pseudotranslucent <bool></code> {{p2 add}} | |||
: Make the water translucent. This is a cheap substitute for refractive water; do not use this when refraction is enabled. | |||
; <code>$waterblendfactor <[[normal]]></code> {{p2 add}} | |||
: How translucent the water should be when <code>$pseudotranslucent</code> is enabled. At 0, the water is completely transparent, while at 1 the water is completely opaque. | |||
; [[Image:Orange Box Scrolling Water.png|right|300px|Size/angle of $scroll1 and $scroll2]] | |||
=== Flowing water === | === Flowing water === | ||
; <code>$scroll1 "[<[[normal]] X> <normal Y>]"</code> {{EP1 add}} | |||
; | ; <code>$scroll2 "[<[[normal]] X> <normal Y>]"</code> {{EP1 add}} | ||
; | |||
: If <code>$scroll1</code> 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.) | : If <code>$scroll1</code> 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 ==== | ==== Flowmaps ==== | ||
[[File:L4d2 flowmap tex.jpg|right|200px|A flowmap texture.]] [[File:L4d2 flowmap dev.jpg|right|200px|The flowmap texture in-engine, shown with $flow_debug 1.]] [[File:L4d2 flowmap user.jpg|right|200px|The result in-engine.]] | |||
; <code>$flowmap <texture></code> {{l4d2 add}} | |||
: [http://www.youtube.com/watch?v=iY6vkpQDcpU | : Texture that defines flow velocity by skewing and scrolling the <code>$normalmap</code>. Valve generates their flowmaps with [http://www.sidefx.com/index.php?option=com_content&task=view&id=1774&Itemid=343 Houdini] | ||
}} | : [http://www.youtube.com/watch?v=iY6vkpQDcpU Video of the effect.] For technical details, see [https://steamcdn-a.akamaihd.net/apps/valve/2010/siggraph2010_vlachos_waterflow.pdf Alex Vlachos' SIGGRAPH 2010 paper] and [https://steamcdn-a.akamaihd.net/apps/valve/2011/gdc_2011_grimes_nonstandard_textures.pdf Valve's GDC 2011 paper]. | ||
; <code>$flow_normaluvscale <float></code> {{l4d2 add}} | |||
: The number of world units covered by the normal map before it repeats. Typically in the 100s. | |||
; <code>$flow_worlduvscale <float></code> {{l4d2 add}} | |||
: The number of times the flow map fits into the material. Face texture scale affects this. | |||
; <code>$flow_uvscrolldistance <float></code> {{l4d2 add}} | |||
: How far along the flow map the normal map should be distorted. Higher values lead to more distortion. | |||
; <code>$flow_timeintervalinseconds <float></code> {{l4d2 add}} | |||
: Time needed for the normal map to cross the <code>$flow_uvscrolldistance</code>. | |||
; <code>$flow_timescale <float></code> {{l4d2 add}} | |||
: Modifies flow speed without affecting the amount of distortion. | |||
; <code>$flow_bumpstrength <normal></code> {{l4d2 add}} | |||
: How rough the surface of the water is. | |||
; <code>$flow_noise_texture <texture></code> {{l4d2 add}} | |||
: A treatment texture used to break up repetition of the normal map. | |||
; <code>$flow_noise_scale <float></code> {{l4d2 add}} | |||
: How many times to fit the noise texture into the normal map. Typically around 0.01. | |||
; <code>$flow_debug <bool></code> {{l4d2 add}} | |||
: Replaces the water surface with a literal rendering of the flow map. {{bug|Although the flow map will show up in Hammer, it may not be in the correct place! Don't rely on Hammer's view for alignment.}} | |||
==== Basetexture Flow ==== | ==== Basetexture Flow ==== | ||
; | ; <code>$basetexture <texture></code> {{AS add}} | ||
: | : A "sludge layer", used in {{portal2}} for the sludge in the test chambers. The alpha channel of the <code>$basetexture</code> controls the strength of the reflection; darker values are more reflective, while lighter values are less reflective. | ||
; <code>$color_flow_uvscale <float></code> {{AS add}} | |||
: The number of world units covered by the base texture before it repeats. Typically in the 100s. | |||
; <code>$color_flow_timescale <float></code> {{AS add}} | |||
: Modifies flow speed without affecting the amount of distortion. | |||
; <code>$color_flow_timeintervalinseconds <float></code> {{AS add}} | |||
:{{todo|Better explanation}} | : Time needed for the base texture to cross the <code>$color_flow_uvscrolldistance</code>. | ||
; <code>$color_flow_uvscrolldistance <float></code> {{AS add}} | |||
: How far along the flow map the base texture should be distorted. Higher values lead to more distortion. | |||
; <code>$color_flow_lerpexp <float></code> {{AS add}} | |||
: How sharp the transition should be between repeats, should be 1. | |||
: {{todo|Better explanation}} | |||
; <code>$color_flow_displacebynormalstrength <float></code> {{p2 add}} | |||
: How much the normal map affects the base texture. Uses extremely low values, usually 0.01 or less. | |||
==== Authoring a flow map ==== | ==== Authoring a flow map ==== | ||
Line 152: | Line 185: | ||
: Y axis | : Y axis | ||
; Alpha channel | ; Alpha channel | ||
: | : Controls $basetexture blend from {{portal2}} onwards. | ||
;There are now tools to assist in painting flowmaps. | ; There are now tools to assist in painting flowmaps. | ||
:Flow field editor from algoholic.eu : http://algoholic.eu/another-flow-field-editor-update/ | : Flow field editor from algoholic.eu : http://algoholic.eu/another-flow-field-editor-update/ | ||
:Flowmap generator (paid): http://www.superpositiongames.com/products/flowmap-generator | : 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 | : Creating flowmaps using Houdini (UDK) : https://www.dropbox.com/s/ii2x077vj64lyhl/Water%20Flow%20For%20UDK.pdf | ||
=== Other === | === Other === |
Revision as of 11:58, 20 May 2019
Water
is a material shader used for water. Water in Source is complex, and can be animated, refract and reflect the world in real-time, and flow throughout a map.
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
,$abovewater
and$envmap
disabled, but can otherwise do whatever it wants. $underwateroverlay <material>
Template:EP2 add- Applies a refracting 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 or you're using a flowmap, which makes an animated bump map redundant. 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 in pre-2006 engine branches.$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. $bumptransform <matrix>
- Transforms the bump map texture.
- The default position is center .5 .5 scale 1 1 rotate 0 translate 0 0.
- center defines the point of rotation. Only useful if rotate is being used.
- scale fits the texture into the material the given number of times. 2 1 is a 50% scale in the horizontal X axis while the vertical Y axis is still at original scale.
- rotate rotates the texture counter-clockwise in degrees. Accepts any number, including negatives.
- translate shifts the texture by the given numbers. .5 will shift it half-way. 1 will shift it once completely over, which is the same as not moving it at all.
Note:All values must be included!
Bug:Scaling the texture may cause odd issues where the Texture Lock tool in Hammer will not actually lock the texture in place. [todo tested in ?]
Bug:Rotating textures applied on brushes will rotate around the map origin (confirm: Orangebox engine only?). A fix for this is to change the center position in the VMT to the brush's origin. [todo tested in ?]
$scale <vector2>
- Todo: What does this do?
$flashlighttint <float>
Template:L4d2 addConfirm:How much projected textures should tint the water?
$waterdepth <float>
Template:CSGO add- Todo: What does this do exactly? Seems like it's related to $waterblendfactor, Found in liquids/nuke_water.vmt. Found in 2006/2007 code, does it do anything there?
$depth_feather <int>
Template:CSGO add- Todo: What does this do exactly? Found in liquids/nuke_water.vmt.
Fog
$fogcolor <RGB matrix>
- Color of the water’s volumetric fog. Generally this value should match the color used in the bottom material.
$fogenable <bool>
- Enable volumetric fog for the water.
$fogstart <float>
- Distance in inches from the eye at which water fog starts.
Warning:Must be 0 for edge fading to work properly.
$fogend <float>
- Distance in inches from the eye at which water fog ends.
$lightmapwaterfog <bool>
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.
Reflection
$reflecttexture <texture>
- Texture to use for reflection. For real-time reflections, use
_rt_WaterReflection
. $envmap <env_cubemap / texture>
- See
$envmap
. Provides reflections for cheap water. Note:Don't use this on underwater materials.
$envmapframe <int>
- The frame to start an animated cubemap on.
$forceenvmap <bool>
Template:P2 add- Forces the water to use
$envmap
for reflections. $forcecheap <bool>
- Force the water to render itself as cheap, regardless of the map's water_lod_control entity settings or the 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>
- Force the water to render itself as expensive, regardless of the map's
water_lod_control
entity settings or the user's settings. $cheapwaterstartdistance <float>
- Distance from the eye in inches that the shader should start transitioning to a cheaper water shader.
$cheapwaterenddistance <float>
- Distance from the eye in inches that the shader should finish transitioning to a cheaper water shader.
$reflect2dskybox
<bool> Template:P2 add- Make the water reflect the skybox material in addition to other reflections.
$reflect3dskybox
<bool> Template:CSGO add- Make the water reflect the 3D skybox in addition to other reflections. Added in the Danger Zone update and used on dz_blacksite.
Note:Requires a sky_camera entity to be placed in the map, otherwise this might cause crashes.
$reflectskyboxonly <bool>
Template:L4d2 add- Make the water reflect only the skybox.
$reflectentities <bool>
- Make the water reflect entities. By default, no entities are reflected.
$reflectonlymarkedentities <bool>
Template:P2 add- Make the water reflect only entities and static props with "Render in Fast Reflections" enabled.
$reflectamount <float>
- Amount of warp for the reflection. Higher values produce more visible reflections.
$reflecttint <RGB matrix>
- Color tint for the real-time reflection and environment map.
$reflectblendfactor <float>
- Todo: What does this do?
$nofresnel <bool>
(in all games since)
- Disable the fresnel on the water's reflection.
Bug:Does not do anything in any engine branch. [todo tested in ?]
$forcefresnel <float>
Template:AS add- Force this amount of fresnel on the water. Higher values usually cause the water to appear brighter.
Bug:Does not work properly in
. [todo tested in ?]
$basereflectance <float>
- Todo: What is this?
$maxreflectance <float>
- Todo: What is this?
Refraction
$refract <bool>
Template:L4d2 add- Whether the material should refract at all.
$refractamount <float>
- 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>
- 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.
$blurrefract <bool>
Template:EP2 add (DX9 SM2)- Applies a blur to the refraction when underwater.
Warning:Underwater materials only; this will cause buggy behavior on any material with
$abovewater
set to 1.$pseudotranslucent <bool>
Template:P2 add- Make the water translucent. This is a cheap substitute for refractive water; do not use this when refraction is enabled.
$waterblendfactor <normal>
Template:P2 add- How translucent the water should be when
$pseudotranslucent
is enabled. At 0, the water is completely transparent, while at 1 the water is completely opaque.
Flowing water
$scroll1 "[<normal X> <normal Y>]"
(in all games since)
$scroll2 "[<normal X> <normal Y>]"
(in all games since)
- 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
$flowmap <texture>
Template:L4d2 add- Texture that defines flow velocity by skewing and scrolling the
$normalmap
. Valve generates their flowmaps with Houdini - Video of the effect. For technical details, see Alex Vlachos' SIGGRAPH 2010 paper and Valve's GDC 2011 paper.
$flow_normaluvscale <float>
Template:L4d2 add- The number of world units covered by the normal map before it repeats. Typically in the 100s.
$flow_worlduvscale <float>
Template:L4d2 add- The number of times the flow map fits into the material. Face texture scale affects this.
$flow_uvscrolldistance <float>
Template:L4d2 add- How far along the flow map the normal map should be distorted. Higher values lead to more distortion.
$flow_timeintervalinseconds <float>
Template:L4d2 add- Time needed for the normal map to cross the
$flow_uvscrolldistance
. $flow_timescale <float>
Template:L4d2 add- Modifies flow speed without affecting the amount of distortion.
$flow_bumpstrength <normal>
Template:L4d2 add- How rough the surface of the water is.
$flow_noise_texture <texture>
Template:L4d2 add- A treatment texture used to break up repetition of the normal map.
$flow_noise_scale <float>
Template:L4d2 add- How many times to fit the noise texture into the normal map. Typically around 0.01.
$flow_debug <bool>
Template:L4d2 add- Replaces the water surface with a literal rendering of the flow map.
Bug:Although the flow map will show up in Hammer, it may not be in the correct place! Don't rely on Hammer's view for alignment. [todo tested in ?]
Basetexture Flow
$basetexture <texture>
Template:AS add- A "sludge layer", used in
for the sludge in the test chambers. The alpha channel of the
$basetexture
controls the strength of the reflection; darker values are more reflective, while lighter values are less reflective. $color_flow_uvscale <float>
Template:AS add- The number of world units covered by the base texture before it repeats. Typically in the 100s.
$color_flow_timescale <float>
Template:AS add- Modifies flow speed without affecting the amount of distortion.
$color_flow_timeintervalinseconds <float>
Template:AS add- Time needed for the base texture to cross the
$color_flow_uvscrolldistance
. $color_flow_uvscrolldistance <float>
Template:AS add- How far along the flow map the base texture should be distorted. Higher values lead to more distortion.
$color_flow_lerpexp <float>
Template:AS add- How sharp the transition should be between repeats, should be 1.
- Todo: Better explanation
$color_flow_displacebynormalstrength <float>
Template:P2 add- How much the normal map affects the base texture. Uses extremely low values, usually 0.01 or less.
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)
- 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)