6.1.3 Compilation Directives

You pass compilation directives as #pragma statements. The compilation directives indicate the shader functions to be compiled.

Each compilation directive must contain at least the directives to compile the vertex and the fragment shader: #pragma vertex name, #pragma fragment name.
By default, Unity compiles shaders into shader model 2.0. The directive #pragma target enables shaders to be compiled into other capability levels. If the shader becomes large you get an error of the following type:
Shader error in 'Custom/MyShader': Arithmetic instruction limit of 64 exceeded; 83 arithmetic instructions needed to compile program;
If this is the case you must change from shader model 2.0 to shader model 3.0 by adding the #pragma target 3.0 statement. Shader model 3.0 has a much higher instruction limit.
If you pass several varyings from vertex shader to fragment shader you might get the following error:
Shader error in 'Custom/MyShader': Too many interpolators used (maybe you want #pragma glsl?) at line 75.
If this is the case add the compilation directive #pragma glsl. This directive converts Cg or HLSL code into GLSL.
The #pragma only_renderers directive.
Unity supports several rendering platforms such as gles, gles3, opengl, d3d11, d3d11_9x, xbox360, ps3 and flash. By default, shaders are compiled to all these platforms unless you explicitly limit this number using the #pragma only_renderers followed by the render APIs you want leaving a blank space between them.
If you are targeting mobile devices only limit shader compilations to gles and gles3. You must also add the opengl and d3d11 renderers used by Unity Editor:
#pragma only_renderers gles gles3 [opengl, d3d11]
Non-ConfidentialPDF file icon PDF versionARM 100140_0201_00_en
Copyright © 2014, 2015 ARM. All rights reserved.