Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

Unity 5.5.1 and "pink shaders" on Shader Model 2.0 /rant

Discussion in 'Editor & General Support' started by s-m-k, Feb 8, 2017.

  1. s-m-k

    s-m-k

    Joined:
    Oct 26, 2013
    Posts:
    16
    If you ever make a mistake like me and update an old Unity project to the new version of Unity, knowing how little devs care about backward compatibility, you might run into the issue that every shader you used on older devices before (that worked perfectly) don't work anymore.

    Symptoms:
    You build your game, it works perfectly well on your moder pc. You switch to your low end machine and everything is pink, though the game logic seems to work (sounds etc.).

    You then look at the log and see a very 'clear' message of what's wrong with every shader:
    And you see this message mentioning every shader you used in the game.

    You set up low tier SM 2.0 emulation and can reproduce the problem (see attached image).

    What's actually wrong:
    By default, Unity used to compile shaders targeting Shader Model 2.0. However, some brilliant guy decided to make it target 2.5 by default without giving an easy way to fallback to 2.0 (like an option in editor settings, not to mention making it default 2.0 for old imported projects!).

    So, thanks to Unity dev team not caring about backward compatibility at all, all your SM 2.0 shaders are now compiled for SM 2.5.

    How to fix it:
    Add
    Code (CSharp):
    1. #pragma target 2.0
    to all shaders you use.

    I hope that helps.

    If this post makes you think I hate Unity, you're right. It's not the first time and not the only issue that could've been non-existent if someone actually spent 5 minutes thinking about backward compatibility.
     

    Attached Files:

    zwcloud likes this.
unityunity