Modding Tutorials/Damage Texture Swap

Intro
Arma 3 has a standardized mechanism to swap out textures based on the damage state of a hit location. It requires modifying the three 'usual suspects' vehicle files: model.cfg, P3D, config.cpp.

Although we refer to 'textures' in the colloquial sense, the game usually swaps "materials" (rvmat files), not "textures" (paa files). It works by letting you define a group of up to three materials for a given part of your vehicle:
 * 1) The base (undamaged) material: used until the hit location damage state reaches 0.5(?)--i.e. 50%.
 * 2) The damaged material: used for hit location damage of 50-99%(?).
 * 3) The destroyed material: used for hit location damage 100%(?).

Optional: instead of 3 materials in the form base/damaged/destroyed, you can use just 2 materials in the form base/base/damaged or base/damaged/damaged--it's just a matter of how you list the materials in your Damage class (see below).

The process is a bit complicated, so here are some additional points to be aware of:
 * The geometry whose material will be swapped:
 * 1) must exist as a "section" in model.cfg
 * 2) must have the base material applied to it in the P3D.
 * The link between the hit location and the material group is defined via the section name--it goes in the visual property of the HitPoint class (config.cpp>CfgVehicles).
 * The only thing that happens in the CfgVehicles>Damage class is listing your material group(s).

Steps to Create Swap
Let's look at how you create a swapping material in more detail. Here are the steps involved (although the order doesn't really matter). As an example, let's assume we have a vehicle with 3 glass windscreens--each a separate hit location--which we want to use the same damage-swapping material on.

1. Create Damaged Version(s) of Material

 * Create up to two damaged versions of the base rvmat.
 * (The material names don't matter, but something along the lines of X_base / X_damaged / X_destroyed would be useful).
 * e.g.

2. Modify model.cfg

 * There must be a separate section defined for each set of geometry that will be associated with a hit location.
 * e.g.

A. Match Named Selections to Sections

 * As with any section, the relevant geometry must be grouped into a named selection that matches section name.
 * e.g. The windscreen geometry in our vehicle's visual LOD's should be grouped into named selections called "glass1", "glass2", and "glass3".

B. Apply Base Material to Geometry Faces

 * Select all the geometry which will use the same damage material. (It doesn't matter if this geometry is different sections). Apply the base material to the geometry (you can do this in Oxygen using the "E" key or with the Resources Library window).
 * e.g. Select named selections "glass1", "glass2", and "glass3" and apply "glass_screen_base.rvmat" to them.

B. Add Damage Class
There is not much to the Damage class: each group of 3 material names defines a swapping set in the form

It's much easier to read a Damage class if you make creative use of the Enter key to keep things clear, e.g.

Something to Note
You've probably figured out by now that this system is set up in such a way that any of your vehicle's geometry that uses a base material from the Damage class will do the damage-texture-swap... as long as the following things are also true:
 * The geometry is in a named selection that matches a section name.
 * That section name appears in the "visual" property of some HitPoint class.

Typical Usage in Arma 3
Arma 3 stock vehicles often have a big 'catch-all' section called "zbytek" (which means "the rest" in Czech). This section usually comprises the vehicle hull and is given a group of damage textures linked (via the "visual" property) to the 'main' hit location (e.g. HitHull for a tank). Other large portions of a vehicle (tracks, turret) tend to be part of different Damage class sections.

FAQ
1. Do textures also need to be applied to geometry faces in Oxygen, or only materials?
 * No, materials appear to be sufficient (for material swapping anyway).

2. Are the dammageFull[] & dammageHalf[] properties in CfgVehicles fully obsolete or just deprecated? (They are not really used in Arma 3 stock configs).
 * (Not tested yet)

3. What exactly are the damage levels at which textures are swapped? (e.g VBS implies that they may be at 0.3 and 0.6 respectively: ,).
 * (Not tested yet)

4. Are there any caveats to mixing the texture swap & damage-hide techniques?
 * Apparently not--both appear to work fine on the same object.

Links
Beware--these references are even less useful than the typical Arma "documentation"...

[mostly useful], [sort-of useful], [mostly obsolete/deprecated], [obsolete/deprecated material-darkening method]