Shader objects can contain of hundreds or thousands of shader variantsA verion of a shader program that Unity generates according to a specific combination of shader keywords and their status. A Shader object can contain multiple shader variants. More info
See in Glossary. If the Editor compiled all variants when loading a ShaderA program that runs on the GPU. More info
See in Glossary object, the import process would be very slow. Instead, the Editor compiles shader variants on-demand, the first time it encounters them.
Compiling these shader variants can cause the Editor to stall for milliseconds or even seconds, depending on the graphics API and the complexity of the Shader objectAn instance of the Shader class, a Shader object is container for shader programs and GPU instructions, and information that tells Unity how to use them. Use them with materials to determine the appearance of your scene. More info
See in Glossary. To avoid these stalls, you can use asynchronous shader compilation to compile the shader variants in the background, and use placeholder Shader objects in the meantime.
Asynchronous shader compilation works like this:
The following exceptions apply:
DrawProcedural
or CommandBuffer.DrawProcedural
, the Editor doesn’t use a placeholder shader. Instead, the Editor just skips rendering this geometry until it has compiled the shader variant.