Jump to content
  • Advertisement
Sign in to follow this  

SharpDX (DirectX 10) Alpha blending

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

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!

Edited by simco50

Share this post

Link to post
Share on other sites



One idea. Do you render transparent models after others?

The order is important in a typical scenario,


Happy Christmas

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!