Hello unity forum members,
I am trying to make the background from a guitarplayer in unity transparent.
I followed the instructions from this thread post:
http://forum.unity3d.com/threads/48938-chroma-key-shader?p=771175&viewfull=1#post771175
And it works great, though the problem is that the guitar player is completely black.
How can I get the color back?
Shadercode used:
Shader "Custom/VideoAlpha" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_AlphaOffsetX ("alpha offset x", float) = 0.5
_AlphaOffsetY ("alpha offset y", float) = 0
_Cutoff ("Cutoff", Range (0,1)) = .5
}
SubShader {
AlphaTest Less [_Cutoff]
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
float _AlphaOffsetX;
float _AlphaOffsetY;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
IN.uv_MainTex.x += _AlphaOffsetX;
IN.uv_MainTex.y += _AlphaOffsetY;
half4 d = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = (d.r*-1)+1;
}
ENDCG
}
FallBack "Diffuse"
}