The Damage FX Object consists of three essentials pieces:

Damage FX Shader

Let’s look at the basic application of the shader with the base layer which is rendering the initial or untouched mesh, and also the damage layer added by the Damage FX function. The universal example would be FORGE3D/DamageFX/PBR Specular Gloss shader in our case.

The damage is added dynamically upon providing an object space point and non empty value to the shader data array. The shader function will iterate through the available impact points building the required masks given the following values:

  • Hit Radius – Defines the size of the impact. Note the mesh import scale (Unity Mesh Inspector) may affect the tiling of the damage masks. Ranges [0f, ~]. Setting a zero value leaves a very subtle effect.
  • Dirt Mask – The strength of the dirtiness around the impact in a range of [0f,1f].
  • Burn Edge – The amount of burn color applied to the inner edge of the impact usually in between the clipped spot and the dirt layer. Ranges [0f, 1f]. This parameter works best with the positive Clip and will fade over time. The fading can be controlled from the Damage FX Script Component.
  • Heat Glow – Is a glowing spot on top of the impact. Ranges [0f, 1f]. This parameter will fade over time and can be controlled from the Damage FX Script Component.
  • Clip Mask – The amount of clip applied at the impact point. Ranges [0f, 1f]. The lower the value the less is the clip up to none. A value in between the range, e.g. 0.5f, leaves the most of the rough edges at the impact hole.

These five values are individual per impact point and you can experiment with them in the real-time by launching the example scenes.

Note the default configuration is set to 200 impact points per Damage FX Object. Adding more points over the limit will overwrite existing ones from the beginning of the shader array.

Damage FX Script Component


In order to control the Damage FX Shader, an instance of the script should be present on each Damage FX Object. The script component handles the data processing for impact spots and fades the heat values over time.

Use DamageFX.Hit() method of the script to add new impacts to the surface of the mesh as shown below:

Here is the simple code snippet that will add the damage point to the Damage FX Object under the mouse cursor on left mouse click:

public float HitRadius = 0.1f;
public float Dirt = 1f;
public float Burn = 1f;
public float Heat = 1f;
public float Clip = 0.7f;
private RaycastHit _hitInfo;
private void Update()
   if (!Input.GetMouseButtonDown(0)) return;
   var screenRay = Camera.main.ScreenPointToRay(Input.mousePosition);
   if (!Physics.Raycast(screenRay, out _hitInfo, Mathf.Infinity)) return;
   var dfx = _hitInfo.collider.GetComponent<DamageFX>();
   if (dfx != null) dfx.Hit(dfx.transform.InverseTransformPoint(_hitInfo.point), HitRadius, Dirt, Burn, Heat, Clip);


The Damage FX works best with precise colliders that match its mesh geometry, e.g. mesh colliders.

If the distance between the closest mesh point and the collider hitpoint is bigger than the hit radius, then the effect won’t be visible at all. It’s important to provide a properly designed colliders to your Damage FX Objects.

The key is to get the impact from the hitpoint of the raycast against the collider to the original vertex position of the mesh. Sometimes this is not possible, for example, because you want to use the rigid body on the same object which will cause Unity to throw an error. Here’s a workaround to it. Remember, that you can use a convex collider or any number of simplified ones instead, either detach the mesh collider in the Awake(), and move it along each frame. You can also try using any third party tools/assets to help with generating a series of convex colliders covering the mesh.