So, I’ve been trying to make a stylized game, with cell shading, and I’m trying to add a texture to an object with cell shading, however, whenever I try to, an error pops up, I don’t know what’s wrong with the code, however it has some thing to do the uv’s and textures.
Here’s my code:
Shader “BestShadersEver/ToonShader”
{
Properties
{
_MainTex (“Texture”, 2D) = “white” {}
_Albedo(“Albedo”, Color) = (1,1,1,1)
_Shades(“Shades”, Range(1,20)) = 3
}
SubShader
{
Tags { “RenderType”=“Opaque” }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include “UnityCG.cginc”
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct v2f
{
float4 vertex : SV_POSITION;
float3 worldNormal : TEXCOORD0;
};
float4 _Albedo;
float _Shades;
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.worldNormal = UnityObjectToWorldNormal(v.normal);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
float cosineAngle = dot(normalize(i.worldNormal), normalize(_WorldSpaceLightPos0.xyz));
fixed4 col = tex2D(_MainTex, i.uv);
cosineAngle = max(cosineAngle, 0.0);
cosineAngle = floor(cosineAngle * _Shades) / _Shades;
return _Albedo * cosineAngle;
}
ENDCG
}
}
}[/code]
Can anyone help me?