Liquid materials: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{stub}}
{{stub}}
{{LanguageBar|title = Water (shader)}}
{{LanguageBar|title = Water (shader)}}
[[Water]] does not ''need'' to use the {{mono|Water}} shader! If a less realistic effect is desired, or the water volume is oddly shaped, other shaders can be used, such as [[LightmappedGeneric]] or [[Refract]]. The method for creating the materials is the same.
[[Water]] does not ''need'' to use the {{mono|Water}} shader! If a less realistic effect is desired, or the water volume is oddly shaped, other shaders can be used, such as [[LightmappedGeneric]] or [[Refract]]. The method for creating the materials is the same. Liquids using using any shader other than Water will always be considered cheap.


== Parameters ==
== Parameters ==


{{MatParam|%CompileWater|bool|This is needed to make a map using the material compile properly.}}
{{MatParamDef|%CompileWater|bool|This is needed to make a map using the material compile properly.}}
{{MatParam|%CompileSlime|bool|Can be used instead of %CompileWater to get different particles.  
{{MatParamDef|%CompileSlime|bool|Can be used instead of %CompileWater to get different particles. Planar reflections don't work with this, due to not applying [[Surface flag|SURF_WARP]].}}
{{important|Planar reflections doesn't work with this.}}
}}


{{MatParam|$abovewater|bool|Whether this material is used for above or below the water’s surface.<br>
{{MatParamDef|$abovewater|bool|Whether this material is used for above or below the water’s surface.<br>
{{note|Not setting this in the VMT will automatically force it to 1. If not defined, a warning will appear saying <code>Need to set $abovewater for material x</code>}}}}
{{note|Not setting this in the VMT will automatically force it to 1. If not defined, a warning will appear saying <code>Need to set $abovewater for material x</code>}}}}
{{MatParam|$bottommaterial|material|Required parameter. 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. {{tip|Add {{cmd|%notooltexture}} to the bottom material to hide it in the texture browser {{hammer++|not}}.}} }}
{{MatParamDef|$bottommaterial|material|Required parameter. 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. {{tip|Add {{cmd|%notooltexture}} to the bottom material to hide it in the texture browser {{hammer++|not}}.}} }}
{{note|If the above water material does not have reflections, refractions, or $underwateroverlay: $abovewater can be omitted, [[$nocull]] can be used, and $bottommaterial can be set to the same material as the abovewater material.}}
{{note|If the above water material does not have reflections, refractions, or $underwateroverlay: $abovewater can be omitted, [[$nocull]] can be used, and $bottommaterial can be set to the same material as the abovewater material.}}
{{MatParam|$underwateroverlay|material|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.<br>
{{MatParamDef|$underwateroverlay|material|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.<br>
{{note|This is technically not a parameter on the water shader, meaning it can be abused for other unintended purposes! The overlay may still be applied even when the underwater material is told not to render ( {{ent|$no_draw}})}}|since={{src07}}}}
{{note|This is technically not a parameter on the water shader, meaning it can be abused for other unintended purposes! The overlay may still be applied even when the underwater material is told not to render ( {{ent|$no_draw}})}}|since={{src07}}}}


=== Fog ===
=== Fog ===


{{MatParam|$fogenable|bool|Enable volumetric fog for the water.<br>
{{MatParamDef|$fogenable|bool|Enable volumetric fog for the water. Note that the [[Water (Shader)|Water]] shader will always have fog regardless of this parameter, but $fogstart and $fogend will not work without it. Optional for all other shaders.}}
{{note|This parameter does not exist on the shader itself, the logic behind it is handled somewhere else.}}}}
{{MatParamDef|$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>}}
{{warning|
{{warning|
Line 29: Line 26:
To calculate the eventual linear value that the shader is supplied with, apply the formula <code>x^(1/2.2)</code>{{tip|While expensive water cannot, cheap water ''can'' go higher than 1.0, achieving a more "neon" effect.}} }}}}
To calculate the eventual linear value that the shader is supplied with, apply the formula <code>x^(1/2.2)</code>{{tip|While expensive water cannot, cheap water ''can'' go higher than 1.0, achieving a more "neon" effect.}} }}}}


