Jump to content
  • Advertisement
Sign in to follow this  
Endemoniada

Custom Blend Mode

This topic is 2590 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, I want my blend mode to be equivalent to Photoshop's Screen mode which is:

Result = 1 - (1 - Target) * (1 - Source)

I'm using D3D9.

How can I do this ? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Unfortunately you can't do this exactly with fixed-function blend modes. If you're using shaders and just want to combine two images this way it's obviously pretty easy to do manually in there :(
EDIT: Disproved, see below.

Share this post


Link to post
Share on other sites
Let's rearrange a little, whereas t = Target and s = Source
Result = 1 - (1 - t) * (1 - s)
= 1 - (1 - t - s + st)
= 1 - 1 + t + s - st
= t + s - st
= s + t (1-s)

That would be: SrcBlendFactor = One, DstBlendFactor = InverseSrcColor and BlendOp = Add.

Share this post


Link to post
Share on other sites

Let's rearrange a little, whereas t = Target and s = Source
Result = 1 - (1 - t) * (1 - s)
= 1 - (1 - t - s + st)
= 1 - 1 + t + s - st
= t + s - st
= s + t (1-s)

That would be: SrcBlendFactor = One, DstBlendFactor = InverseSrcColor and BlendOp = Add.


Agh, you're right! I tried to be more 'elegant' and got stuck when I needed to force the target factor to be a constant one, but this works out. Carry on :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!