Flag Shader

About

The flag shader can be used to create props which contain something moving in the wind, such as flags or some kind of cloth.

It's also possible to have multiple textures inside the same flag prop, which change based on the position of the prop, just like the vanilla flags do.

This article assumes you are familiar with regular prop asset creation.

Various example props using the flag shader

Various example props using the flag shader.

Textures

The textures work just like they would for any normal prop.

Mesh

The mesh is modeled as usual.

Format

Use a format which supports vertex colors, such as FBX (2015 or older) or DAE.

Multiple Flag Textures

If you have multiple flag textures on your texture, the flag should be UV mapped to the bottom right flag.

Vertex Paint

The vertex colors define which parts use the wind movement and multiple flag texture UV mapping.

If you're not planning to use multiple flag textures inside the same prop, like vanilla flags, then you can use the full range from white to black to define how much movement each vertex will have.

White means no movement and black means maximum movement.

If you will use multiple flag textures inside the same prop, then you can't use any shade of gray, as it will break the UV mapping when the flag tries to change textures. In that case, the flag must be completely black, and you can't control the strength of the wind effect.

Vertex paint of example props

Vertex paint of example props. Only the flag on the left uses multiple flag textures in the same prop.

LOD

The LOD also moves in the wind, so it should also be treated as described above. The LOD texture should match the main texture, but it can be scaled down to a lower resolution.

Script

You can find the script here .

Flag Grid

If you're using multiple flag textures for the same prop and want them to change based on position, just like the vanilla flags, you must have the flag textures in a consistent grid. If you're not using multiple flag textures for the same prop, then you can leave the flag grid parameters at default values.

A grid of flags for an example prop

A grid of flags for an example prop. 5 columns, 1 row, top left corner is (0,0), bottom right corner is (1024, 364).

Columns and Rows

Defines how many columns and rows the grid of flags on the texture has.

Top Left and Bottom Right

Defines the X and Y coordinates of the top left and bottom right corners of the entire flag grid on the texture, in pixels, as measured from the top left corner of the texture which is 0,0.

Movement Parameters

Strength

This will recalculate the vertex paint to reduce the strength of the wind movement. If you're using multiple flag textures on one prop, you can't control the strength, as it will break the UV mapping when the flag tries to change textures.

Axis

This defines the axis orientation in X Y Z, around which the wind movement happens.

The axis orientation is defined by a vector, so if you set both X and Y to the same value, the axis will be rotated 45°.

Keep in mind that ingame the Y-axis represents height, so the Y and Z-axis are swapped compared to what 3D software usually uses.

Pivot

This defines the pivot, where the axis is moved to, so you can move the axis, around which the movement happens.