Search Unity

Shader error in "Standard": Too many math instructions for SM2.0

Discussion in 'Shaders' started by ArachnidAnimal, Jul 31, 2016.

  1. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,825
    I'm trying to perform a build for windows.
    I'm using Unity 5.3.6.
    Whenever I build, the console complains about the Unity Standard shader:

    Shader error in 'Standard': Too many math instructions for SM2.0 (65 needed, max is 64). Try #pragma target 3.0 at UnityStandardCore.cginc(427) (on d3d9)

    Compiling Fragment program with DIRECTIONAL SHADOWS_SCREEN LIGHTMAP_OFF DIRLIGHTMAP_OFF DYNAMICLIGHTMAP_OFF FOG_EXP2 _NORMALMAP _DETAIL_MULX2 _ALPHATEST_ON
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING

    Does anyone know what this error means?
    I assume Unity is complaining about it's own Standard Shader.
     
  2. Namey5

    Namey5

    Joined:
    Jul 5, 2013
    Posts:
    188
    Well, because of the features of the standard shader, I would assume it requires a minimum of SM3.0. I can't think of any reason it would be forcibly compiling into shader model 2.0, however.
     
  3. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,825
    I went to the project settings and disabled support for dx9. Now the warning does not occur.
    By the time I'm with this project, there aren't going to be anymore computers with dx9.
     
  4. Namey5

    Namey5

    Joined:
    Jul 5, 2013
    Posts:
    188
    Makes sense. Although, from memory DX9 does have SM3.0 support. I've never compiled for it though, so I couldn't say for sure.
     
  5. msklywenn

    msklywenn

    Joined:
    Nov 28, 2014
    Posts:
    67
    I have the same kind of error when building with 5.5.1

    Code (csharp):
    1. Shader error in 'Standard (Specular setup)': Too many math instructions for SM2.0 (65 needed, max is 64). Try #pragma target 3.0 at /Program Files/Unity/5.5.1f1/Editor/Data/CGIncludes/UnityStandardCore.cginc(432) (on d3d9)
    2.  
    3. Compiling Fragment program with DIRECTIONAL SHADOWS_SCREEN LIGHTMAP_ON FOG_EXP2 _EMISSION _NORMALMAP _SPECGLOSSMAP _DETAIL_MULX2
    4. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP
    Any idea on how to fix it besides removing dx9 support ?...
     
  6. caLLow

    caLLow

    Joined:
    Apr 21, 2014
    Posts:
    35
    I had the same problem when I went from Unity 5.2.2 to 5.5.2.
    The fix for me, without removing dx9 support, was I switched from Shader Hardware Tier 3 to Shader Hardware Tier 1
    Here's how:
    Edit -> Graphics Emulation-> Shader Hardware Tier 1
     
    firepad9 and MasaIketani like this.
  7. msklywenn

    msklywenn

    Joined:
    Nov 28, 2014
    Posts:
    67
    Fair enough! I don't think the game would run with tier 3 anyway :)

    EDIT: oh, that's an editor only setting :(
     
  8. Wothanar

    Wothanar

    Joined:
    Sep 2, 2016
    Posts:
    122
    thanks alot
     
  9. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    You don't need to change it in the editor. Set "#pragma target 3.0" in your shader. Check to make sure you don't have some downloaded shaders in your project that are overriding the default Standard shader with a lower pragma target in it.