GreenScreen cromakey?

Mar 9, 2009 at 10:28 PM
Edited Mar 9, 2009 at 10:30 PM
I wanna do a effect that functions like "Greenscreen cromakey". Ex. A person i filmed in fron of a green wall, with the shader effect I want to remove all the green (make it alpha) - More on Greenscreen cromakey: http://en.wikipedia.org/wiki/Chroma_key

Here is a shader I did, it works, but I stil get some green garbage around edges of hair and clotes, I need to smooth it, of add more green color tones.

Any idéa?

 

//--------------------------------------------------------------------------------------

//

// WPF ShaderEffect HLSL -- GreenScreenEffect

//

//--------------------------------------------------------------------------------------

//-----------------------------------------------------------------------------------------

// Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.)

//-----------------------------------------------------------------------------------------

 

float GreenColor : register(C0);

float Gain : register(C1);

//--------------------------------------------------------------------------------------

// Sampler Inputs (Brushes, including ImplicitInput)

//--------------------------------------------------------------------------------------

 

sampler2D implicitInputSampler : register(S0);

//--------------------------------------------------------------------------------------

// Pixel Shader

//--------------------------------------------------------------------------------------

float4 main(float2 uv : TEXCOORD) : COLOR

{

float4 color = tex2D( implicitInputSampler, uv );

 

//GreenColor

if( color.r + color.b - (color.g+(GreenColor/10)) < (Gain/10)) {

color.rgba = 0;

}

 

return color;

}