Difference between revisions of "$treeSway"

From Valve Developer Community
Jump to: navigation, search
m (linked to a tutorial on how to fake $treeSway)
($treesway rewrite)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<code>[[$treeSway]]</code> is a [[VMT]] command for <code>[[VertexLitGeneric]]</code> available in {{l4ds}}, {{as}}, {{portal2}}, {{csgo}}, {{insurgency}}, {{tf2}} (As of Jungle Inferno), {{bms}} (as of December 2017), {{GMOD}} (as of October 2018) that morphs a material around using the parameters of an <code>[[env_wind]]</code> entity. This is used in {{csgo}} and {{insurgency}} to give the appearance of tree leaves and foilage blowing in the wind. The paramaters of this command determine how much the <code>env_wind</code> entity should affect the morphing. This command assumes any model using it is facing upwards.
+
{{screenshot}}
{{note|In {{tf2}}, {{GMOD}}, does not require {{ent|env_wind}} if <code>$treeSwayStatic</code> is set to 1.}}
+
{{Shaderparam|$treesway|since=Left 4 Dead|shader1=VertexLitGeneric}} It morphs a material around using the parameters of an {{ent|env_wind}} entity to give the appearance of tree leaves and foilage blowing in the wind. The subparameters of <code>$treesway</code> determine how much the <code>env_wind</code> entity should affect the morphing, and all of them (except <code>$treeswaystatic</code>) must be specified in order for the effect to work properly. This shader parameter assumes any model using it is facing upwards.
 +
{{note|This shader parameter is also available in {{tf2}}, {{Bms}}, and {{GMOD}}. In {{GMOD}}, it can also be used for {{ent|UnlitGeneric}}.}}
 
{{note|This shader is disabled by default in the {{as}} SDK. It can re-enabled by modding.}}
 
{{note|This shader is disabled by default in the {{as}} SDK. It can re-enabled by modding.}}
{{bug|In {{GMOD}}, using a [[env_projectedtexture|projected texture]] on materials with this parameter will cause flickering. As a workaround, try to keep trees away from where player flashlights can reach. <code>[[$halflambert]]</code> may also partially fix the issue.}}
+
{{bug|In {{GMOD}}, using a [[env_projectedtexture|projected texture]] on materials with this parameter will cause flickering. As a workaround, try to keep trees away from where player flashlights can reach. {{ent|$halflambert}} may also partially fix the issue.}}
 +
: {{todo|What about <code>$singlepassflashlight</code> and <code>$flashlightnolambert</code>?}}
  
 
==Parameters==
 
==Parameters==
<pre>
 
$treeSway                        "0" "1" or "2"
 
//Changes the treesway effect. 0 is no sway, 1 is classic tree sway, 2 is an alternate, radial tree sway effect.
 
//Tree sway mode 2: Hacks to use tree sway code on rectangular sheets of plastic/tarp attached at the four corners.
 
//Inverts the sway scale radius to be 1 at (0,0,0) in model space and fall off radially towards the edges of the model.
 
