我在图形设备上的BlendState正常工作并正确显示Alpha混合时遇到问题。XNA 4.0中的设备AlphaBlend状态
在某些情况下,你可以通过其他的叶子看到叶子,你不能等情况。而后备箱也总是被遮挡。我试过很多不同的BlendState设置组合。目前,它看起来像这样:
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
//GraphicsDevice.BlendState = BlendState.AlphaBlend;
GraphicsDevice.BlendState = new BlendState()
{
AlphaBlendFunction = BlendFunction.Add,
AlphaDestinationBlend = Blend.InverseSourceAlpha,
AlphaSourceBlend = Blend.One,
BlendFactor = new Color(1.0F, 1.0F, 1.0F, 1.0F),
ColorBlendFunction = BlendFunction.Add,
ColorDestinationBlend = Blend.InverseSourceAlpha,
ColorSourceBlend = Blend.One,
ColorWriteChannels = ColorWriteChannels.All,
ColorWriteChannels1 = ColorWriteChannels.All,
ColorWriteChannels2 = ColorWriteChannels.All,
ColorWriteChannels3 = ColorWriteChannels.All,
MultiSampleMask = -1
};
的着色器代码如下:
浮子阿尔法= 1.0F; if(HasAlphaTexture) alpha = tex2D(AlphaSampler,IN.UV).xyz;
// ... // 确定颜色值等。 /// ...
返回个float4(result.xyz,阿尔法);
我使用的是这种情况的地图如下所示:
谢谢安德鲁。非常感激。 – helloserve 2011-06-11 11:44:19