spriteBatch =
new SpriteBatch(GraphicsDevice);
bs.AlphaSourceBlend =
Blend.SourceAlpha;
bs.AlphaDestinationBlend =
Blend.InverseSourceAlpha;
用XNA开发个编辑器,发现不能正确绘制PNG图片,所以需要AlphaBlend,于是写了上面的混合代码,但是我的电脑不支持HiDef,只能Reach,并提示“XNA Framework Reach profile does not support separate alpha blend. BlendState.ColorDestinationBlend and AlphaDestinationBlend must be set to the same value.”
折腾了几天,想到了用Shader解决,失败。
其实我一直以为Alpha混合要设置AlphaSource和AlphaDestination,但是我错了,主要应该设置ColorSourceBlend和ColorDestinationBlend:
spriteBatch =
new SpriteBatch(GraphicsDevice);
bs.ColorSourceBlend =
Blend.SourceAlpha;
bs.AlphaSourceBlend =
Blend.SourceAlpha;
bs.ColorDestinationBlend =
Blend.InverseSourceAlpha;
bs.AlphaDestinationBlend =
Blend.InverseSourceAlpha;
这样就可以得到很好的混合效果了,无论Reach或是HiDef。