{{MatParam|$fogstart|float|Distance in units/inches from the eye at which water fog starts.
{{MatParamDef|$fogstart|float|Distance in units/inches from the eye at which water fog starts.
: {{warning|Must be 0 for edge fading to work properly.}}}}
: {{warning|Must be 0 for edge fading to work properly.}}}}
{{MatParam|$fogend|float|Distance in units/inches from the eye at which water fog ends.}}
{{MatParamDef|$fogend|float|Distance in units/inches from the eye at which water fog ends.}}


=== Other ===
=== Other ===
{{MatParam|$surfaceprop|water|Tells the physics system that the surface is water. See [[$surfaceprop]].}}
{{MatParamDef|$surfaceprop|water|Tells the physics system that the surface is water. See [[$surfaceprop]].}}
{{MatParam|%tooltexture|texture|Defines the texture Hammer will display in the material browser. Any texture can be used, but it is customary to use the [[$normalmap]].}}
{{MatParamDef|%tooltexture|texture|Defines the texture Hammer will display in the material browser. Any texture can be used, but it is customary to use the [[$normalmap]].}}
; <code>WaterLOD proxy</code>
; <code>WaterLOD proxy</code>
: 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.
: 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.


[[Category:Water]]
[[Category:Water]]

Latest revision as of 12:10, 23 August 2025

Stub

This article or section is a stub. You can help by expanding it.

English (en)Translate (Translate)

Water does not need to use the Water shader! If a less realistic effect is desired, or the water volume is oddly shaped, other shaders can be used, such as LightmappedGeneric or Refract. The method for creating the materials is the same. Liquids using using any shader other than Water will always be considered cheap.

Parameters

This is needed to make a map using the material compile properly.
Can be used instead of %CompileWater to get different particles. Planar reflections don't work with this, due to not applying SURF_WARP.
Whether this material is used for above or below the water’s surface.
Note.pngNote:Not setting this in the VMT will automatically force it to 1. If not defined, a warning will appear saying Need to set $abovewater for material x
Required parameter. 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.
Tip.pngTip:Add %notooltexture to the bottom material to hide it in the texture browser (not in Hammer++).
Note.pngNote:If the above water material does not have reflections, refractions, or $underwateroverlay: $abovewater can be omitted, $nocull can be used, and $bottommaterial can be set to the same material as the abovewater material.
$underwateroverlay <material> (in all games since Source 2007)
Applies a refracting screen overlay when the camera is underwater. Generally used with effects\water_warp01. Requires $abovewater to be 0.
Note.pngNote:This is technically not a parameter on the water shader, meaning it can be abused for other unintended purposes! The overlay may still be applied even when the underwater material is told not to render ( $no_draw)

Fog

Enable volumetric fog for the water. Note that the Water shader will always have fog regardless of this parameter, but $fogstart and $fogend will not work without it. Optional for all other shaders.
Color of the water’s volumetric fog. Generally this value should match the color used in the bottom material.
Icon-Important.pngImportant: If this parameter is not defined in a VMT, the shader will force its value to "[1 0 0]" and spew an error message saying Material x needs to have a $fogcolor.
Warning.pngWarning:

Cheap water treats this parameters as a linear value where 0.0 is 0% and 1.0 is 100%.
Expensive water treats this parameter as a Gamma value,
and due do this, each component ( red, green and blue respectively ) can not go above 1.0 or below 0.0 ( on expensive water )

To calculate the eventual linear value that the shader is supplied with, apply the formula x^(1/2.2)
Tip.pngTip:While expensive water cannot, cheap water can go higher than 1.0, achieving a more "neon" effect.
Distance in units/inches from the eye at which water fog starts.
Warning.pngWarning:Must be 0 for edge fading to work properly.
Distance in units/inches from the eye at which water fog ends.

Other

Tells the physics system that the surface is water. See $surfaceprop.
Defines the texture Hammer will display in the material browser. Any texture can be used, but it is customary to use the $normalmap.
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.