How to add Outline to ChromaKey Shader?

Hi there,

for a project we have to use videocontent. The videos contain alpha through greenscreen keying by chroma key shading. The result is a movietexture with a moving cutout person. We want to make an outline around the cutout person.
So far we have the ability to colorize the cutout person. What is something that is also needed.

Our colorizable ChromeKey Shader is written thanks to the thread Chroma Key in Unity 5 - Learn Content & Certification - Unity Discussions

How we have to modify the shader, to combine it with an outline? We managed outline shading on images with alpha, but not on the current shader which creates an alpha at runtime from color-keying. (current shader code below)

Greetings,

Martin

The current shader code:

Shader"KIDS/ChromaKeyWithColor" {

Properties {
_MainTex (“Base(RGB)”, 2D) = “white” {}
_thresh (“Threshold”, Range (0, 16)) = 0.8
_slope (“Slope”, Range (0, 1)) = 0.2
_keyingColor (“KeyColor”, Color) = (1,1,1,1)
_overlayColor (“OverlayColor”, Color) = (1,1,1,1)
}

SubShader {
Tags {“Queue”=“Transparent”“IgnoreProjector”=“True”“RenderType”=“Transparent”}

LightingOn
ZWriteOff
AlphaTestOff
BlendSrcAlphaOneMinusSrcAlpha

Pass {
CGPROGRAM
#pragmavertexvert_img
#pragmafragmentfrag
#pragmafragmentoptionARB_precision_hint_fastest

sampler2D _MainTex;
float3 _keyingColor;
float4 _overlayColor;
float _thresh;
float _slope;

#include “UnityCG.cginc”

float4 frag(v2f_img i) : COLOR{
float3 input_color = tex2D(_MainTex,i.uv).rgb;
float d = length(_keyingColor.rgb - input_color.rgb);
float edge0 = _thresh * (1 - _slope);
float alpha = smoothstep(edge0, _thresh, d);

float valueOverlayR = (_overlayColor.r * _overlayColor.a);
float valueOverlayG = (_overlayColor.g * _overlayColor.a);
float valueOverlayB = (_overlayColor.b * _overlayColor.a);

input_color.r = (input_color.r * (1 - _overlayColor.a)) + valueOverlayR;
input_color.g = (input_color.g * (1 - _overlayColor.a)) + valueOverlayG;
input_color.b = (input_color.b * (1 - _overlayColor.a)) + valueOverlayB;

if (input_color.r > 1) {
input_color.r = 1;
}
if (input_color.g > 1) {
input_color.g = 1;
}
if (input_color.b > 1) {
input_color.b = 1;
}

returnfloat4(input_color, alpha);
}
ENDCG
}
}

FallBack"Unlit/Texture"
}

bump