Listing All Shader Permutations with the Material Analyzer


Sep 16, 2020.Knowledge
Article written by Branden T.

While authoring materials, it can be difficult to track the number of shader permutations that will be generated and how different options may influence that number. To address this, you can use the Material Analyzer to inspect your materials and track down the worst offenders. The Material Analyzer can be found under Window > Developer Tools. If you open it right when the editor starts, it’ll have to wait for the asset registry to finish loading.

Select your material or material instance to analyze from the drop-down, and the tool will find all the descendants of the material (or the material instance’s parent material). It will also find all the base property overrides, static switches, and static component mask parameters.

Below the material tree is a suggestion list. The suggestion list groups all the material instances with the same set of static overrides. Reparenting these to a new instance that has those static overrides so that the material instances just change their unique overrides can provide a savings in permutations and storing that data. Make sure to remove all the static parameter overrides after that reparent, otherwise the additional data will still be stored.

There’s a button for each suggestion list that will place all the related instances into a local collection. Down the road if this is an area that provides significant time/resource savings, we’d like to look into a more automated process for fixing up a suggestion group.

In this example, we are analyzing the M_Cave_Rock_MASTER material from the ActionRPG sample. The suggestion box shows that the children are sharing material permutations with the parents, so we can look at the tree above to find the redundant static parameters.

Because both static switches default to false, all the child material instances that also override them to false are redundant, and shader size gains would be found by removing the overrides in those children.

1 Like