Jump to content
  • Advertisement
Sign in to follow this  
C0nn

D3D10_BLEND_OP_MAX

This topic is 2543 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

[font="arial, verdana, tahoma, sans-serif"]Hey there,
I have a problem understanding the results of this operation. I have attached an image of my small test.

The red cube is drawn first. Blending is only enabled when rendering the second cube (green). The red cube is solid with an alpha value of 1.0. The green cube is semi-transparent with an alpha value of 0.5.
My blend description looks like this:
D3D10_BLEND_DESC desc = {0};
desc.AlphaToCoverageEnable = 0;
desc.BlendEnable[0] = true;
desc.SrcBlend = D3D10_BLEND_ZERO;
desc.DestBlend = D3D10_BLEND_ZERO;
desc.BlendOp = D3D10_BLEND_OP_MAX;
desc.SrcBlendAlpha = D3D10_BLEND_ONE;
desc.DestBlendAlpha = D3D10_BLEND_ZERO;
desc.BlendOpAlpha = D3D10_BLEND_OP_ADD;
desc.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL;

Since the source factor is zero I would assume that the green cube would be invisible; therefore not blended with the red one. The blending equation looks like this afaik:
Csrc * Fsrc (OP) Cdest * Fdest
where Cscr is the color of the source, Fscr is the blending factor of the source, Cdest and Fdest destination color and factor and (OP) the blending operation.
In this case it should be: Max(ZERO, ZERO) = black, but it's not. It seems as if both factors are ignored.

Can someone enlighten me?
Btw, is this something that belongs rather in the beginner section?[/font]

Share this post


Link to post
Share on other sites
Advertisement
I hate to bump my own thread, but is there really nobody who has an idea? I also tried the reference driver with the same result hence I guess that I don't understand blending in DX. huh.gif
Thanks in advance.

Share this post


Link to post
Share on other sites
[source]
desc.SrcBlend = D3D10_BLEND_ZERO;
desc.DestBlend = D3D10_BLEND_ZERO;
desc.BlendOp = D3D10_BLEND_OP_MAX;
[/source]
This says to use ( 0, 0, 0 ) for both source and destination data, and choose the greater. Which doesn't make much sense :D

Share this post


Link to post
Share on other sites
I am not sure I can follow you. I guess that D3D10_BLEND_OP_MAX does a componentwise comparison in the form of
MAX((Rs, Gs, Bs), (Rd, Gd, Bd)) = (MAX(Rs, Rd), MAX(Gs, Gd), MAX(Bs, Bd))
where MAX(a,b) = a if a>b
b if b>a
a=b else

Why wouldn't it make sense if D3D10_BLEND_OP_MAX((0,0,0), (0,0,0)) =(0,0,0)? Even if this would be nonsense, why does the similar operation D3D10_BLEND_OP_MIN yield the expected color, which is black?

Share this post


Link to post
Share on other sites

why does the similar operation D3D10_BLEND_OP_MIN yield the expected color, which is black?

I don't know why D3D10 isn't producing expected results. Is there an effect you're trying to create, or are you just trying to understand the various blend operations?

Share this post


Link to post
Share on other sites
I am reading atm Frank D. Luna's introduction to DirectX 10. In the chapter about blending is a small example with water. He encouraged to experiment with some blending params, which I did. Everything is logical except this operation. I couldn't explain the appearance of the water, therefore I wrote a small test with just these two cubes. And I still can't explain. So no, I had no intention for a special effect, just trying to understand.

Notice that setting both blending factors to zero was just an example. Replacing it with other values (ONE, ALPHA, BLENDFACTOR etc.) still produces the same image. This behavior seems pointless and even less is it documented, hence I think I found a bug in the reference driver cool.gif, unless ofc someone explains why I am wrong.

Share this post


Link to post
Share on other sites
Nope, I think you are right. I just did a quick test in DX9 mixing all possible combinations and both min and max behave as if the factors are always one/one, i.e. ignored. I don't seem to find this mentioned in the docs so far and my google-fu doesn't give me anything useful either.

For OpenGL on the other hand it's crystal clear, e.g. here in wiki: Blending equations. Seems to be the expected behavior and not a bug in the pipeline.

Congrats: You actually demonstrated that docs (and books) can be misleading or even wrong. Won't be the last time, promised ;)

Share this post


Link to post
Share on other sites
Thanks for testing. I also tried finding something on this board and google but couldn't find anything. This operation is obviously not that important so nobody noticed/cared. I am still not sure if this is an error in the docs or in D3D itself. I tend to the latter so I wrote a bug report on Microsoft Connect. Strange that you can't logout from Connect if you don't accept cookies blink.gif .

Hm, should have taken a closer look at your link first. It explicitly states that in OpenGL both factors are ignored. So yes, it is most probably intentional in D3D as well. Oh well, then they can use my report to update the MSDN article. Edited by C0nn

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!