0

我在加载带有从搅拌机到 xna 的 alpha 混合的纹理模型时遇到问题。

在搅拌机上,我知道纹理具有正确的 alpha 值,但是每当我将模型绘制到我的游戏中时,原本应该是透明的额外空间被填充为黑色

这就是我的绘图方法的样子。

public void draw()
    {

        Matrix posTranslated = Matrix.CreateTranslation(position); 
        foreach (ModelMesh mesh in model.Meshes)
        {
            foreach (BasicEffect effect in mesh.Effects)
            {
                effect.EnableDefaultLighting();


                effect.View = view;
                effect.Projection = proj;
                effect.World = modelTransforms[mesh.ParentBone.Index] * posTranslated;
            }

            mesh.Draw();

        }
    }

我错过了图形设备的任何效果或更改吗?我一直在寻找几天,但仍然没有解决这个问题。请帮忙TT

4

1 回答 1

2

这些属性你设置了吗?

graphicsDevice.RenderState.AlphaBlendEnable = true;
graphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha;
graphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha;

如果您使用的是 XNA 4.0,则需要设置混合状态而不是旧的 RenderState。

BlendState blendState = new BlendState()
{
    AlphaSourceBlend = Blend.SourceAlpha,
    AlphaDestinationBlend = Blend.InverseSourceAlpha, 
    ColorDestinationBlend = Blend.InverseSourceAlpha, // Required for Reach profile
};
GraphicsDevice.BlendState = blendState;
于 2012-06-14T07:48:58.460 回答