Basic

July 14 2020

0 comments

Now You Can Choose High-Performing Unity Shaders

By Rubén Torres Bonet

July 14, 2020


__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"6c4de":{"name":"Main Accent","parent":-1},"67ed2":{"name":"Accent Dark","parent":"6c4de","lock":{"saturation":1}}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"6c4de":{"val":"var(--tcb-skin-color-0)"},"67ed2":{"val":"rgb(59, 65, 63)","hsl_parent_dependency":{"h":160,"l":-0.05,"s":0.04}}},"gradients":[]},"original":{"colors":{"6c4de":{"val":"rgb(51, 190, 127)","hsl":{"h":152,"s":0.57,"l":0.47}},"67ed2":{"val":"rgb(59, 65, 63)","hsl_parent_dependency":{"h":160,"s":0.04,"l":0.24}}},"gradients":[]}}]}__CONFIG_colors_palette__

There are many shaders in Unity.

When choosing your next shader, you need to strike the balance between your dream visuals and the performance you take away.

But how much performance do your shaders steal?

Well, in my previous post I showed you a simple process to measure the performance cost of your shaders.

But today I'm doing something different.

Today, I'll give you handy tables so you can see the performance cost of the commonly used Unity shaders.

Yes, now you can make informed decisions in your game 🙂

How to Read These Performance Numbers

Here's a few notes regarding these numbers:

  • I did not include all variants, as most shaders can well have 1k+ variants.
  • I simplified the variant term as a concatenation of the shader's Global Keyword and Local Keyword.
  • The numbers represent the total number of GPU shader unit cycles as estimated by Mali Offline Compiler for OpenGL ES 3 for a modern mobile platform.
  • I'm using Unity default graphic settings regarding hardware tiers.
  • The red number shows the hardware bottleneck for each shader variant.
  • These numbers do not account for your current GPU pipeline state, such as caching.

And here's the legend:

  • A = Arithmetic operations (e.g. sum, multiply, etc.)
  • LS = Load/Store operations (e.g. loading parameters from buffers)
  • V = Varying operations (i.e. the cost spent in the shader unit varying interpolator)
  • T = Texture operations (e.g. fetching + sampling)

By the way, I suggest reading this on desktop...

Reading this on mobile will only hurt your eyesight.

I know because I tried. And my eyes still hurt after two days.

The Gamedev Guru Logo

The Cost of Your Shaders

UI Default Shader (4 Variants)

Vertex Shader Fragment Shader
Variant A LS V T A LS V T
NONE | NONE1.413.00.00.00.30.00.50.5
NONE | UNITY_UI_ALPHACLIP 1.413.00.00.00.40.00.50.5
NONE | UNITY_UI_CLIP_RECT 1.413.00.00.00.50.00.80.5
NONE | UNITY_UI_ALPHACLIP UNITY_UI_CLIP_RECT 1.413.00.00.00.70.00.80.5

Sprite Default Shader (4 Variants)

Vertex Shader Fragment Shader
Variant A LS V T A LS V T
NONE | NONE1.49.00.00.00.30.00.50.5
NONE | PIXELSNAP_ON 1.59.00.00.00.30.00.50.5
ETC1_EXTERNAL_ALPHA | NONE1.49.00.00.00.40.00.51.0
ETC1_EXTERNAL_ALPHA | PIXELSNAP_ON 1.59.00.00.00.40.00.51.0

Sky Sphere Example

Skybox Procedural (3 Variants)

Vertex Shader Fragment Shader
Variant A LS V T A LS V T
NONE | _SUNDISK_NONE 8.39.00.00.00.30.00.60.0
NONE | _SUNDISK_SIMPLE 8.511.00.00.00.80.01.00.0
NONE | _SUNDISK_HIGH_QUALITY 8.411.00.00.01.70.01.10.0

Skybox Cubemap (1 Variant)

Vertex Shader Fragment Shader
Variant A LS V T A LS V T
NONE | NONE1.35.00.00.00.60.00.40.5

