Grass

From Valve Developer Community
Jump to navigation Jump to search

Grass is a Vertex shader available in Counter-Strike: Global Offensive Counter-Strike: Global Offensive. It features the function where the grass is flattened by nearby players, using cl_proximity_grass convar. The shader also simulates swaying in the wind.

Examples

Grass from dz_blacksite

[pak01_dir.vpk] materials\detail\detailsprites_survival.vmt

grass
{
	"$basetexture"     "detail/detailsprites_survival"
	"$masks"		   "detail/detailsprites_survival_masks"
 	"$alphatest"       "1"
	"$vertexcolor"     "1"
	"$worldspacetype"  "detail/test_massive9_grass_type"
	"$worldspacetint"  "detail/test_massive9_grass_tint"
	"$worldspaceburn"  "_rt_grassburn"
	"$worldspacezone"  "_rt_zoneprojection"
	%notooltexture     "1"
//	"$worldspacescale" ".75"
	"$minimumspritesize" "22"
}

Supported Parameters

$worldspacetint as test_massive9_grass_tint.vtf 512x512 texture from detailsprites_survival.vmt

Basics

$basetexture <texture>
Diffuse texture. $alphatest and $vertexcolor enabled by default.
$worldspacescale <float>
Default value 1.
$worldspacetint <texture>
Vertex texture. Used as world tint color of grass on all map. Can be usage as different grass colors depend of the map place. It is also recommended to use it as a lightmap to shade areas where the grass is in shadow, making those sections dark.
$worldspacetype <texture>
Vertex texture. Lookup data.
$minimumspritesize <float>
Default value 0.
$masks <texture>
Provides control over tint and wind sway relative to the $basetexture's UV coordinates, unlike the world-space control found in other textures.

Gameplay textures

$worldspaceburn <texture>
Burn data in world space. It affects the color, transparency and sway effect. Vertex texture. No default texture binding. Specify explicitly _rt_grassburn, which created as render target with RGB888 texture format. Used only Red channel.
$worldspacezone <texture>
Zone data in world space, that affect the transparency. Vertex texture. No default texture binding. Specify explicitly _rt_zoneprojection, which created as render target with RGB888 texture format. Used only Red channel.

Configuring the masks

$worldspacetype as test_massive9_grass_type.vtf 512x512 texture from detailsprites_survival.vmt
$masks as detailsprites_survival_masks.vtf from detailsprites_survival.vmt

$worldspacetint

The RGB channels of $worldspacetint is configured as follows:

Channel/Info Data
RGB Tint color
Format DXT1

$worldspacetype

The RGB channels of $worldspacetype is configured as follows:

Channel/Info Data
Red UV offset by X coordinate
Green Scale channel
Blue Has no effect
Format ATI2N

$masks

The RGB channels of $masks is configured as follows:

Channel/Info Data
Red Used with $worldspacetype as wind sway influence factor
Green Used with $worldspacetint as color tint factor
Blue Used with $worldspacetype as wind sway multiplier
Format DXT1

See also