$treesway: Difference between revisions
| m (Edited TF2 note a little, and added bug for GMod.) | No edit summary | ||
| (44 intermediate revisions by 17 users not shown) | |||
| Line 1: | Line 1: | ||
| {{LanguageBar}} | |||
| == | [[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}}.}} | ||
| {{bug|In {{GMOD}}, [[env_projectedtexture|projected  | {{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== | ||
| $ | {{MatParamDef|$treesway|int|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 <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}}}} | |||
| == 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. | |||
| $ | |||
| [[Category: | [[Category:Shader parameters|t]] | ||
Latest revision as of 11:46, 23 August 2025
 
   de_lake in CS:GO (click to preview).
 de_lake in CS:GO (click to preview).$treesway  is a   material shader parameter for the VertexLitGeneric shader available in all  Source games since
 Source games since  Left 4 Dead 2. (also in
 Left 4 Dead 2. (also in  
  
  
  ) In
) In  
  , it can also be used for UnlitGeneric.
, 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.
 Warning:Due to the way bumped lighting is calculated,
Warning:Due to the way bumped lighting is calculated, $treesway will not sway materials which use $bumpmap. Bug:
Bug:
- This shader parameter does not work with $detailtexturetransform.
- In   , 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. , 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  , using a shadow-casting projected texture will cause shadows not reacting to , using a shadow-casting projected texture will cause shadows not reacting to$treesway, shadows don't move, except in and Games now running on the 'TF2 SDK' ( 2025 Version of SDK2013MP ).  [todo tested in ?] and Games now running on the 'TF2 SDK' ( 2025 Version of SDK2013MP ).  [todo tested in ?]
 Note:There was a TODO here, asking about the impact of $singlepassflashlight and $flashlightnolambert on this.
Note: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.
 Important:While $TreeSway can be used to animate a prop_static, lightmap shadows casted by swaying static props will remain static.
Important: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
- 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 Note:Models using$treesway 2are expected to be built lying in the X Y plane in model space, with their center at the origin.
 
env_wind triggers a gust. Default 2.env_wind will start affecting the material. Default 3.env_wind will fully affect the material. Default 6.env_wind. If enabled, env_wind is not required.$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.




























