About the shader

During my time working on Border Patrol, we faced an exponential problem for variation in robot visuals. Robots could be built out of different body parts in engine, and this meant that using traditional texturing methods became an issue the more robots we created. We needed a system to create robot visuals efficiently without limiting creativity.

I worked with David Marshall to design and create this shader and editor to allow robot visuals to be created and modified in engine, using masks to set colors, roughness and metallic values along with many other details. These templates could then be saved as “skins” and used across all robots.

Created with Amplify Shader Editor and Unity.
Robot models by Catherine Clarke.

Base mask

The robot skin shader is based on an efficient masking method using a greyscale mask within the vertex colors of the meshes that can be placed in a single color channel. The shader extracts different values in steps from the mask and creates an array of masks from it.

This method allows you to get 10+ masks out of a single channel, as oppose to one mask per channel.

For example, the shader extracts areas of color value 0.2 from the vertex colors/texture mask and discards everything else. This then becomes it’s own mask, and the process is repeated for other values.

These masks are then used to set color, roughness, metallic and emissive values. A texture or vertex colors can be used.

Texture masks

These four textures are conveniently packed into a TGA and applied to the robot’s main material.

  • Dirt mask – Black and white mask used to mask in a grunge texture to act as dirt.
  • Curvature mask – Black and white mask mainly highlighting edges used to mask in a grunge texture to act as edge wear/rust.
  • Extra roughness – Adds additional roughness detail on top of base roughness. Used to get some variance on the surface on a clean robot.
  • Ambient Occlusion – Multiplied into albedo stylistically and used in conjunction with dirt mask to display dirt.

Grunge textures

Any texture can be masked into the dirt and curvature masks. Different grunge textures can be used to create variations of different dirt and edge wear/rust.

The dirt and curvature fields have the following settings:

  • Color
  • Strength
  • Roughness
  • Metallic toggle
  • Emissive toggle

Blend shapes (deformation)

Robots use blend shapes to set varying levels of damage. Within the editor, any field can be altered and keyed at any point along the deformation. The skin will blend between the two values keyed as the robot’s damage state is altered.

For example, a damaged robot would be expected to be more dirty than an undamaged one. So dirt strength can be keyed as 0 at 0% damage, and keyed as 100 at 100% damage. The skin will then blend between these two values along the deformation.