0

Is it possible (in shader) to change the color of pixels which are identical to the background color?

Thanks

Edit: The background color is white. So is it not possible just to compare each pixel color to white color in Pixel Shader and if equal then just replace it with a desired color?

1 Answer 1

0

Yes, but only in an indirect way. You have to render your scene onto a rendertarget. Then you render a fullscreenquad over your backbuffer with the rendertarget as input texture, whereby you run a pixelshader, which replace a color specified via a shader constant with another color. Keep in mind, that any kind of multisampling would lead to halos at the border, because there the background color isn't exact the original color anymore.

Sign up to request clarification or add additional context in comments.

2 Comments

Is the color returned by pixelshader the same color that is accessible by rendertarget2d GetData method in XNA?
If you're using the rendertarget for clearing and rendering GetData would return all pixeldata of your image. You could manipulate them at the CPU, but that would be extremely slow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.