Hi
I’m using the following shader (taken bits and pieces from those who have already posted it), to use on my 2d sprites.
I need to be able to cast shadows and receive shadows. All works well on iPhone (although I get a ‘may not perform well’ message - but I haven’t noticed any performance issues). But on Android it all turns to schnozzle.
It runs at like 2fps if it’s lucky and there are strange lines across the sprites.
So, wondering if anyone can take a look at this and see what I can do so that I can get the same on Android as it performs on iPhone?
I have NFI about shaders!
Thanks
Shader "Custom/Sprite Cast Rec Shadow" {
Properties
{
_MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
PixelSnap ("Pixel snap", Float) = 0
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.3
}
SubShader
{
Tags
{
"Queue"="AlphaTest" //bad for mobile! (Android anyway)
// "Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
LOD 300
Cull Off
Lighting On
ZWrite On
Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma surface surf Lambert alpha vertex:vert alphatest:_Cutoff fullforwardshadows
#pragma multi_compile DUMMY PIXELSNAP_ON
sampler2D _MainTex;
fixed4 _Color;
struct Input
{
float2 uv_MainTex;
fixed4 color;
};
void vert (inout appdata_full v, out Input o)
{
#if defined(PIXELSNAP_ON) !defined(SHADER_API_FLASH)
v.vertex = UnityPixelSnap (v.vertex);
#endif
v.normal = float3(0,0,-1);
v.tangent = float4(1, 0, 0, 1);
UNITY_INITIALIZE_OUTPUT(Input, o);
o.color = _Color;
}
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * IN.color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
Fallback "Transparent/Cutout/Diffuse"
}