This article's documentation is for anything that uses the Source engine. Click here for more information.

$treesway: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Consistency)
No edit summary
 
(45 intermediate revisions by 18 users not shown)
Line 1: Line 1:
[[$treeSway]] is a shader effect available in {{csgo}}, {{insurgency}}, {{l4d2}}, {{l4d}}, {{as}}, {{tf2}} (As of Jungle Inferno update), {{GMOD}} (as of October 2018).
{{LanguageBar}}


==Description==
[[File:de_lake_treesway.gif|thumb|Tree with treesway on {{csgomap|de_lake|game=csgo}} in CS:GO (click to preview).]]
When this shader effect is added, it will make the [[material]] morph around to an {{ent|env_wind}} entity to give it the effect that it's blowing in the wind, this effect is used for the trees in {{csgo}} and various foliage seen in {{insurgency}}. The effect assumes that the model is facing upwards, and the commands specify how much it should be affected by the <code>env_wind</code> entity. By default this shader is disabled in the {{as}} SDK, however it can be re-enabled in a mod.
{{This is a|shader parameter|name=$treesway|shader=VertexLitGeneric|since=Left 4 Dead 2}} {{also| {{tf2branch}} {{Bms}} {{GMOD}} {{mapbase}} }} In {{GMOD}} {{mapbase}}, it can also be used for {{ent|UnlitGeneric}}.
<code>$treesway</code> morphs the vertices of a mesh with a given 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 {{mono|env_wind}} 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.


