What pixel shader can I use to remove a background color, but keep transparent pixels?

745 Views Asked by At

I can use a pixel shader in WPF to remove a specific color, but there are alpha pixels layered over the background. I want to remove a background color, but keep alpha pixels.

For example, I have Image 1. It is a red rectangle with opacity 50% overlaid on a solid black background. I want to remove the black background so that the red rectangle stays alpha 50% and then I can overlay the resulted image on blue background like on Image 2-3 (left).

But by using a pixel shader to remove a specific color, I get Image 2-3 (right), which is not what I want.

Image 2-3.

  1. Is it possible?
  2. How is this process called?
  3. What pixel shader can I use to do it in WPF?
0

There are 0 best solutions below