1 Attachment(s)
Use XNA like DirectX9, Transparencies
Hi,
I have been trying to achieve alpha blending in XNA. I don't want to use the Spritebatch class. I have tried playing around with the renderstate and setting a colour key.
Code to create Colourkey:
Code:
TextureCreationParameters tt = new TextureCreationParameters();
tt = TextureCreationParameters.Default;
tt.ColorKey = new Color(0, 0, 0);
tt.Format = SurfaceFormat.Rgba32;
inSheet.texData = Texture2D.FromFile(device, assetName, tt);
Code setting renderstate:
Code:
device.RenderState.AlphaSourceBlend = Blend.SourceAlpha;
device.RenderState.AlphaDestinationBlend = Blend.InverseSourceAlpha;
device.RenderState.AlphaBlendEnable = true;
Have I gone mad and tried to use XNA like DX9? :confused:
Or is there a way?
Find my whole project attached.
Re: Use XNA like DirectX9, Transparencies
ah, Fixed, it turns out all I had to do was change:
Code:
device.RenderState.AlphaSourceBlend = Blend.SourceAlpha;
device.RenderState.AlphaDestinationBlend = Blend.InverseSourceAlpha;
device.RenderState.AlphaBlendEnable = true;
into:
Code:
device.RenderState.SourceBlend = Blend.SourceAlpha;
device.RenderState.DestinationBlend = Blend.InverseSourceAlpha;
device.RenderState.AlphaBlendEnable = true;
I was blending the alpha values and not the colours :blush: