Is Alpha to Coverage supported?

I’ve used this feature before in native DX11 and I was wondering if it was supported in Monogame? Would definitely prefer this over traditional alpha testing or other not so pretty alternatives.

MonoGame does not expose the AlphaToCoverageEnable member of blend state description, so you can currently not do this through the MG API directly. You can probably hack it in through reflection.

Or you could implement it in MonoGame! That way you don’t have to use reflection hacks and other people can use this feature too.
It should be pretty easy for DX considering it’s just a Boolean value in the blend state. If you want to go ahead and implement it, feel free to ask anything. The gitter channel is a great place for quick help.
What needs to be done for this to work is:

  1. Add an AlphaToCoverage Boolean property to blend state ( and document it saying it only works on DirectX for now and is ignored for other backends.
  2. In BlendState.DirectX set the AlphaToCoverage on the DX blend state description to the value of the property:

That’s it!

Sounds like you could have done that in the time you needed to write that post @Jjagg haha

1 Like

That’s true, but I like to encourage people to contribute! :smiley:
Easy issues like this are a great way to start for someone who’d like to contribute to MG.

Well I’ve tried implementing it but it doesn’t seem to work properly. It looks as if there’s some kind of built in cutoff being used which wouldn’t make any sense. This was tested through spritebatch and basic effect. Changing the blend state combinations aren’t helping either.

This is kind of odd though, usually the downside to this feature is that some GPUs will render incorrectly giving a checkerboard/net like pattern. But this is straight up clipping the alpha after a certain point.

Was there anything else you had to do using DirectX directly to get it working? Other than setting the AlphToCoverage in the blend state description.

No, just having that feature enabled in the description makes it look terrible. I’m not experienced with SharpDX but it could possibly be an issue with that. I have used this feature in a C++ project before (same blend settings that I tried in Monogame) and it looks fine there.

Alternatively, might be a GPU issue but I hope that’s not the case.

SharpDX is very reliable in general. Maybe MG has some other settings that affect the alpha to coverage. It might be worth a shot to compare the complete blend state description in your DX project vs the MonoGame blend state description.

I will try to come up with a simple test program that showcases the issue later on tonight when I get a chance. As well as include source code. (excuse my sloppy C++ code in advance)

1 Like