- Home /
Shader Doesn't Work On Android
Why doesn't this shader work on Android? I just alpha blend two textures.
Shader "Cone/Tile" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Wallpaper ("Wallpaper", 2D) = "white" {}
}
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform sampler2D _Wallpaper;
struct input
{
float4 vertex : POSITION;
float4 tc : TEXCOORD0;
};
struct vertOut {
float4 pos : SV_POSITION;
float4 scrPos;
float2 tc;
};
vertOut vert(input i) {
vertOut o;
o.pos = mul (UNITY_MATRIX_MVP, i.vertex);
o.scrPos = ComputeScreenPos(o.pos);
o.tc = i.tc.xy;
return o;
}
fixed4 frag(vertOut i) : COLOR0 {
float2 wcoord = i.scrPos.xy / i.scrPos.w;
fixed4 tex = tex2D(_MainTex, i.tc);
return tex2D(_Wallpaper, wcoord) * (1 - tex.a) + tex * tex.a;
}
ENDCG
}
}
Fallback "Unlit/Texture"
}
Comment
Answer by Jespertheend2 · Sep 11, 2016 at 09:51 PM
I have a shader that uses ComputeScreenPos
as well and I'm getting reports that it isn't working either. Only on some devices though. I see your shader has ComputeScreenPos
as well so that might be the cause of it.