Profile and compare transparency implementations

There are several different ways to implement transparency in a shader, each with their own benefits and drawbacks.

The most common used transparency implementations are alpha test and alpha blend:

  • Alpha test, or cutout

    The alpha test implementation makes the object material look either 100% opaque, or 100% transparent. You can set the threshold of the cutout for the mask. Unity calls this type of transparency cutout.

  • Alpha blend

Visually, alpha blend allows the material to have a range of transparency, making an object look partially transparent, instead of just opaque or completely transparent. Unity calls this blend mode transparent.

Alpha blend allows partial transparency while alpha test results in a sharp cutout. The following image shows a comparison of alpha blend and alpha test:

Deciding whether to use alpha blend or alpha test

The performance of alpha blend and alpha test depend on your use case. To determine which transparency implementation to use, Arm recommends that you always profile the performance difference between the two. On a mobile platform, you can use Arm Streamline to collect the performance data of a device.

Alpha test

If you want to use alpha test in your game, then here are some tips to remember:

  • Avoid the alpha test, or cutout, unless it is required.
  • Alpha test means that a material is either 100% opaque, or 100% transparent.
  • Using alpha test disables some optimization features within the GPU. Arm therefore recommends that you carefully examine the results of alpha test on the mobile platforms that you are targeting. Also, do not forget to profile and compare it against alpha blend for any differences in performance.
Alpha blend

If you want to use alpha blend in your game, here are some tips to remember:

  • For mobile platforms, Unity recommends using alpha blend instead of alpha test. In practice, you should profile and compare the performance between the alpha test and alpha blend. This is because the performance of alpha blend is content dependent and therefore needs measuring.
  • In general, avoid using transparencies with alpha blend on mobile platforms.
  • If alpha blend is needed, try to make the coverage of the blend area small.
Using alpha test transparency on foliage

In a static view of foliage, alpha blending can look better because of the soft edges. This is compared with the sharp cut in alpha test, as you can see in the following image:

However, when in motion, the use of alpha blend looks wrong and the leaves do not render in the correct order. Alpha test handles the transparency, and the order of the leaves, much better. However, the edges are harsher, or aliased, when compared with alpha blend.

Usually, the alpha test visual quality is acceptable, because the aliased edges are not as obvious in motion. But the optical illusion is broken when the leaves and branches jump back and forward from the use of alpha blend.

Previous Next