- Home /
Can I set a shader to only compile for specific platforms?
I have a shader that I am only ever going to use on desktop platforms, and it is pretty long and takes ages to compile, and also gives me warnings for the xbox 360 platform. Is there a way to prevent it from compiling to anything other than the desktop version to prevent the compiler warnings and speed up the compile time?
Answer by Kibsgaard · Feb 23, 2014 at 01:33 AM
http://docs.unity3d.com/Documentation/Components/SL-ShaderPrograms.html
#pragma only_renderers
space separated names - compile shader only for given renderers. By default shaders are compiled for all renderers. See Renderers below for details.
#pragma exclude_renderers
space separated names - do not compile shader for given renderers. By default shaders are compiled for all renderers. See Renderers below for details.
So what you probably want to do is to add this at the top of your source file:
#pragma only_renderers d3d9 d3d11
Thanks, it seems to work but still takes forever to compile. i guess its just how much code there is
Please use the "add new comment" button to add comments. Answers are reserved for solutions to the problem.
Your answer
![](https://koobas.hobune.stream/wayback/20220613134417im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to force the compilation of a shader in Unity? 5 Answers
Stop Shader Graph from recompiling preview shaders 1 Answer
Is it possible to dynamically recompile a shader on-the-fly? 1 Answer
Weird streak effect, particle sprites, Android but not all devices 1 Answer
check shader property if exist 1 Answer