   [SlimDX] Learning Alpha Blending
  Learning alpha blendingI can enable it so it works in two different manners, some sort of low quality transparency and high quality transparency.I get the HQ tranparency by adding this in the effect file:BlendState SrcAlphaBlendingAdd{    BlendEnable[0] = TRUE;    SrcBlend = SRC_ALPHA;    DestBlend = INV_SRC_ALPHA;    BlendOp = ADD;    SrcBlendAlpha = ZERO;    DestBlendAlpha = ZERO;    BlendOpAlpha = ADD;    RenderTargetWriteMask[0] = 0x0F;};And the SetBlendState line in the pass definition: (1)technique10 tech01{    pass P0    {SetGeometryShader( 0 );SetVertexShader( CompileShader( vs_4_0, VS() ) );SetPixelShader( CompileShader( ps_4_0, PStextura() ) );SetBlendState( SrcAlphaBlendingAdd, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF ); // (1)    }}with this result:  I'd like to achieve that result enabling alpha blending in my program code.So I comment out the last line in (1) in my effect file, and then try to enable it in my program code.I add this lines: (2)    BlendStateDescription bsd = new BlendStateDescription() { IsAlphaToCoverageEnabled=true, AlphaBlendOperation = BlendOperation.Add, SourceAlphaBlend = BlendOption.Zero, DestinationAlphaBlend = BlendOption.Zero, BlendOperation= BlendOperation.Add, SourceBlend = BlendOption.SourceAlpha, DestinationBlend = BlendOption.InverseSourceAlpha  }; OblendSt_transparencias = BlendState.FromDescription (dispG, bsd);    ( ... )    dispG.OutputMerger.BlendState = OblendSt_transparencias;What I get is this, wich I call the "low quality" transparency  Then I try to play with:dispG.OutputMerger.BlendFactor = new Color4(0f, 0f, 0f, 0f);   dispG.OutputMerger.BlendSampleMask = 0x0F;Giving them a lot of different values. I still don't have a clue what they are for and the documentation was not helpful.So what is really happenning? I had never seen this "low quality" thing before so it may be something else.I studied this example regarding alpha blending, being in cpp in this case I was not able to find the equivalent in c# for SlimDX:ID3D10BlendState* g_pBlendState = NULL; D3D10_BLEND_DESC BlendState;ZeroMemory(&BlendState, sizeof(D3D10_BLEND_DESC)); BlendState.BlendEnable[0] = TRUE;BlendState.SrcBlend = D3D10_BLEND_SRC_ALPHA;BlendState.DestBlend = D3D10_BLEND_INV_SRC_ALPHA;BlendState.BlendOp = D3D10_BLEND_OP_ADD;BlendState.SrcBlendAlpha = D3D10_BLEND_ZERO;BlendState.DestBlendAlpha = D3D10_BLEND_ZERO;BlendState.BlendOpAlpha = D3D10_BLEND_OP_ADD;BlendState.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL; pd3dDevice->CreateBlendState(&BlendState, &g_pBlendState);pd3dDevice->OMSetBlendState(g_pBlendState, 0, 0xffffffff);I found the code here: http://takinginitiative.wordpress.com/2010/04/09/directx-10-tutorial-6-transparency-and-alpha-blending/Thanks for reading   
  For your "low-quality version" you have alpha to coverage enabled, which is causing that dithered look.   ;  Thanks a lot for your answer, MJP. That link to the documentation was most helpful. It clearifies a lot about blending. However If I just set alphaToCoverage = false, then I get no alpha blending at all.I see, from the cpp code I posted, there is a BlendEnable to be set to true. In fact it seems to be an array: BlendState.BlendEnable[0] = TRUE;I can't find this BlendEnable in SlimDX, nor can I find something related to:BlendState.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL;wich seems to be important too.As a SlimDX specific question: where are the equivalents of these two lines? And if there is something else to do in order to enable alpha blending the way I did in the .fx file (see (1) in my first post), what is it?--------------------Now I found it!I'm going to write it here just in case someone else gets stuck. It's just that those two arrays in the BlendStateDescription are not accessed directly as in the cpp code, but through two methods:- SetBlendEnable(UInt32, Boolean) - SetWriteMask(UInt32, ColorWriteMaskFlags) So this is what must be done:1) Fill the BlendStateDescription:    BlendStateDescription bsd = new BlendStateDescription() { IsAlphaToCoverageEnabled=false, AlphaBlendOperation = BlendOperation.Add, SourceAlphaBlend = BlendOption.Zero, DestinationAlphaBlend = BlendOption.Zero, BlendOperation= BlendOperation.Add, SourceBlend = BlendOption.SourceAlpha, DestinationBlend = BlendOption.InverseSourceAlpha  };2) Call these two methods throwing in the desired values:    bsd.SetBlendEnable(0, true);  bsd.SetWriteMask(0, ColorWriteMaskFlags.All);3) Create the BlendState from the description and set it  OblendSt_transparencias = BlendState.FromDescription (dispG, bsd);    ( ... )    dispG.OutputMerger.BlendState = OblendSt_transparencias; [Edited by - Fray Verdugo on May 8, 2010 7:19:49 AM]