Skybox 6-Sided (1 Variant)

Vertex Shader Fragment Shader
Variant A LS V T A LS V T
NONE | NONE (6x)1.26.00.00.00.50.00.30.5

Clearly, the procedural skybox shader is more expensive than its two alternatives.


Unity Alpha Blended Shader

Unity Alpha Blended Shader

Mobile - Particles - Alpha Blended (1 Variant)

Vertex Shader Fragment Shader
Variant A LS V T A LS V T
NONE | NONE1.19.00.00.00.20.00.50.5

Unity Shader Diffuse

Unity Shader Diffuse (Source: Unity)

Mobile - Diffuse (17 Variants)

Vertex Shader Fragment Shader
Variant A LS V T A LS V T
DIRECTIONAL | NONE1.813.00.00.01.50.01.01.0
DIRECTIONAL LIGHTPROBE_SH | NONE3.615.00.00.01.50.01.31.0
DIRECTIONAL SHADOWS_SCREEN | NONE2.215.00.00.02.00.01.51.5
DIRECTIONAL LIGHTPROBE_SH SHADOWS_SCREEN | NONE2.717.00.00.04.60.01.83.0
DIRECTIONAL VERTEXLIGHT_ON | NONE1.813.00.00.01.50.01.01.0
DIRECTIONAL LIGHTPROBE_SH VERTEXLIGHT_ON | NONE5.515.00.00.01.50.01.31.0
DIRECTIONAL SHADOWS_SCREEN VERTEXLIGHT_ON | NONE2.215.00.00.02.00.01.51.5
DIRECTIONAL LIGHTPROBE_SH SHADOWS_SCREEN VERTEXLIGHT_ON | NONE5.017.00.00.04.60.01.83.0
NONE | NONE1.88.00.00.00.30.00.40.0
NONE | NONE3.815.00.00.00.90.01.11.0
LIGHTPROBE_SH | NONE3.815.00.00.00.90.01.11.0
UNITY_HDR_ON | NONE3.815.00.00.00.50.01.11.0
LIGHTPROBE_SH UNITY_HDR_ON | NONE3.815.00.00.00.50.01.11.0
NONE | NONE1.813.00.00.00.60.00.60.5
LIGHTPROBE_SH | NONE3.615.00.00.00.90.00.90.5
UNITY_HDR_ON | NONE1.813.00.00.00.60.00.60.5
LIGHTPROBE_SH UNITY_HDR_ON | NONE3.615.00.00.00.70.00.90.5
Unity Shader Bumped Diffuse

Unity Shader Bumped Diffuse (Source: Unity)

Mobile - Bumped Diffuse (17 Variants)

Vertex Shader Fragment Shader
Variant A LS V T A LS V T
DIRECTIONAL | NONE2.816.00.00.02.20.01.81.5
DIRECTIONAL LIGHTPROBE_SH | NONE4.518.00.00.02.30.02.01.5
DIRECTIONAL SHADOWS_SCREEN | NONE3.018.00.00.02.80.02.32.0
DIRECTIONAL LIGHTPROBE_SH SHADOWS_SCREEN | NONE3.620.00.00.05.20.02.53.5
DIRECTIONAL VERTEXLIGHT_ON | NONE2.816.00.00.02.20.01.81.5
DIRECTIONAL LIGHTPROBE_SH VERTEXLIGHT_ON | NONE6.318.00.00.02.30.02.01.5
DIRECTIONAL SHADOWS_SCREEN VERTEXLIGHT_ON | NONE3.018.00.00.02.80.02.32.0
DIRECTIONAL LIGHTPROBE_SH SHADOWS_SCREEN VERTEXLIGHT_ON | NONE6.020.00.00.05.20.02.53.5
NONE | NONE2.914.00.00.00.80.01.40.5
NONE | NONE3.815.00.00.00.90.01.11.0
LIGHTPROBE_SH | NONE3.815.00.00.00.90.01.11.0
UNITY_HDR_ON | NONE3.815.00.00.00.50.01.11.0
LIGHTPROBE_SH UNITY_HDR_ON | NONE3.815.00.00.00.50.01.11.0
NONE | NONE2.816.00.00.01.30.01.41.0
LIGHTPROBE_SH | NONE4.518.00.00.01.40.01.61.0
UNITY_HDR_ON | NONE2.816.00.00.01.30.01.41.0
LIGHTPROBE_SH UNITY_HDR_ON | NONE4.518.00.00.01.30.01.61.0

