Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am getting the following error, even though the code runs through the Draw could twice and then it errors:

XNA Framework HiDef profile does not support alpha blending or ColorWriteChannels when using rendertarget format Single.

The BlendState that I'm using is:

BlendState newBlendState = new BlendState()
{
    AlphaBlendFunction = BlendFunction.Add,
    AlphaSourceBlend = Blend.One,
    AlphaDestinationBlend = Blend.One,
    ColorBlendFunction = BlendFunction.Add,
    ColorSourceBlend = Blend.One,
    ColorDestinationBlend = Blend.One
};

I even set the SamplerStates to PointClamp before the actual draw is called:

device.DrawUserIndexedPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, domeVerts, 0, 1024, ib, 0, 1860);

I don't understand how it can run successfully twice, and then fail. Any help would be greatly appreciated.

A screenshot of the problem: Alpha Blending fail

share|improve this question
    
Before you do any drawing I would suggest you reset the GraphicsDevice to its defaults. blogs.msdn.com/b/shawnhar/archive/2010/06/18/… –  Luis Estrada Feb 29 '12 at 18:22
1  
"I don't understand how it can run successfully twice, and then fail." Do you use a spritebatch anywhere? Perhaps with a render target. –  ClassicThunder Feb 29 '12 at 18:43
    
There is a Debug render that uses a SpriteBatch. –  Neil Knight Feb 29 '12 at 20:28
    
Are you using a RenderTarget2D anywhere? If so, can you post the code for the declaration of that? –  Nic Foster Feb 29 '12 at 20:31
    
@Neil Knight try "GraphicsDevice.BlendState = BlendState.Opaque;" before "DrawUserIndexedPrimitives" then. –  ClassicThunder Feb 29 '12 at 20:56

2 Answers 2

The problem is that the RenderTargetFormat 'Single' does not have an alpha channel so you need to use a different format or an opaque blend state.

When I went to look up which values the RenderTargetFormat enum has I found out that someone else also asked this question in the official XNA forums, that they gave the same advice as I have and that this resolved the issue. I'm still posting this answer here so other people have a reference as well.

http://forums.create.msdn.com/forums/t/60776.aspx

edit: thought it was the same person who asked this, but as ClassicThunder pointed out this is very unlikely.

share|improve this answer
2  
The question was asked in 2010 and the latest post was close to a year ago so I doubt it was the same person. –  ClassicThunder Feb 29 '12 at 21:54
    
ClassicThunder: you're right, I didn't look at the date, but the question was so similar :) –  Roy T. Mar 1 '12 at 8:02
    
The question you have posted in your answer is not me. I've tried using GraphicsDevice.BlendState = BlendState.Opaque but I want alpha blending. I've updated my question with a screenshot of the problem. –  Neil Knight Mar 1 '12 at 8:48
    
You can't have alpha blending in a render target with format single, there is no alpha channel there. Single uses all the bits as one 32bit float instead of 4x8bits for colours as in RGBA modes so just change the render target declaration. –  Roy T. Mar 1 '12 at 8:51
    
I have tried changing that, do you have a RenderTarget suggestion? –  Neil Knight Mar 1 '12 at 9:24
up vote 0 down vote accepted

The solution was nothing to do with the RenderTargets that were currently in use, but it was the DepthBuffer RenderTarget causing the problem. Changing this resolved the issue.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.