Jump to content
  • Advertisement

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!