As you can see, the bumped diffuse shader is considerably more expensive than the plain diffuse shader.


Unity Unlit Color Shader

Unity Unlit Color Shader

Unlit - Color (1 Variant)

Vertex Shader Fragment Shader
Variant A LS V T A LS V T
NONE | NONE1.23.00.00.00.20.00.00.0
Unity Unlit Texture Shader

Unity Unlit Texture Shader

Unlit - Texture (1 Variant)

Vertex Shader Fragment Shader
Variant A LS V T A LS V T
NONE | NONE1.16.00.00.00.10.00.30.5

The unlit shaders are one of the cheapest shaders. The unlit texture variant more than doubles its performance cost.


Unity Standard Shaders

Unity Standard Shaders (Source: Unity)

Standard Shader (42 Variants)

Vertex Shader Fragment Shader
Variant A LS V T A LS V T
DIRECTIONAL | NONE2.222.00.00.07.90.01.42.5
DIRECTIONAL LIGHTPROBE_SH | NONE3.022.00.00.010.40.01.64.0
DIRECTIONAL SHADOWS_SCREEN | NONE2.422.00.00.08.40.01.93.0
DIRECTIONAL LIGHTPROBE_SH SHADOWS_SCREEN | NONE3.022.00.00.011.20.02.14.5
DIRECTIONAL VERTEXLIGHT_ON | NONE2.222.00.00.07.90.01.42.5
DIRECTIONAL LIGHTPROBE_SH VERTEXLIGHT_ON | NONE4.922.00.00.010.40.01.64.0
DIRECTIONAL SHADOWS_SCREEN VERTEXLIGHT_ON | NONE2.422.00.00.08.40.01.93.0
DIRECTIONAL LIGHTPROBE_SH SHADOWS_SCREEN VERTEXLIGHT_ON | NONE5.422.00.00.011.20.02.14.5
POINT | NONE2.822.00.00.05.00.02.51.5
DIRECTIONAL | NONE2.320.00.00.04.40.02.51.0
SPOT | NONE3.022.00.00.05.30.02.52.0
POINT_COOKIE | NONE2.822.00.00.05.30.02.52.0
DIRECTIONAL_COOKIE | NONE2.922.00.00.04.50.02.51.5
SHADOWS_DEPTH SPOT | NONE3.022.00.00.06.30.02.52.5
SHADOWS_DEPTH SHADOWS_SOFT SPOT | NONE3.022.00.00.06.70.02.54.0
DIRECTIONAL SHADOWS_SCREEN | NONE2.520.00.00.04.90.03.01.5
DIRECTIONAL_COOKIE SHADOWS_SCREEN | NONE2.922.00.00.04.90.03.02.0
POINT SHADOWS_CUBE | NONE2.822.00.00.05.80.02.52.0
POINT SHADOWS_CUBE SHADOWS_SOFT | NONE2.822.00.00.06.80.02.53.5
POINT_COOKIE SHADOWS_CUBE | NONE2.822.00.00.06.10.02.52.5
POINT_COOKIE SHADOWS_CUBE SHADOWS_SOFT | NONE2.822.00.00.07.10.02.54.0
NONE | NONE2.320.00.00.01.00.00.61.0
LIGHTPROBE_SH | NONE2.820.00.00.04.00.01.32.5
UNITY_HDR_ON | NONE2.320.00.00.01.00.00.61.0
LIGHTPROBE_SH UNITY_HDR_ON | NONE2.820.00.00.03.60.01.32.5
DIRECTIONAL | NONE2.422.00.00.03.40.01.42.5
DIRECTIONAL LIGHTPROBE_SH | NONE4.322.00.00.03.80.01.62.5
DIRECTIONAL SHADOWS_SCREEN | NONE2.422.00.00.08.40.01.93.0
DIRECTIONAL LIGHTPROBE_SH SHADOWS_SCREEN | NONE3.022.00.00.011.20.02.14.5
DIRECTIONAL VERTEXLIGHT_ON | NONE2.422.00.00.03.40.01.42.5
DIRECTIONAL LIGHTPROBE_SH VERTEXLIGHT_ON | NONE6.322.00.00.03.80.01.62.5
DIRECTIONAL SHADOWS_SCREEN VERTEXLIGHT_ON | NONE2.422.00.00.08.40.01.93.0
DIRECTIONAL LIGHTPROBE_SH SHADOWS_SCREEN VERTEXLIGHT_ON | NONE5.422.00.00.011.20.02.14.5
POINT | NONE3.322.00.00.03.00.02.52.0
DIRECTIONAL | NONE2.520.00.00.02.50.02.51.5
SPOT | NONE3.322.00.00.03.20.02.52.5
POINT_COOKIE | NONE3.322.00.00.03.20.02.52.5
DIRECTIONAL_COOKIE | NONE3.122.00.00.02.80.02.52.0
SHADOWS_DEPTH SPOT | NONE3.322.00.00.02.90.02.52.5
DIRECTIONAL SHADOWS_SCREEN | NONE2.520.00.00.04.90.03.01.5
DIRECTIONAL_COOKIE SHADOWS_SCREEN | NONE2.922.00.00.04.90.03.02.0
POINT SHADOWS_CUBE | NONE3.322.00.00.02.50.02.52.0
POINT_COOKIE SHADOWS_CUBE | NONE3.322.00.00.02.70.02.52.5

Standard Shader - Specular Setup (42 Variants)

Vertex Shader Fragment Shader
Variant A LS V T A LS V T
DIRECTIONAL | NONE2.222.00.00.07.50.01.42.5
DIRECTIONAL LIGHTPROBE_SH | NONE3.022.00.00.010.30.01.64.0
DIRECTIONAL SHADOWS_SCREEN | NONE2.422.00.00.08.20.01.93.0
DIRECTIONAL LIGHTPROBE_SH SHADOWS_SCREEN | NONE3.022.00.00.011.00.02.14.5
DIRECTIONAL VERTEXLIGHT_ON | NONE2.222.00.00.07.50.01.42.5
DIRECTIONAL LIGHTPROBE_SH VERTEXLIGHT_ON | NONE4.922.00.00.010.30.01.64.0
DIRECTIONAL SHADOWS_SCREEN VERTEXLIGHT_ON | NONE2.422.00.00.08.20.01.93.0
DIRECTIONAL LIGHTPROBE_SH SHADOWS_SCREEN VERTEXLIGHT_ON | NONE5.422.00.00.011.00.02.14.5
POINT | NONE2.822.00.00.04.80.02.51.5
DIRECTIONAL | NONE2.320.00.00.04.30.02.51.0
SPOT | NONE3.022.00.00.04.90.02.52.0
POINT_COOKIE | NONE2.822.00.00.05.00.02.52.0
DIRECTIONAL_COOKIE | NONE2.922.00.00.04.50.02.51.5
SHADOWS_DEPTH SPOT | NONE3.022.00.00.06.00.02.52.5
SHADOWS_DEPTH SHADOWS_SOFT SPOT | NONE3.022.00.00.06.40.02.54.0
DIRECTIONAL SHADOWS_SCREEN | NONE2.520.00.00.04.70.03.01.5
DIRECTIONAL_COOKIE SHADOWS_SCREEN | NONE2.922.00.00.04.70.03.02.0
POINT SHADOWS_CUBE | NONE2.822.00.00.05.60.02.52.0
POINT SHADOWS_CUBE SHADOWS_SOFT | NONE2.822.00.00.06.90.02.53.5
POINT_COOKIE SHADOWS_CUBE | NONE2.822.00.00.05.90.02.52.5
POINT_COOKIE SHADOWS_CUBE SHADOWS_SOFT | NONE2.822.00.00.07.00.02.54.0
NONE | NONE2.320.00.00.00.90.00.61.0
LIGHTPROBE_SH | NONE2.820.00.00.03.80.01.32.5
UNITY_HDR_ON | NONE2.320.00.00.00.90.00.61.0
LIGHTPROBE_SH UNITY_HDR_ON | NONE2.820.00.00.03.40.01.32.5
DIRECTIONAL | NONE2.422.00.00.03.20.01.42.5
DIRECTIONAL LIGHTPROBE_SH | NONE4.322.00.00.03.40.01.62.5
DIRECTIONAL SHADOWS_SCREEN | NONE2.422.00.00.08.20.01.93.0
DIRECTIONAL LIGHTPROBE_SH SHADOWS_SCREEN | NONE3.022.00.00.011.00.02.14.5
DIRECTIONAL VERTEXLIGHT_ON | NONE2.422.00.00.03.20.01.42.5
DIRECTIONAL LIGHTPROBE_SH VERTEXLIGHT_ON | NONE6.322.00.00.03.40.01.62.5
DIRECTIONAL SHADOWS_SCREEN VERTEXLIGHT_ON | NONE2.422.00.00.08.20.01.93.0
DIRECTIONAL LIGHTPROBE_SH SHADOWS_SCREEN VERTEXLIGHT_ON | NONE5.422.00.00.011.00.02.14.5
POINT | NONE3.322.00.00.02.80.02.52.0
DIRECTIONAL | NONE2.520.00.00.02.40.02.51.5
SPOT | NONE3.322.00.00.03.00.02.52.5
POINT_COOKIE | NONE3.322.00.00.03.10.02.52.5
DIRECTIONAL_COOKIE | NONE3.122.00.00.02.60.02.52.0
SHADOWS_DEPTH SPOT | NONE3.322.00.00.02.80.02.52.5
DIRECTIONAL SHADOWS_SCREEN | NONE2.520.00.00.04.70.03.01.5
DIRECTIONAL_COOKIE SHADOWS_SCREEN | NONE2.922.00.00.04.70.03.02.0
POINT SHADOWS_CUBE | NONE3.322.00.00.02.30.02.52.0
POINT_COOKIE SHADOWS_CUBE | NONE3.322.00.00.02.50.02.52.5

We all knew standard shaders are extremely expensive.

From the numbers, it looks as if the specular setup is slightly cheaper than the metallic version.

Get the Sortable List

That was a ton of numbers!

These metrics will help you balance the visual quality you want to achieve in your game with your performance requirements.

The lower the GPU cycles your shader takes, the faster it will run.

(I wish we could always run the standard shader... but as you see, its cost is prohibitive for mobile platforms)

To get a free sortable spreadsheet that you can save and keep at hand for quick reference in your projects, just subscribe to the performance newsletter with your e-mail below.

It's super handy because you can filter the list by the shaders you want to compare.

Take care,
~Ruben (The Gamedev Guru)

[SPOILER] P.S. In the next post on GPU Performance, I'll dig deeper into the performance world of the standard shaders.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Rubén Torres Bonet

About the author

Born Game Developer, now ready to help you develop better games. Primary programmer on Star Trek Bridge Crew (Oculus Quest), Diamond Dash. Programmer on Time Stall, Catan Universe, Anne Frank House VR, Jelly Splash, Blackguards Definitive Edition. I also worked in minor XR experiences for HoloLens and Vive for clients such as Audi and Volkswagen.

You might also like

Simplify Your Life With Unity Mesh Simplifier
>