Custom Shader not working correctly on Android

Hello All, i have a little problem with the shader i wrote i’m using for a game.

What i’m trying to accomplish is to invert the colors of an object when it is under a specific area. With this code i’m inputting the areas which the objects will be inverted with _Hor1… _Ver1…_Diag1…, I couldn’t figure out how to input them as array so this is the case.

The shader is working perfectly fine in editor and PC standalone, also webgl build, but with android, objects always get inverted regardless of the values.

I’m new to shaders so i’m not sure what i’m doing here.

Thanks :0)

Shader "Custom/CustomCutout" {
	Properties{
		_Color("Main Color", Color) = (1,1,1,1)

		_Hor1("FFFF", Vector) = (44,16,1,1)
		_Hor2("UUUU", Vector) = (44,-16,1,1)
		_Hor3("CCCC", Vector) = (30,-16,1,1)
		_Hor4("KKKK", Vector) = (30,16,1,1)

		_Ver1("TTTT", Vector) = (44,16,1,1)
		_Ver2("HHHH", Vector) = (44,-16,1,1)
		_Ver3("IIII", Vector) = (30,-16,1,1)
		_Ver4("SSSS", Vector) = (30,16,1,1)

		_Diag1("SSSS", Vector) = (44,16,1,1)
		_Diag2("HHHH", Vector) = (44,-16,1,1)
		_Diag3("IIII", Vector) = (30,-16,1,1)
		_Diag4("TTTT", Vector) = (30,16,1,1)
	}

	SubShader{
		Tags{ "RenderType" = "Opaque" }
		Lighting Off
		LOD 100

		Pass{
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag

			#include "UnityCG.cginc"

			struct simplePos {
				float4 vertex : POSITION;
			};

			struct v2f {
				float4 vertex : SV_POSITION;
				half2 worldPos : TEXCOORD0;
			};

			fixed4 _Color;

			half2 _Hor1;
			half2 _Hor2;
			half2 _Hor3;
			half2 _Hor4;

			half2 _Ver1;
			half2 _Ver2;
			half2 _Ver3;
			half2 _Ver4;

			half2 _Diag1;
			half2 _Diag2;
			half2 _Diag3;
			half2 _Diag4;

			half CalculateDistanceOfTwoPoints(half2 p_One, half2 p_Two) {
				return sqrt(pow((p_One.x - p_Two.x), 2) + pow((p_One.y - p_Two.y), 2));
			}

			half CalculateAreaOfTriangle(half2 p_One, half2 p_Two, half2 p_Three) {

				half2 a = CalculateDistanceOfTwoPoints(p_One, p_Two);
				half2 b = CalculateDistanceOfTwoPoints(p_Two, p_Three);
				half2 c = CalculateDistanceOfTwoPoints(p_One, p_Three);
				half2 s = (a + b + c) / 2;

				return sqrt(s * (s - a) * (s - b) * (s - c));
			}

			half CalculatePointInRect(half2 p_Point, half2 p_One, half2 p_Two, half2 p_Three, half2 p_Four) {
				float p_BaseArea = ceil(CalculateDistanceOfTwoPoints(p_One, p_Two) * CalculateDistanceOfTwoPoints(p_Two, p_Three)) * 1.01;

				half p_First = CalculateAreaOfTriangle(p_Point, p_One, p_Two);
				half p_Second = CalculateAreaOfTriangle(p_Point, p_Two, p_Three);
				half p_Third = CalculateAreaOfTriangle(p_Point, p_Three, p_Four);
				half p_Fourth = CalculateAreaOfTriangle(p_Point, p_Four, p_One);

				half p_Area = p_First + p_Second + p_Third + p_Fourth;

				return sign(floor(p_Area - p_BaseArea));
			}

			v2f vert(simplePos v)
			{
				v2f o;
				o.worldPos = mul(unity_ObjectToWorld, v.vertex);
				o.vertex = UnityObjectToClipPos(v.vertex);
				return o;
			}

			fixed4 frag(v2f i) : COLOR
			{
				half _Condition = CalculatePointInRect(i.worldPos.xy, _Hor1.xy, _Hor2.xy, _Hor3.xy, _Hor4.xy )* CalculatePointInRect(i.worldPos.xy, _Ver1.xy, _Ver2.xy, _Ver3.xy, _Ver4.xy)* CalculatePointInRect(i.worldPos.xy, _Diag1.xy, _Diag2.xy, _Diag3.xy, _Diag4.xy);
				return lerp(1 - _Color, _Color, _Condition);
			}
			ENDCG
		}
	}
}

Under shader targets here, i found out that i was under a instruction count restriction. The problem was because of that.

Edit1 : Interestingly doing the necessary calculations in vertex shader rather than fragment shader fixed the problem.