S&box Wiki

Revision Difference

Foliage_Shader#549620

<cat>Material.ShaderList</cat> <title>Foliage Shader</title> # Procedural Wind Animation <upload src="a5727/8db3aa6c97fdbd0.gif" size="9700698" name="foliage.gif" /> <upload src="a5727/8db3ad8056cad39.gif" size="8802419" name="foliage2.gif" /> The foliage shader supports procedural wind animation using vertex colors, to turn it on look for this feature in the material editor: <upload src="a5727/8db3aa4dba1ae94.png" size="4258" name="image.png" /> ## Vertex Color <upload src="a5727/8db3aa49bf0bbc8.png" size="699590" name="image.png" /> The intensity and variation of foliage movements are defined by each RGB channel in vertex colors as follows: **Red channel**: used for animation of smaller or peripheral parts of vegetation (leaves). Bright parts are animated, and dark parts are stiff. **Green channel:** which parts of branches can be bent, brighter parts indicate bendable portions and dark parts stiff portions. **Blue channel**: used for per-leaf phase variation - this is to de-synchronize the movement of different leaves. This should match across entire leaves. <note>After you turn on foliage animation on the material, the model will need to be force recompiled - this will make sure the vertex color stream gets baked into the compiled model.</note> ## Material Parameters <upload src="a5727/8db3aa45a9cd325.png" size="14715" name="image.png" /> * **Branch Amplitude**: How much the branches bend (multiplied by the green channel) * **Branch Frequency**: How frequently the branches bend (multiplied by the wind speed) * **Edge Amplitude**: How much the leaves flutter (multiplied by the red channel) * **Edge Frequency**: How frequently the leaves flutter (multiplied by the wind speed) * **Trunk Deflection**: A scale factor of how much the tree bends with the wind * **Trunk Deflection Start**: The height at which the tree begins to bend from ## Global Wind Parameters Currently wind speed and direction is controlled by the following convars: * `r_world_wind_strength` - default: 40.0 * `r_world_wind_dir` - default: 0.707 0.707 0.0 This will change in the near future to be game / map configurable.