Hi guys,
I am trying to get alpha blending to work using SharpDX (C#). I am using DirectX 10 to be able to use the FX Framework.
I have been looking all over google trying to find my mistake in my BlendState but I don't think that the problem is there because the exact same shader works like intended in my C++ engine.
Currently, everything gets rendered but there is simply no blending going on.
Below is my blendstate, written in the .fx file
BlendState AlphaBlending { BlendEnable[0] = TRUE; SrcBlend = SRC_ALPHA; DestBlend = INV_SRC_ALPHA; BlendOp = ADD; SrcBlendAlpha = ONE; DestBlendAlpha = ZERO; BlendOpAlpha = ADD; RenderTargetWriteMask[0] = 0x0f; };
I have tried creating and setting the blend state in code but that doesn't work either.
BlendStateDescription desc = new BlendStateDescription(); desc.IsBlendEnabled[0] = true; desc.BlendOperation = BlendOperation.Add; desc.SourceAlphaBlend = BlendOption.One; desc.DestinationAlphaBlend = BlendOption.Zero; desc.AlphaBlendOperation = BlendOperation.Add; desc.RenderTargetWriteMask[0] = ColorWriteMaskFlags.All; desc.SourceBlend = BlendOption.SourceAlpha; desc.DestinationBlend = BlendOption.InverseSourceAlpha;
_context.Device.OutputMerger.SetBlendState(_blendState, new Color4(0, 0, 0, 0), -1);
I was wondering if it might have something to do with the texture itself (maybe the alpha channel is not loaded properly?) but I am unsure about that
_textureResourceView = ShaderResourceView.FromFile(_context.Device, ParticleSystem.ImagePath);
I wouldn't know where the problem could lie. Is there anyone with experience with SharpDX that might see the problem?
Thanks in advance!