- Home /
Problem with custom shader (ShaderLab + Cg)
Hi. I'm newbie in Cg. It is my first my own shader. It is perfectly works on android and Windows platform. But when we speak about iOs platform, some horrible thing begins. When model with this shader displayed for first time all is ok: but when I disable gameobject and reactivate it again, the surface is seems to be deformed. I'm using OpenGl ES 3 api for iOs, and OpenGl ES 2 api for android. Here is my code:
Shader "AlphaVideo" {
Properties{
_MainTex("Base (RGB)", 2D) = "white" {}
_Mask("Mask (RGB)", 2D) = "white" {}
}
SubShader{
Tags{ "Queue" = "transparent" "RenderType" = "transparent" }
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Lighting Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
sampler2D _MainTex;
sampler2D _Mask;
float4 _Mask_ST;
float4 _MainTex_ST;
v2f vert(v2f v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.pos);
o.uv = v.uv;
return o;
}
half4 frag(v2f i) : COLOR
{
float2 uv2 = TRANSFORM_TEX(i.uv, _Mask);
float2 uv1 = TRANSFORM_TEX(i.uv, _MainTex);
half4 base = tex2D(_MainTex, uv1);
half4 a = tex2D(_Mask, uv2);
base.a = a.b;
return base;
}
ENDCG
}
}
}
Comment
UPD: I found that this problem is active only if OpenGl ES 3 api is used. On OpenGL ES2 and $$anonymous$$etal all is O$$anonymous$$.
Answer by SunnyChow · Sep 27, 2016 at 05:00 AM
I remember in some platform, it only allows one set of Scale & Tile. I am not sure if this is the case