Only compatible with {{ent|VertexLitGeneric}}.
{{note|This shader parameter is disabled by default in the {{as}} SDK. It can re-enabled by modding.}}
{{note|{{tf2}} Does not require {{ent|env_wind}} if <code>$treeSwayStatic</code> is set to 1.}}
{{warning|Due to the way bumped lighting is calculated, <code>$treesway</code> will not sway materials which use {{ent|$bumpmap}}.}}
{{bug|{{clr}}
* This shader parameter does not work with [[$detail#Parameters and Effects|$detailtexturetransform]].
* In {{GMOD}}{{mapbase}}, using a shadow-casting [[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.
* In {{mapbase}}, using a shadow-casting [[env_projectedtexture|projected texture]] will cause shadows not reacting to <code>$treesway</code>, shadows don't move, except in {{gmod}} and Games now running on the 'TF2 SDK' ( 2025 Version of SDK2013MP ).}}
 
{{note|There was a TODO here, asking about the impact of $singlepassflashlight and $flashlightnolambert on this.<br>
its important to clarify this to avoid further confusion:<br>
These are Parameteres that affect the rendered Material only.<br>
For creating the 'Shadow Map' ( Depth Texture, Projected Texture, etc ), an entirely separate Shader is used.<br>
That Shader (DepthWrite) did not have the $TreeSway Code, causing Shadows to be entirely unaffected by this feature.<br>
It can't 'simply' be added either, only some Parameters from the original Material are copied to it.<br>
And in case of SDK2013SP ( What MapBase is running on, for now ) does not allow an easy replacement of the existing DepthWrite Shader.}}
 
 
 
{{modernImportant|While $TreeSway can be used to animate a {{ent|prop_static}}, lightmap shadows casted by swaying static props will remain static.<br>'''''If [[CSM]] is unavailable''''', consider using a {{ent|prop_dynamic}} instead. This can be combined with an animation containing more realistic pre-baked wind physics than can be achieved with $treesway.<br>As {{ent|prop_dynamic}} cannot be lit by [[VRAD]] per-vertex, it may be desirable to use a pre-baked {{ent|$lightmap}} (if available) in such situations, to restore some ambient lighting quality.}}


==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.
$treeSwayStartHeight              "float"    //The height from the origin in which the effect starts blending in.
$treeSwayRadius                  "float"    //The radius from the origin in which the effect is applied.
$treeSwayStartRadius              "float"    //The radius from the origin in which the effect starts blending in.
$treeSwaySpeed                    "float"    //The speed multiplier of large movement such as the trunk.
$treeSwayStrength                "float"    //The distance multiplier of large movement such as the trunk.
$treeSwayScrumbleSpeed            "float"    //The falloff of the effect on small movement such as the trunk. Higher means a more stable center.


$treeSwayScrumbleStrength        "float"   //The speed multiplier of the small movement such as the leaves.
{{MatParamDef|$treesway|int|What option to use for the tree swaying effect.
$treeSwayScrumbleFrequency        "float"    //The distance multiplier of the small movement such as the leaves.
:*0: No Sway
$treeSwayFalloffExp              "float"    //The frequency of the rippling of a sine wave in small movement such as the leaves.
:*1: "Classic" tree sway.
$treeSwayScrumbleFalloffExp      "float"    //The falloff of the effect on small movement such as the leaves. Higher means a more stable center.
:*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.}}}}
{{MatParamDef|$treeswayheight|float|The starting height in Hammer units where the effect should start being fully applied. Default 1000.}}
{{MatParamDef|$treeswaystartheight|float|The height from the model's origin in which the effect starts blending in. Default 0.2.}}
{{MatParamDef|$treeswayradius|float|The radius from the model's origin in Hammer units in where the effect should start being fully applied. Default 300.}}
{{MatParamDef|$treeswaystartradius|float|The radius from the model's origin in which the effect starts blending in. Default 0.1.}}
{{MatParamDef|$treeswayspeed|float|The speed multiplier of large movement such as the trunk. Default 1.}}
{{MatParamDef|$treeswaystrength|float|The distance multiplier of large movement such as the trunk. Default 10.}}
{{MatParamDef|$treeswayscrumblespeed|float|The falloff of the effect on large movement such as the trunk. Higher means a more stable center. Default 0.1.}}
{{MatParamDef|$treeswayscrumblestrength|float|The speed multiplier of the small movement such as the leaves. Default 0.1.}}
{{MatParamDef|$treeswayscrumblefrequency|float|The distance multiplier of the small movement such as the leaves. Default 0.1.}}
{{MatParamDef|$treeswayfalloffexp|float|The frequency of the rippling of a sine wave in small movement such as the leaves. Default 1.5.}}
{{MatParamDef|$treeswayscrumblefalloffexp|float|The falloff of the effect on small movement such as the leaves. Higher means a more stable center. Default 1.}}
{{MatParamDef|$treeswayspeedhighwindmultipler|float|Speed multiplier when <code>env_wind</code> triggers a gust. Default 2.}}
{{MatParamDef|$treeswayspeedlerpstart|float|Minimum wind speed in which a gust triggered by <code>env_wind</code> will start affecting the material. Default 3.}}
{{MatParamDef|$treeswayspeedlerpend|float|Minimum wind speed in which a gust triggered by <code>env_wind</code> will fully affect the material. Default 6.}}
{{MatParamDef|$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={{tf2branch}}{{csgo}}{{GMOD}}{{mapbase}}}}
{{MatParamDef|$treeswaystaticvalues|vector2|Sets the static wind values used by <code>$treeswaystatic</code>, syntax <code>[x y]</code>. Default <code>[0.5 0.5]</code>.|only={{mapbase}}}}


$treeSwaySpeedHighWindMultiplier  "float"    //Speed multiplier when env_wind triggers a gust.
== External links ==
$treeSwaySpeedLerpStart          "float"    //Minimum wind speed in which a gust triggered by env_wind will start affecting the material.
https://gamebanana.com/tuts/12924 - How to achieve a similar effect without <code>$treeSway</code>, on all source engine games. Alternatively, use an animated {{ent|prop_dynamic}}, for a more realistic (but more [[expensive]]) effect.
$treeSwaySpeedLerpEnd            "float"    //Minimum wind speed in which a gust triggered by env_wind will fully affect the material.
$treeSwayStatic                  "boolean"  //Whether or not to instead use a static wind value instead of the values from env_wind. TF2 only.
</pre>


[[Category:List of Shader Parameters|T]]
[[Category:Shader parameters|t]]

Latest revision as of 11:46, 23 August 2025

English (en)Русский (ru)Translate (Translate)
Tree with treesway on de_lake de_lake in CS:GO (click to preview).

$treesway is a material shader parameter for the VertexLitGeneric shader available in all Source Source games since Left 4 Dead 2 Left 4 Dead 2. (also in Team Fortress 2 branch Black Mesa Garry's Mod Mapbase) In Garry's Mod Mapbase, it can also be used for UnlitGeneric. $treesway morphs the vertices of a mesh with a given 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.pngNote:This shader parameter is disabled by default in the Alien Swarm SDK. It can re-enabled by modding.
Warning.pngWarning:Due to the way bumped lighting is calculated, $treesway will not sway materials which use $bumpmap.
Icon-Bug.pngBug:
  • This shader parameter does not work with $detailtexturetransform.
  • In Garry's ModMapbase, using a shadow-casting 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.
  • In Mapbase, using a shadow-casting projected texture will cause shadows not reacting to $treesway, shadows don't move, except in Garry's Mod and Games now running on the 'TF2 SDK' ( 2025 Version of SDK2013MP ).  [todo tested in ?]
Note.pngNote:There was a TODO here, asking about the impact of $singlepassflashlight and $flashlightnolambert on this.

its important to clarify this to avoid further confusion:
These are Parameteres that affect the rendered Material only.
For creating the 'Shadow Map' ( Depth Texture, Projected Texture, etc ), an entirely separate Shader is used.
That Shader (DepthWrite) did not have the $TreeSway Code, causing Shadows to be entirely unaffected by this feature.
It can't 'simply' be added either, only some Parameters from the original Material are copied to it.

And in case of SDK2013SP ( What MapBase is running on, for now ) does not allow an easy replacement of the existing DepthWrite Shader.


Icon-Important.pngImportant:While $TreeSway can be used to animate a prop_static, lightmap shadows casted by swaying static props will remain static.
If CSM is unavailable, consider using a prop_dynamic instead. This can be combined with an animation containing more realistic pre-baked wind physics than can be achieved with $treesway.
As prop_dynamic cannot be lit by VRAD per-vertex, it may be desirable to use a pre-baked $lightmap (if available) in such situations, to restore some ambient lighting quality.

Parameters

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.pngNote:Models using $treesway 2 are expected to be built lying in the X Y plane in model space, with their center at the origin.
The starting height in Hammer units where the effect should start being fully applied. Default 1000.
The height from the model's origin in which the effect starts blending in. Default 0.2.
The radius from the model's origin in Hammer units in where the effect should start being fully applied. Default 300.
The radius from the model's origin in which the effect starts blending in. Default 0.1.
The speed multiplier of large movement such as the trunk. Default 1.
The distance multiplier of large movement such as the trunk. Default 10.
The falloff of the effect on large movement such as the trunk. Higher means a more stable center. Default 0.1.
The speed multiplier of the small movement such as the leaves. Default 0.1.
The distance multiplier of the small movement such as the leaves. Default 0.1.
The frequency of the rippling of a sine wave in small movement such as the leaves. Default 1.5.
The falloff of the effect on small movement such as the leaves. Higher means a more stable center. Default 1.
Speed multiplier when env_wind triggers a gust. Default 2.
Minimum wind speed in which a gust triggered by env_wind will start affecting the material. Default 3.
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 branchCounter-Strike: Global OffensiveGarry's ModMapbase)
Use a static wind value instead of the values from env_wind. If enabled, env_wind is not required.
Sets the static wind values used by $treeswaystatic, syntax [x y]. Default [0.5 0.5].

External links

https://gamebanana.com/tuts/12924 - How to achieve a similar effect without $treeSway, on all source engine games. Alternatively, use an animated prop_dynamic, for a more realistic (but more expensive) effect.