User:DJFluXion/Making Your Own Water: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Saving.)
 
Tag: New redirect
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
'''[[Water]]''' is one of the Source engine's most complex material types/shaders.
#redirect [[User:VectorFluxion/Making Your Own Water]]
 
Water does not have a <code>$basetexture</code> value by default, but rather, is made up of a real-time transforming [[normal map]], fog, a combination of reflection and refraction, a flow map (for dx90 users and below), and an [[env_cubemap]] to give the water surface a [[specular reflection]] effect.
 
Water in the Source engine, is composed of three different elements:
*A material for when the observer is above the water surface, facing down into it;
*A material for when the observer is beneath the water surface, looking upwards; and,
*A scrolling overlay screen effect that the observer sees when underwater.
 
=="Expensive" vs. "Cheap" Water==
 
==Generic VMT Files For Water==
[[File:TF2FlowMap.png|150px|thumb|The flow map used by TF2's water, for sub-dx90 users.]]
The general code for the three elements of water.
 
For color values, both RGB and HSV can be used. Use square brackets for denote a HSV value <code>"[H S V]"</code> and curly brackets to denote a RGB value <code>"{R G B}"</code>.
 
For sub-dx90 users, a flow map (pictured to the right) must be used, as this will be transformed instead of a normal map. A flow map is also called a du/dv map, a derivative map, and a movement map. The flow map will be specified using the <code>$bumpmap</code> material parameter. <code>$bumpmap</code> should only be used in [[fallback materials]], and specified in the main water file, using the <code><dx90</code> rule, with the <code>$fallbackmaterial</code> material parameter inside.
 
It is generally recommended to make a fallback material for water, as water can be a memory-hog on older computers.
 
===Above water material:===
 
<pre>
"Water"
{
"%compilewater" 1
"%keywords" "<string>"
"%tooltexture" "<path> relative to <game abbr>/materials/"
"$abovewater" 1
"$underwateroverlay" "<path> relative to <game abbr>/materials/"
"$refracttexture" "_rt_WaterRefraction"
"$refracttint" "<RGB>" or "<HSV>"
"$normalmap" "<path> relative to <game abbr>/materials/"
"$refractamount" <value>
"$envmap" "env_cubemap"
"$refractblur" 1
"$surfaceprop" water
"$bottommaterial" "<path> relative to <game abbr>/materials/"
"$scale" "[1 1]"
"$bumpframe" 0
"$fogenable" <bool>
"$fogcolor" "<RGB>" or "<HSV>"
"$fogstart" <value in HU>
"$fogend" <value in HU>
"$temp" "[0 0]"
"$curr" 0
"$curr2" 0
"Proxies"
{
"AnimatedTexture"
{
"animatedtexturevar" "$normalmap"
"animatedtextureframenumvar" "$bumpframe"
"animatedtextureframerate" 30
}
"TextureTransform"
{
"translatevar" "$temp"
"resultvar" "$bumptransform"
}
"Sine"
{
"sineperiod" 20
"sinemax" .6
"sinemin" -.6
"resultvar" "$curr"
}
"Sine"
{
"sineperiod" 15
"sinemax" -.6
"sinemin" .6
"resultvar" "$curr2"
}
"Equals"
{
"srcvar1" "$curr2"
"resultvar" "$temp[0]"
}
"Equals"
{
"srcvar1" "$curr"
"resultvar" "$temp[1]"
}
"WaterLOD"
{
"dummy" 0
}
}
}
</pre>
 
===Below water material:===
<pre>
"Water"
{
"%compilewater" 1
"%keywords" "<string>"
"%tooltexture" "<path> relative to <game abbr>/materials/"
"$abovewater" 0
"$cheapwaterstartdistance" <value in HU>
"$cheapwaterenddistance" <value in HU>
"$refractamount" <value>
"$reflectamount" 1
"$refracttint" "<RGB>" or "<HSV>"
"$reflecttint" "<RGB>" or "<HSV>"
"$refracttexture" "_rt_WaterRefraction"
"$scale" "[1 1]"
"$blurrefract" 1
"$normalmap" "<path> relative to <game abbr>/materials/"
"$underwateroverlay" "<path> relative to <game abbr>/materials/"
"$surfaceprop" "water"
"$bumpframe" 0
"$fogenable" <bool>
"$fogcolor" "<RGB>" or "<HSV>"
"$fogstart" <value in HU>
"$fogend" <value in HU>
"Proxies"
{
"AnimatedTexture"
{
"animatedtexturevar" "$normalmap"
"animatedtextureframenumvar" "$bumpframe"
"animatedtextureframerate" 30
}
"TextureScroll"
{
"texturescrollvar" "$bumptransform"
"texturescrollrate" .3
"texturescrollangle" 60
}
}
}
</pre>
 
===Screen distortion overlay effect:===
<pre>
"Refract"
{
"%keywords" "<string>"
"%tooltexture" "<path> relative to <game abbr>/materials/"
"$refractamount" <value>
"$refracttint" "<RGB>" or "<HSV>"
"$refractblur" <bool>
"$bluramount" <0, 1, 2>
"$ignorez" <bool>
"$scale" "[1 1]"
"$bumpmap" "<path> relative to <game abbr>/materials/"
"$normalmap" "<path> relative to <game abbr>/materials/"
"$bumpframe" 0
"Proxies"
{
"AnimatedTexture"
{
"animatedtexturevar" "$normalmap"
"animatedtextureframenumvar" "$bumpframe"
"animatedtextureframerate" 30
}
"TextureScroll"
{
"texturescrollvar" "$bumptransform"
"texturescrollrate" .2
"texturescrollangle" 45
}
}
}
</pre>
 
==See Also==
*[[Water]]
*[[Normal]] mapping

Latest revision as of 20:42, 7 November 2020