//The model is expected to be built lying in the X Y plane in model space, with its center at the origin.
 
  
$treeSwayHeight                  "float"   //The height in which the effect is applied.
+
{{MatParam|$treesway|int|What option to use for the tree swaying effect.
$treeSwayStartHeight              "float"    //The height from the origin in which the effect starts blending in.
+
:*0: No Sway
$treeSwayRadius                  "float"    //The radius from the origin in which the effect is applied.
+
:*1: "Classic" tree sway.
$treeSwayStartRadius              "float"    //The radius from the origin in which the effect starts blending in.
+
:*2: Radial tree sway effect, intended for use on rectangular sheets of plastic/tarp attached at four corners. It inverts the sway scale radius to be 1 at (0,0,0) in model space and to fall off radially towards the edges of the model. {{note|Models using <code>$treesway 2</code> are expected to be built lying in the X Y plane in model space, with their center at the origin.}}}}
$treeSwaySpeed                    "float"    //The speed multiplier of large movement such as the trunk.
+
{{MatParam|$treeswayheight|float|The starting height in Hammer units where the effect should start being fully applied. Default 1000.}}
$treeSwayStrength                "float"    //The distance multiplier of large movement such as the trunk.
+
{{MatParam|$treeswaystartheight|float|The height from the model's origin in which the effect starts blending in. Default 0.2.}}
$treeSwayScrumbleSpeed            "float"    //The falloff of the effect on small movement such as the trunk. Higher means a more stable center.
+
{{MatParam|$treeswayradius|float|The radius from the model's origin in Hammer units in where the effect should start being fully applied. Default 300.}}
 
+
{{MatParam|$treeswaystartheight|float|The radius from the model's origin in which the effect starts blending in. Default 0.1.}}
$treeSwayScrumbleStrength        "float"    //The speed multiplier of the small movement such as the leaves.
+
{{MatParam|$treeswayspeed|float|The speed multiplier of large movement such as the trunk. Default 1.}}
$treeSwayScrumbleFrequency        "float"    //The distance multiplier of the small movement such as the leaves.
+
{{MatParam|$treeswaystrength|float|The distance multiplier of large movement such as the trunk. Default 10.}}
$treeSwayFalloffExp              "float"    //The frequency of the rippling of a sine wave in small movement such as the leaves.
+
{{MatParam|$treeswayscrumblespeed|float|The falloff of the effect on large movement such as the trunk. Higher means a more stable center. Default 0.1.}}
$treeSwayScrumbleFalloffExp      "float"    //The falloff of the effect on small movement such as the leaves. Higher means a more stable center.
+
{{MatParam|$treeswayscrumblestrength|float|The speed multiplier of the small movement such as the leaves. Default 0.1.}}
 
+
{{MatParam|$treeswayscrumblefrequency|float|The distance multiplier of the small movement such as the leaves. Default 0.1.}}
$treeSwaySpeedHighWindMultiplier  "float"    //Speed multiplier when env_wind triggers a gust.
+
{{MatParam|$treeswayfalloffexp|float|The frequency of the rippling of a sine wave in small movement such as the leaves. Default 1.5.}}
$treeSwaySpeedLerpStart          "float"    //Minimum wind speed in which a gust triggered by env_wind will start affecting the material.
+
{{MatParam|$treeswayscrumblefalloffexp|float|The falloff of the effect on small movement such as the leaves. Higher means a more stable center. Default 1.}}
$treeSwaySpeedLerpEnd            "float"    //Minimum wind speed in which a gust triggered by env_wind will fully affect the material.
+
{{MatParam|$treeswayspeedhighwindmultipler|float|Speed multiplier when <code>env_wind</code> triggers a gust. Default 2.}}
$treeSwayStatic                  "boolean"  //Whether or not to instead use a static wind value instead of the values from env_wind. TF2 and GMOD (as of April 2019) only.
+
{{MatParam|$treeswayspeedlerpstart|float|Minimum wind speed in which a gust triggered by <code>env_wind</code> will start affecting the material. Default 3.}}
</pre>
+
{{MatParam|$treeswayspeedlerpend|float|Minimum wind speed in which a gust triggered by <code>env_wind</code> will fully affect the material. Default 6.}}
 +
{{MatParam|$treeswaystatic|float|Use a static wind value instead of the values from <code>env_wind</code>. If enabled, <code>env_wind</code> is not required.|only=TF2|also=GMOD}}
  
 
[[Category:List of Shader Parameters|T]]
 
[[Category:List of Shader Parameters|T]]
  
 
== See Also ==
 
== See Also ==
https://gamebanana.com/tuts/12924 - How to achieve this effect without <code>$treeSway</code>, on all source engine games
+
https://gamebanana.com/tuts/12924 - How to achieve a similar effect without <code>$treeSway</code>, on all source engine games

Latest revision as of 01:23, 18 November 2019

$treesway is a material shader parameter available in all Source games since <Left 4 Dead> Left 4 Dead for VertexLitGeneric. It morphs a material around using the parameters of an env_wind entity to give the appearance of tree leaves and foilage blowing in the wind. The subparameters of $treesway determine how much the env_wind entity should affect the morphing, and all of them (except $treeswaystatic) must be specified in order for the effect to work properly. This shader parameter assumes any model using it is facing upwards.

Note:This shader parameter is also available in <Team Fortress 2>, <Black Mesa (Source)>, and <Garry's Mod>. In <Garry's Mod>, it can also be used for UnlitGeneric.
Note:This shader is disabled by default in the <Alien Swarm> SDK. It can re-enabled by modding.
Bug: In <Garry's Mod>, using a projected texture on materials with this parameter will cause flickering. As a workaround, try to keep trees away from where player flashlights can reach. $halflambert may also partially fix the issue.
To do: What about $singlepassflashlight and $flashlightnolambert?

Parameters

$treesway <integer>
What option to use for the tree swaying effect.
  • 0: No Sway
  • 1: "Classic" tree sway.
  • 2: Radial tree sway effect, intended for use on rectangular sheets of plastic/tarp attached at four corners. It inverts the sway scale radius to be 1 at (0,0,0) in model space and to fall off radially towards the edges of the model.
    Note:Models using $treesway 2 are expected to be built lying in the X Y plane in model space, with their center at the origin.
$treeswayheight <float>
The starting height in Hammer units where the effect should start being fully applied. Default 1000.
$treeswaystartheight <float>
The height from the model's origin in which the effect starts blending in. Default 0.2.
$treeswayradius <float>
The radius from the model's origin in Hammer units in where the effect should start being fully applied. Default 300.
$treeswaystartheight <float>
The radius from the model's origin in which the effect starts blending in. Default 0.1.
$treeswayspeed <float>
The speed multiplier of large movement such as the trunk. Default 1.
$treeswaystrength <float>
The distance multiplier of large movement such as the trunk. Default 10.
$treeswayscrumblespeed <float>
The falloff of the effect on large movement such as the trunk. Higher means a more stable center. Default 0.1.
$treeswayscrumblestrength <float>
The speed multiplier of the small movement such as the leaves. Default 0.1.
$treeswayscrumblefrequency <float>
The distance multiplier of the small movement such as the leaves. Default 0.1.
$treeswayfalloffexp <float>
The frequency of the rippling of a sine wave in small movement such as the leaves. Default 1.5.
$treeswayscrumblefalloffexp <float>
The falloff of the effect on small movement such as the leaves. Higher means a more stable center. Default 1.
$treeswayspeedhighwindmultipler <float>
Speed multiplier when env_wind triggers a gust. Default 2.
$treeswayspeedlerpstart <float>
Minimum wind speed in which a gust triggered by env_wind will start affecting the material. Default 3.
$treeswayspeedlerpend <float>
Minimum wind speed in which a gust triggered by env_wind will fully affect the material. Default 6.
$treeswaystatic <float> (Only in Team Fortress 2) (Also in Garry's Mod)
Use a static wind value instead of the values from env_wind. If enabled, env_wind is not required.

See Also

https://gamebanana.com/tuts/12924 - How to achieve a similar effect without $treeSway, on all source engine games