我在圖形設備上的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