- Home /
Bug In Unity
Android Shader Problem After Unity 3.5.1 Upgrade
I just upgraded from unity 3.4.x to 3.5.1 today and I have found a problem with shaders.
Before the update, I had a simple 'feathering' shader - the alpha increased towards the edge of a plane. Once my android project was compiling to Android 2.2 and OpenGL ES 2, the shader was working fine.
Since the update though, the shader has been falling through to the Fallback shader.
Previously the editor gave me a good idea what shaders would work on Android, but now the shader works fine in the editor but fails on the device.
There have been no code changes and there are no warnings that appear to refer to this shader in the log.
The shader is quite simple and relatively low-cost. There are three parameters - the texture, an alpha constant (for transparency) and a 'feathering' factor that controls the strength of the feathering effect.
Does anyone have any idea why it isn't working?
Thanks in advance for your help!
Shader "Special/Feathered" {
Properties {
_MainTex ("Base (RGBA)", 2D) = "white" {}
_Feather ("Feather", Float) = 2
_Alpha ("Alpha", Float) = 1
}
SubShader {
Tags { "RenderType"="Transparent"
"Queue"="Transparent" }
LOD 200
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
};
half _Feather;
half _Alpha;
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c;
o.Alpha = saturate((1-(distance(IN.uv_MainTex,(0.5,0.5)) * _Feather)));
o.Alpha = min(o.Alpha,_Alpha);
}
ENDCG
}
FallBack "Mobile/Diffuse"
}
Interestingly with a statement as complex as the saturate one, it's the $$anonymous$$IN that seems to be the problem!
Without the '$$anonymous$$' the shader works properly!
CONFIR$$anonymous$$ED: This is the case. In the newest version of Unity (3.5.1f2) an Android shader that uses the '$$anonymous$$' function will fail and fall back.
If this is by design, could we get a warning? Otherwise can we get the bug fixed?
Answer by IgnoranceIsBliss · Apr 17, 2012 at 03:38 AM
In the newest version of Unity (3.5.1f2) an Android shader that uses the 'min' function will fail and fall back.
This problem occurs on a Tegra 2-based tablet.
This must be due to a bug in Unity, as did not occur in previous versions.