- Home /
Unity 5 shaders and alpha on sprites broken?
I've used a shader in unity 4.6 which uses alpha channel. In 5 same shader shows strange behavior, ignoring or altering alpha in strange way. I've read about 'keepalpha' tag in the docs, but it does nothing here, it seems.
Another strange thing is when I select 'BumpedSpecular' shader in 'Legacy/Transparent/' folder, they work fine, cutting off alpha where needed. If i use same shader from 'Built-in shaders 4.6' package, it's broken. So, something changed in shaders. There's no ZIP of the built-in ones on their site: http://unity3d.com/get-unity/download/archive so I can't get those as a reference.
Shader source: http://pastebin.com/ensWirZR
Answer by Shins94 · Apr 10, 2015 at 05:27 PM
Just add "alpha:blend" to your #pragma like following
#pragma surface surf alpha:blend
I tried that, and although it does alpha blending( I recall alpha:blend being an option long before Unity 5, and it did just that, alpha blending but ignoring the Blend option settings), it ignores the Blend SrcAlpha One option for the shader, it uses a default way to blend ins$$anonymous$$d of what you specify, so this is still not the same as in Unity 4. it seems that you cannot have additive blending surface shaders in Unity5. If you read the compiled surface shader code. You'll see that it completely ignores your "Blend" options and just adds SrcAlpha One$$anonymous$$inusSrcAlpha
Answer by antonkudin · Mar 04, 2015 at 03:23 PM
Found the link to 5's built-in shaders in documentation: http://docs.unity3d.com/Manual/StandardShaderMakeYourOwn.html