I’ve just recently got my game to build onto an iPhone 3GS, and for reasons unknown, this shader refuses to draw.
The shader’s pretty simple, flat colour with a black outline based on view/surface normal cutoff. Then renders the back-side in the same fashion but with half the brightness.
It’s used to render cloth that’s on my character. It’s skinned cloth, which is why it’s a double sided shader (can’t simply duplicate/flip the mesh normals in my 3D app). The mesh renders fine if I apply the same shader minus the second pass. The fallback’s simple a fixed function equivalent.
Renders fine on Android.
Any thoughts?
Shader "BeforeDeath/Unlit Outline Double Sided" {
Properties {
_MainTex ("Diffuse (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" "IgnoreProjector"="True" "Queue"="Geometry" "LightMode" = "Always" }
Lighting Off
LOD 200
Pass {
Cull Back
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_builtin
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
fixed2 uv : TEXCOORD0;
float vLight : TEXCOORD1;
};
float4 _MainTex_ST;
v2f vert (appdata_base v) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
o.vLight = dot(ObjSpaceViewDir(v.vertex), v.normal);
return o;
}
sampler2D _MainTex;
fixed4 frag(v2f i) : COLOR {
fixed4 c = fixed4 ( 0.0 );
c.rgb = tex2D ( _MainTex, i.uv ) * step ( 0.25, i.vLight ); // Colour outline.
return c;
}
ENDCG
}
Pass {
Cull Front
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_builtin
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
fixed2 uv : TEXCOORD0;
float vLight : TEXCOORD1;
};
float4 _MainTex_ST;
v2f vert (appdata_base v) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
o.vLight = dot(ObjSpaceViewDir(v.vertex), -v.normal);
return o;
}
sampler2D _MainTex;
fixed4 frag(v2f i) : COLOR {
fixed4 c = fixed4 ( 0.0 );
c.rgb = tex2D ( _MainTex, i.uv ).rgb * step ( 0.25, i.vLight ) * 0.5; // Colour outline darken.
return c;
}
ENDCG
}
}
FallBack "BeforeDeath/Unlit Double Sided"
}