Shader not working correctly on iOS

Hi,all

I have a problem, my shader cannot work correctly on iOS, while it work correct on Windows, macOS, and Android.
As the code below, the shader make while color for each pixel on PC and Android. But on iOS, the color is blue. So i think maybe the vertex position is always 0.(the x and y coordinate for i.pos in fragment shader are both 0 for each pixel).
If I use other semantic binding for pos, such as TEXCOORD1, the vertex position is not 0 on iOS.
I tried 5.4 and 5.5 version of Unity, and the XCode version is 8.1.

Thank you for any help!

Shader "Custom/SimpleShader"
{
SubShader
{
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
};
v2f vert(appdata_img v)
{
v2f o;
o.pos = v.vertex;
return o;
}
float4 frag(v2f i) : SV_Target
{
return float4(i.pos.x, i.pos.y, 1.0, 1.0);
}
ENDCG
}
}
}

See VPOS:

Thank you very much! Solved my problem!

I know this was 5 years (wow time goes by fast!), but I hate when people find the solution and just say “thanks, I solved it”.

What was wrong and what did you actually change to solve it?

2 Likes