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

$treesway

From Valve Developer Community
(Redirected from $treeSway)
Jump to navigation Jump to search
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, expect in Garry's Mod.
Todo: What about $singlepassflashlight and $flashlightnolambert?
  [todo tested in?]
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.