So, I made a spine model and i imported it into Unity and everything went fine.
Since I needed to do some lighting and the SkeletonLit shader is way less luminous than the standard UnityDiffuse one, I wrote my own shader to make Spine models and background shaders match.
The problem is, that on some junctions (and I emphasize some, as it happens only on 2 or three junctions, of all the various skins of the character) there is a weird shader overlapping happening and I don't know how it comes up and what to do to solve it. It looks like, while all the other attachments are on different z-indexes, those two are on the same one, which makes no sense as I didn't touch anything on import, and on the spine project (as far as I know you can't have two attachments on the same draw order layer) everything is set up correctly.
Here is the shader code and below I attached a screenshot of the problem I get (one pic of the error, and one of all the other correct junctions).
Shader "EvilSystem/SpineSkeletonDiffuse"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
}
SubShader
{
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
LOD 100
Cull Off
//Lighting Off
ZWrite Off
//ZTest LEqual
Blend One OneMinusSrcAlpha
Pass {
Tags { "LightMode"="Vertex" }
ColorMaterial AmbientAndDiffuse
Lighting On
SetTexture [_MainTex] {
Combine texture * primary DOUBLE, texture * primary
}
}
CGPROGRAM
#pragma surface surf Lambert vertex:vert nofog keepalpha
#pragma multi_compile _ PIXELSNAP_ON
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
uniform sampler2D _MainTex;
fixed4 _Color;
uniform fixed _Cutoff;
struct Input
{
float2 uv_MainTex;
fixed4 color;
};
void vert (inout appdata_full v, out Input o)
{
#if defined(PIXELSNAP_ON)
v.vertex = UnityPixelSnap (v.vertex);
#endif
UNITY_INITIALIZE_OUTPUT(Input, o);
o.color = v.color * _Color;
}
fixed4 SampleSpriteTexture (float2 uv)
{
fixed4 color = tex2D (_MainTex, uv);
clip(color.a - _Cutoff);
return color;
}
void surf (Input IN, inout SurfaceOutput o)
{
fixed4 c = SampleSpriteTexture (IN.uv_MainTex) * IN.color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
// 1 texture stage GPUs
SubShader {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
LOD 100
Cull Off
ZWrite Off
Blend One OneMinusSrcAlpha
Pass {
Tags { "LightMode"="Vertex" }
ColorMaterial AmbientAndDiffuse
Lighting On
SetTexture [_MainTex] {
Combine texture * primary DOUBLE, texture * primary
}
}
}
}