- Home /
Question by
Curyous · May 11, 2012 at 09:46 AM ·
androidshaderdiffusesurfaceshader
Surface Shader works on Web, Mac, iOS but not Android
I'm just talking about running the game within Unity. When I switch platforms to Android, the surface shader I've written doesn't work. I wrote it to fallback to Diffuse, but it the object is just black.
What do I need to do to ensure that a surface shader will run on Android? I haven't actually tested it on a device at this point.
Here is the surface shader in question:
Shader "Custom/Squared" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf SquaredLambert
#pragma debug
sampler2D _MainTex;
half4 LightingSquaredLambert (SurfaceOutput s, half3 lightDir, half atten) {
half NdotL = saturate(dot (s.Normal, lightDir));
half4 c;
c.rgb = s.Albedo * _LightColor0.rgb * (NdotL * sqrt(atten) * 2);
c.a = s.Alpha;
return c;
}
struct Input {
float2 uv_MainTex;
float4 color : COLOR;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Comment