My general question is “how can I know what shaders will work on what platforms (especially different iOS platform targets)?”
My specific question is “why doesn’t this custom shader work on iPad Air?”
See bottom of post for the shader code.
I’m using this shader on a material for a line renderer (aim assist on a weapon, color toggles between green and red).
The renderer works fine on my iPad 2, but shows up as black on the iPad Air. When I switch to the builtin shader “mobile/vertex colored” and redploy, the line renderer then works fine on the iPad Air.
I can’t remember where exactly I got it from, I think a shader tutorial somewhere - certainly didn’t write it myself, since I don’t know anything about shaders yet.
I guess I started using it because it has a “no lighting” lighting model and it has simple color properties (I’m setting the color from a script, don’t need a texture).
Shader "Custom/SimpleTransparentSelfIllum" {
Properties {
_MainColor ("Main Color", Color) = (1,1,1,1)
_EmissionColor ("Emission Color", Color) = (1,1,1,1)
_AlphaValue ("Alpha Value", Range(0, 1)) = 1
}
SubShader {
Tags {
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
}
LOD 200
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma surface surf Lambert
float4 _MainColor;
float4 _EmissionColor;
float _AlphaValue;
struct Input {
float4 color : COLOR;
};
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = _MainColor;
o.Emission = _EmissionColor;
o.Alpha = _AlphaValue;
}
// This function defines the lighting model.
// This specific implementation strips all lighting information
// to make all rendered pixels full-bright (useful for in-game pickups/glows
// and the like). This function operates at pixel level.
// @param s The SurfaceOutput information from the 'surf' function.
// @param lightDir The light's direction we can use to calculate
// light-surface interaction with.
// @param atten The light's attenuation factors (attenuation is complex,
// outside the scope of this shader. Lots of information on the webs).
fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten) {
// Declare the variable that will store the final pixel color,
fixed4 c;
// Copy the diffuse color component from the SurfaceOutput
// to the final pixel.
c.rgb = s.Albedo;
// Copy the alpha component from the SurfaceOutput to the final pixel.
c.a = s.Alpha;
return c;
}
ENDCG
}
FallBack "Diffuse"
}