Transparency in SpriteBatch (Straight Alpha)

Jun 13, 2016 at 2:06 PM
Premultiplied Mode
In Premultiplied mode, to change the transparency, we multiply the Colors::White * 0.75 to get 75% opacity, and pass in to the SpriteBatch's Draw() function.

However, if I modify the Color to Vector4(1,1,1,0), it gives me a very light tint blue on the texture. There is no particular reason why I would do so as I am trying to understand how premultiplied work. I am expecting that the entire texture will not appear since the alpha value is 0. Why is it so?

Straight Alpha
If I set Straight Alpha mode in the SpriteBatch's Begin(), how do I adjust the transparency to 75% opacity in code? Does it work if I use the same method above?

SpriteBatch Default Color for Draw()
Understand that the default color parameter for Draw() is white. I do not understand why the default color of white does not affect the texture's color at all. If white was used, why wasn't the texture looks tinted with white? However, when other colors were used to tint the texture in the Draw() function, it shows that particular color tint.
Coordinator
Jun 13, 2016 at 7:20 PM
Edited Jun 13, 2016 at 7:22 PM
The Premultipled alpha blending state is:
CD3D11_BLEND_DESC desc(default);
desc.RenderTarget[0].BlendEnable = TRUE;
desc.RenderTarget[0].SrcBlend = desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
desc.RenderTarget[0].DestBlend = desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
The Straight alpha blending state is:
CD3D11_BLEND_DESC desc(default);
desc.RenderTarget[0].BlendEnable = TRUE;
desc.RenderTarget[0].SrcBlend = desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
desc.RenderTarget[0].DestBlend = desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
So the behavior comes down to the math. See Shawn Hargreaves blog for some articles on understanding premultipled alpha.

Vector4(1,1,1,0) is not a valid premultipled value which would have to be Vector4(0,0,0,0).

If you are using straight-alpha, the correct solution is to just modify the alpha value and leave the RGB channels unchanged. So to get 75% opaque white you'd use:
Vector4 clr = Colors::White;
clr.w = 0.75f;
or
XMVectorSetW(Colors::White, 0.75f);
The reason that Colors::White * .75f works for premultipled alpha is that Colors::White is equivalent to Vector4(1,1,1,1) so you end up with Vector4(0.75f, 0.75f, 0.75f, 0.75f) which is a valid premultiplied value.
Marked as answer by pentocrypt on 6/15/2016 at 6:58 PM