How to do smooth Alpha channel keying with Silverlight 3 Pixel Shaders?
I want some HLSL filter (like this Shazzam HLSL example)
sampler2D implicitInputSampler : register(S0);
float4 main(float2 uv : TEXCOORD) : COLOR
{
float4 color = tex2D( implicitInputSampler, uv );
if( color.r + color.g + color.b < 1.9 ) {
color.rgba = 0;
}
return color;
}
to key not just the color I’m trying to key but for example if dark red consists of red and blue and I’m keying all blue i want to get transparent red.
(Probably this picture can explain what do I want)

(source: narod.ru)
Sounds like you just want to subtract a color rather then key it.
float4 subtract = ... ; // color you want to remove
float4 color = ... ;
color.r -= subtract.r;
... // for b and g
if ( color.r < 0 )
color.r = 0;
... // for b and g
After this, you can then use a color chooser to pick which color "subtract" would be and remove it. Hope thats what your trying to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With