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
m (Consistency with $detail - $treesway does not work with $detailtexturetransform)
No edit summary
 
(24 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Lang}}
{{LanguageBar}}
[[File:de_lake_treesway.gif|thumb|Tree with treesway on de_lake in CS:GO (click on image for gif to play).]]
{{Shaderparam|$treesway|since=Left 4 Dead 2|shader1=VertexLitGeneric}} It is also available in {{tf2}}{{Bms}}{{GMOD}}{{mapbase}}. In {{GMOD}}{{mapbase}}, it can also be used for {{ent|UnlitGeneric}}.


<code>$treesway</code> 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.
[[File:de_lake_treesway.gif|thumb|Tree with treesway on {{csgomap|de_lake|game=csgo}} in CS:GO (click to preview).]]
{{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.


{{note|This shader parameter is disabled by default in the {{as}} SDK. It can re-enabled by modding.}}
{{warning|Due to the way bumped lighting is calculated, <code>$treesway</code> will not sway materials which use {{ent|$bumpmap}}.}}
{{warning|Due to the way bumped lighting is calculated, <code>$treesway</code> will not sway materials which use {{ent|$bumpmap}}.}}
{{note|This shader parameter is disabled by default in the {{as}} SDK. It can re-enabled by modding.}}
{{bug|{{clr}}
{{bug|This shader parameter does not work with [[$detail#Parameters and Effects|$detailtexturetransform]].}}
* This shader parameter does not work with [[$detail#Parameters and Effects|$detailtexturetransform]].
{{bug|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 {{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.
{{bug|In {{mapbase}}, using a shadow-casting [[env_projectedtexture|projected texture]] will cause shadows not reacting to <code>$treesway</code>, shadows don't move, expect in {{gmod}}.}}
* 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 ).}}
: {{todo|What about <code>$singlepassflashlight</code> and <code>$flashlightnolambert</code>?}}
 
{{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==


{{MatParam|$treesway|int|What option to use for the tree swaying effect.
{{MatParamDef|$treesway|int|What option to use for the tree swaying effect.
:*0: No Sway
:*0: No Sway
:*1: "Classic" tree 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 <code>$treesway 2</code> are expected to be built lying in the X Y plane in model space, with their center at the origin.}}}}
:*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.}}}}
{{MatParam|$treeswayheight|float|The starting height in Hammer units where the effect should start being fully applied. Default 1000.}}
{{MatParamDef|$treeswayheight|float|The starting height in Hammer units where the effect should start being fully applied. Default 1000.}}
{{MatParam|$treeswaystartheight|float|The height from the model's origin in which the effect starts blending in. Default 0.2.}}
{{MatParamDef|$treeswaystartheight|float|The height from the model's origin in which the effect starts blending in. Default 0.2.}}
{{MatParam|$treeswayradius|float|The radius from the model's origin in Hammer units in where the effect should start being fully applied. Default 300.}}
{{MatParamDef|$treeswayradius|float|The radius from the model's origin in Hammer units in where the effect should start being fully applied. Default 300.}}
{{MatParam|$treeswaystartradius|float|The radius from the model's origin in which the effect starts blending in. Default 0.1.}}
{{MatParamDef|$treeswaystartradius|float|The radius from the model's origin in which the effect starts blending in. Default 0.1.}}
{{MatParam|$treeswayspeed|float|The speed multiplier of large movement such as the trunk. Default 1.}}
{{MatParamDef|$treeswayspeed|float|The speed multiplier of large movement such as the trunk. Default 1.}}
{{MatParam|$treeswaystrength|float|The distance multiplier of large movement such as the trunk. Default 10.}}
{{MatParamDef|$treeswaystrength|float|The distance multiplier of large movement such as the trunk. Default 10.}}
{{MatParam|$treeswayscrumblespeed|float|The falloff of the effect on large movement such as the trunk. Higher means a more stable center. Default 0.1.}}
{{MatParamDef|$treeswayscrumblespeed|float|The falloff of the effect on large movement such as the trunk. Higher means a more stable center. Default 0.1.}}
{{MatParam|$treeswayscrumblestrength|float|The speed multiplier of the small movement such as the leaves. Default 0.1.}}
{{MatParamDef|$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.}}
{{MatParamDef|$treeswayscrumblefrequency|float|The distance multiplier of the small movement such as the leaves. Default 0.1.}}
{{MatParam|$treeswayfalloffexp|float|The frequency of the rippling of a sine wave in small movement such as the leaves. Default 1.5.}}
{{MatParamDef|$treeswayfalloffexp|float|The frequency of the rippling of a sine wave in small movement such as the leaves. Default 1.5.}}
{{MatParam|$treeswayscrumblefalloffexp|float|The falloff of the effect on small movement such as the leaves. Higher means a more stable center. Default 1.}}
{{MatParamDef|$treeswayscrumblefalloffexp|float|The falloff of the effect on small movement such as the leaves. Higher means a more stable center. Default 1.}}
{{MatParam|$treeswayspeedhighwindmultipler|float|Speed multiplier when <code>env_wind</code> triggers a gust. Default 2.}}
{{MatParamDef|$treeswayspeedhighwindmultipler|float|Speed multiplier when <code>env_wind</code> triggers a gust. Default 2.}}
{{MatParam|$treeswayspeedlerpstart|float|Minimum wind speed in which a gust triggered by <code>env_wind</code> will start affecting the material. Default 3.}}
{{MatParamDef|$treeswayspeedlerpstart|float|Minimum wind speed in which a gust triggered by <code>env_wind</code> will start affecting the material. Default 3.}}
{{MatParam|$treeswayspeedlerpend|float|Minimum wind speed in which a gust triggered by <code>env_wind</code> will fully affect the material. Default 6.}}
{{MatParamDef|$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}}{{csgo}}{{GMOD}}{{mapbase}}}}
{{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}}}}
{{MatParam|$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}}}}
{{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}}}}


[[Category:List of Shader Parameters|T]]
== External links ==
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.


== See Also ==
[[Category:Shader parameters|t]]
https://gamebanana.com/tuts/12924 - How to achieve a similar effect without <code>$treeSway</code>, on all source engine games

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.