See the Flag Shader article.
Various example props using the flag shader.
The Flag Params mod 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.
The textures work just like they would for any normal prop.
The mesh is modeled as usual.
Use a format which supports vertex colors, such as FBX 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 of example props. Only the flag on the left uses multiple flag textures in the same prop.
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.
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.
You can find the script here.
A grid of flags for an example prop. 5 columns, 1 row, top left corner is (0,0), bottom right corner is (1024, 364).
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.
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.
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.
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.
This defines the pivot, where the axis is moved to, so you can move the axis, around which the movement happens.
It's also possible to use the flag shader for vehicle sub-meshes using these scripts.
The only difference in the creation process is that the mesh should be imported as a prop first, then the game must be reloaded, and then the vertex colors can be copied to the vehicle sub-mesh using the first script. This is the same process required for rotors shader propellers.
The LOD on vehicle sub-meshes doesn't support flag shader, therefore an invisible, or a static regular vehicle LOD can be made.
If you try to use the multiple flag textures method, the flag texture will change as the vehicle drives.