# DX11 Bitwise OR BlendState

## Recommended Posts

Posted (edited)

Is it possible to implement bitwise OR blending between colors using a custom BlendState?

This, of course, implies that writing to a render target that is then sampled to perform the calculations in the pixel shader is out of the question.

In my case each RGB component is a bit field and I only need to set one bit at a time. Alpha can be whatever. So for example, if I want to set bit 3 (2^3) of red component in back buffer I would return this in the pixel shader:

return float4(8, 0, 0, 1);

The expected behaviour is that if bit 3 in red component is already 1 then nothing will change, but if it is 0 then it will be set to 1.

Edited by CSharpCoder

##### Share on other sites
Posted (edited)

It is, if you can create a 11.1 Device (depends on which OS you're running). Only then you can create a ID3D11BlendState1. D3D11_RENDER_TARGET_BLEND_DESC1's LocalOp entry allows what you're after (see here, for your case that's D3D11_LOGIC_OP_OR). Also enable LogicOpEnable.

If not, there's no way around blending "manually", i.e. perform the operation in a custom pixel shader. Depending on your setup, this may or may not work.

Edited by unbird

##### Share on other sites

5
1 hour ago, unbird said:

It is, if you can create a 11.1 Device (depends on which OS you're running). Only then you can create a ID3D11BlendState1. D3D11_RENDER_TARGET_BLEND_DESC1's LocalOp entry allows what you're after (see here, for your case that's D3D11_LOGIC_OP_OR). Also enable LogicOpEnable.

That unfortunately is not an option for me.

## Create an account

Register a new account

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 12
• 18
• 15
• 9
• 9