2
\$\begingroup\$

I am using XNA 4.0, hence DX9 and HLSL. I have a RenderTarget2D "MAIN" that I want to add semi-transparent objects "TRANS" to. I want them to blend with MAIN using the TRANS's alpha and inverseAlpha BUT I want to preserve information kept in the MAIN's alpha channel.

If I simply use BlendState.AlphaBlend, MAIN's alpha channel becomes 1 everywhere where TRANS is written. I know there is a property in the BlendState class that prevents writing to color channels Is there an option that prevents writing to alpha?

Thanks.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

BlendState.ColorWriteChannels is a bitfield with a bit for each of the four channels. You can make it write to RGB only by setting

blendState.ColorWriteChannels = ColorWriteChannels.Red | ColorWriteChannels.Green | ColorWriteChannels.Blue; 
\$\endgroup\$
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.