I believe that the problem in this frag(line 82),I tried several times , but without result.
The goal is that the effect on mobile becomes similar to the PC(this shader works on PC).
It is the shader “Toony -Basic” with splatmap , needs no light at all .
If you try use it on android, it will be pink.
phone model: Huawei Ascend G610.
I made this changers on “Toony -Basic”:
-Add some Properties, Lines 7-14
-Add iniform sampler2D, Lines 47-48
-Add struct Input, line 73-80
-Change “float4 frag (v2f i) : COLOR” to “float4 frag (v2f i,Input IN) : COLOR, line 82”, add Input IN
-Add splat efect, lines 87 - 91
-change “return float4(2.0f cube.rgb col.rgb, col.a);” to “return float4(2.0f cube.rgb col2.rgb col.rgb, col2.a col.a);”, just by add col2, line 91.
Shader "Custom/myToonLightfake"
{
Properties
{
// Control Texture ("Splat Map")
_Control ("Control (RGBA)", 2D) = "red" {}
// Terrain textures - each weighted according to the corresponding colour
// channel in the control texture
_Splat3 ("Layer 3 (A)", 2D) = "black" {}
_Splat2 ("Layer 2 (B)", 2D) = "gray" {}
_Splat1 ("Layer 1 (G)", 2D) = "gray" {}
_Splat0 ("Layer 0 (R)", 2D) = "gray" {}
// Used in fallback on old cards & also for distant base map
_MainTex ("BaseMap (RGB)", 2D) = "white" {}
_Color ("Main Color", Color) = (1,1,1,1)
// Colour of toon outline
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_Outline ("Outline width", Range (.002, 0.05)) = .05
_ToonShade ("ToonShader Cubemap(RGB)", CUBE) = "" { Texgen CubeNormal }
}
SubShader
{
Tags { "RenderType"="Opaque" }
Pass
{
Cull Off
Name "myToonLightfake"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
sampler2D _MainTex;
samplerCUBE _ToonShade;
float4 _MainTex_ST;
float4 _Color;
uniform sampler2D _Control;
uniform sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
struct appdata
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float3 normal : NORMAL;
};
struct v2f
{
float4 pos : POSITION;
float2 texcoord : TEXCOORD0;
float3 cubenormal : TEXCOORD1;
};
v2f vert (appdata v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.cubenormal = mul (UNITY_MATRIX_MV, float4(v.normal,0));
return o;
}
struct Input
{
float2 uv_Control : TEXCOORD0;
float2 uv_Splat0 : TEXCOORD1;
float2 uv_Splat1 : TEXCOORD2;
float2 uv_Splat2 : TEXCOORD3;
float2 uv_Splat3 : TEXCOORD4;
};
float4 frag (v2f i,Input IN) : COLOR
{
float4 col2 = _Color * tex2D(_MainTex, i.texcoord);
float4 cube = texCUBE(_ToonShade, i.cubenormal);
fixed4 splat_control = tex2D (_Control, IN.uv_Control);
fixed4 col;
col = _Color *splat_control.r * tex2D (_Splat0, IN.uv_Splat0);
col += _Color *splat_control.g * tex2D (_Splat1, IN.uv_Splat1);
col += _Color *splat_control.b * tex2D (_Splat2, IN.uv_Splat2);
col += _Color *splat_control.a * tex2D (_Splat3, IN.uv_Splat3);
return float4(2.0f * cube.rgb * col2.rgb * col.rgb, col2.a * col.a);
}
ENDCG
}
//UsePass "Custom/myOutline/OUTLINE"
}
//Fallback "Toon/Basic"
} // Ehd Shader