Would anyone know why I’d get an error when compiling a shader for metal? The shader works fine on gles 2.0, but for some reason generates an error with metal… Here is the code (you might recognize it if you saw my other thread) and the error below:
Anyone have any ideas about the issue? Thanks for any help!
Shader "Hidden/Glow 11/Blur GL" {
Properties {
_MainTex ("", 2D) = "" {}
}
CGINCLUDE
#include "UnityCG.cginc"
struct v2f {
half4 pos : POSITION;
half4 uv[5] : TEXCOORD0;
};
sampler2D _MainTex;
half4 _MainTex_TexelSize;
struct appdata_glow {
half4 vertex : POSITION;
half4 texcoord[5] : TEXCOORD;
};
v2f vert( appdata_glow v )
{
v2f o;
float offX = _MainTex_TexelSize.x;
float offY = _MainTex_TexelSize.y;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv[0] = v.texcoord[0] + float4(offX*.5f,offY*.5f,0,0);
o.uv[1] = v.texcoord[1]+ float4(-offX*1.5f,-offY*1.5f,0,0);
o.uv[2] = v.texcoord[2]+ float4(-offX,-offY,0,0);
return o;
}
fixed4 frag(v2f pixelData) : COLOR
{
return tex2D(_MainTex, pixelData.uv[0]) * .2270270270f +
(tex2D(_MainTex, pixelData.uv[1]) + tex2D(_MainTex, pixelData.uv[2])) * .3162162162f;
}
ENDCG
Subshader {
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
ColorMask RGB
CGPROGRAM
#pragma glsl
#pragma only_renderers gles opengl gles3 metal
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment frag
ENDCG
}
}
Fallback off
And the error:
Invalid unit for GL texcoord (got 4 but only 0…3 valid)
System.InternalEnumerator1:get_Current() UnityEngine.Graphics:Internal_BlitMultiTap(Texture, RenderTexture, Material, Vector2[ ]) UnityEngine.Graphics:BlitMultiTap(Texture, RenderTexture, Material, Vector2[ ]) Glow11.Blur.BlurBase:BlurBuffer(RenderTexture, RenderTexture) Glow11.Blur.DefaultBlur:BlurAndBlitBuffer(RenderTexture, RenderTexture, Settings, Boolean) Glow11.Blur.AdvancedBlur:BlurAndBlitBuffer(RenderTexture, RenderTexture, Settings, Boolean) Glow11.Glow11:OnRenderImage(RenderTexture, RenderTexture) System.InternalEnumerator1:get_Current()
[ line 1783]
(Filename: Line: 1783)
Metal: Error creating pipeline state: Vertex attribute 2 is not defined in the vertex layout.