Water (shader): Difference between revisions
ShiroDkxtro2 (talk | contribs) m (Reformatted $BaseTexture and added some ( but not all ) of its caveats) |
ShiroDkxtro2 (talk | contribs) m (Modified note of $fogenable, it is in fact handled outside of the shader itself.) |
||
Line 50: | Line 50: | ||
{{MatParam|$fogenable|bool|Enable volumetric fog for the water.<br> | {{MatParam|$fogenable|bool|Enable volumetric fog for the water.<br> | ||
{{note| | {{note|This parameter does not exist on the shader itself, the logic behind it is handled somewhere else.}}}} | ||
{{MatParam|$fogcolor|RGB matrix|Color of the water’s volumetric fog. Generally this value should match the color used in the bottom material.<br> | {{MatParam|$fogcolor|RGB matrix|Color of the water’s volumetric fog. Generally this value should match the color used in the bottom material.<br> | ||
{{Important| If this parameter is not defined in a VMT, the shader will force its value to <code>"[1 0 0]"</code> and spew an error message saying <code>Material x needs to have a $fogcolor.</code>}} | {{Important| If this parameter is not defined in a VMT, the shader will force its value to <code>"[1 0 0]"</code> and spew an error message saying <code>Material x needs to have a $fogcolor.</code>}} |
Revision as of 20:14, 19 October 2023
Water
is a Pixel shader available in all Source games. It creates water that realistically reflects and refracts the world, and that can 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_cubemap entities throughout a map.- 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 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
$abovewater
$bottommaterial
$underwateroverlay
$bumpmap
$normalmap
$dudvframe
$bumpframe
$bumptransform
$scale
$flashlighttint
$waterdepth
$depth_feather
Fog
$fogstart
$fogend
$lightmapwaterfog
Reflection
$reflecttexture
$reflectamount
$reflecttint
$envmap
$envmapframe
$forceenvmap
$forcecheap
$forceexpensive
$cheapwaterstartdistance
$cheapwaterenddistance
$reflectentities
$reflectonlymarkedentities
$reflectskyboxonly
$reflect2dskybox
$reflect3dskybox
$reflectblendfactor
$nofresnel
$forcefresnel
$basereflectance
$maxreflectance
Refraction
$refract
$refracttexture
$refractamount
$refracttint
$blurrefract
$pseudotranslucent
$waterblendfactor
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.)
Flow maps
$flowmap
$flow_normaluvscale
$flow_worlduvscale
$flow_uvscrolldistance
$flow_timeintervalinseconds
$flow_timescale
$flow_bumpstrength
$flow_noise_texture
$flow_noise_scale
$flow_debug
Basetexture Flow
$basetexture
$color_flow_uvscale
$color_flow_timescale
$color_flow_timeintervalinseconds
$color_flow_uvscrolldistance
$color_flow_lerpexp
$color_flow_displacebynormalstrength
Authoring a flow map
Overall, trying to create a flow map manually is a nightmare. Painting the flow map, 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/ [dead link]
- 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 [dead link]
Other
%compilewater
$surfaceprop
%tooltexture
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)