Outline Shader has visible gaps

Hey everyone,

First post here but there will be a lot more in the future. I’m currently making a ‘graphics test’ for a project with friends, looking at how we could make a turn-based squad game look good with minimal assets and animation. one of the solutions is the use of unanimated ‘cards’ or ‘pawns’ on-screen (unrelated but any other ideas like this would be greatly appreciated)

I made a card model in Maya and slapped on a quick texture. Now I’m trying to apply an outline shader from the unity wiki but the outline is not attached to the edges and is showing visible gaps. I’m thinking it’s an issue with my model, because the rocks from the Free Rocks Pack are doing fine (outline is a lot thicker on the same setting aswell). Any ideas?

This is the shader in question, only difference is I added the texture and a bigger range of outline
http://wiki.unity3d.com/index.php/Outlined_Diffuse_3

This image shows the tri setup of the card model, maybe that’s causing the issue

This is normal (no pun intended) behavior. As soon as the angle between two face’s normal vectors becomes too high, such gaps will appear. I recommend taking a look at this shader, which has been slightly modified from this thread:

//http://forum.unity3d.com/threads/96393-Achieving-a-multi-pass-effect-with-a-Surface-Shader
//http://answers.unity3d.com/questions/11175/how-to-make-an-outline-of-an-object-behind-a-wall.html

Shader "Outlined/NewOcclusionOutline" {
Properties {
    _Color ("Main Color", Color) = (.77,.77,.77,1)
    _RimCol ("Rim Colour" , Color) = (1,0,0,1)
    _RimPow ("Rim Power", Float) = 1.0
    _MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
    Pass {
            Name "Behind"
            Tags { "RenderType"="transparent" "Queue" = "Transparent" }
            Blend SrcAlpha OneMinusSrcAlpha
            ZTest Greater               // here the check is for the pixel being greater or closer to the camera, in which
            Cull Back                   // case the model is behind something, so this pass runs
            ZWrite Off
            LOD 200                   
          
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"
          
            struct v2f {
                float4 pos : SV_POSITION;
                float2 uv : TEXCOORD0;
                float3 normal : TEXCOORD1;      // Normal needed for rim lighting
                float3 viewDir : TEXCOORD2;     // as is view direction.
            };
          
            sampler2D _MainTex;
            float4 _RimCol;
            float _RimPow;
          
            float4 _MainTex_ST;
          
            v2f vert (appdata_tan v)
            {
                v2f o;
                o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
                o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
                o.normal = normalize(v.normal);
                o.viewDir = normalize(ObjSpaceViewDir(v.vertex));       //this could also be WorldSpaceViewDir, which would
                return o;                                               //return the World space view direction.
            }
          
            half4 frag (v2f i) : COLOR
            {
                half Rim = 1 - saturate(dot(normalize(i.viewDir), i.normal));       //Calculates where the model view falloff is      
                                                                                                                                   //for rim lighting.
              
                half4 RimOut = _RimCol * pow(Rim, _RimPow);
                return RimOut;
            }
            ENDCG
        }

        Pass {
            Name "BASE"
            ZWrite On
            ZTest LEqual
            Blend SrcAlpha OneMinusSrcAlpha
            Material {
                Diffuse [_Color]
                Ambient [_Color]
            }
            Lighting On
            SetTexture [_MainTex] {
                ConstantColor [_Color]
                Combine texture * constant
            }
            SetTexture [_MainTex] {
                Combine previous * primary DOUBLE
            }
        }
              
    }
    //FallBack "VertexLit"
    FallBack "Diffuse"
}