Exemplo n.º 1
0
        public BlendState(GraphicsDevice graphicsDevice, BlendStateInfo info)
            : base(graphicsDevice, new StackTrace(1))
        {
            this.Info = info;

            SharpDX.Direct3D11.BlendStateDescription desc = new SharpDX.Direct3D11.BlendStateDescription();
            desc.AlphaToCoverageEnable  = info.AlphaToCoverageEnable;
            desc.IndependentBlendEnable = info.IndependentBlendEnable;

            for (int i = 0; i < info.RenderTargets.Length; i++)
            {
                RTBlendInfo rtInfo = info.RenderTargets[i];
                desc.RenderTarget[i] = new SharpDX.Direct3D11.RenderTargetBlendDescription()
                {
                    IsBlendEnabled        = rtInfo.IsBlendEnabled,
                    SourceBlend           = EnumConverter.Convert(rtInfo.SrcBlend),
                    DestinationBlend      = EnumConverter.Convert(rtInfo.DestBlend),
                    BlendOperation        = EnumConverter.Convert(rtInfo.BlendOp),
                    SourceAlphaBlend      = EnumConverter.Convert(rtInfo.SrcBlendAlpha),
                    DestinationAlphaBlend = EnumConverter.Convert(rtInfo.DestBlendAlpha),
                    AlphaBlendOperation   = EnumConverter.Convert(rtInfo.BlendOpAlpha),
                    RenderTargetWriteMask = EnumConverter.Convert(rtInfo.RenderTargetWriteMask)
                };
            }

            Handle = new SharpDX.Direct3D11.BlendState(graphicsDevice.Device, desc);
        }
Exemplo n.º 2
0
        static BlendStateInfo()
        {
            var defaultState = new BlendStateInfo(1);

            defaultState.AlphaToCoverageEnable                  = false;
            defaultState.IndependentBlendEnable                 = false;
            defaultState.RenderTargets[0].IsBlendEnabled        = false;
            defaultState.RenderTargets[0].SrcBlend              = Blend.Zero;
            defaultState.RenderTargets[0].DestBlend             = Blend.Zero;
            defaultState.RenderTargets[0].BlendOp               = BlendOp.Add;
            defaultState.RenderTargets[0].SrcBlendAlpha         = Blend.One;
            defaultState.RenderTargets[0].DestBlendAlpha        = Blend.Zero;
            defaultState.RenderTargets[0].BlendOpAlpha          = BlendOp.Add;
            defaultState.RenderTargets[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;
            Default = defaultState;

            var add = new BlendStateInfo(1);

            add.AlphaToCoverageEnable                  = false;
            add.IndependentBlendEnable                 = false;
            add.RenderTargets[0].IsBlendEnabled        = true;
            add.RenderTargets[0].SrcBlend              = Blend.One;
            add.RenderTargets[0].DestBlend             = Blend.One;
            add.RenderTargets[0].BlendOp               = BlendOp.Add;
            add.RenderTargets[0].SrcBlendAlpha         = Blend.One;
            add.RenderTargets[0].DestBlendAlpha        = Blend.Zero;
            add.RenderTargets[0].BlendOpAlpha          = BlendOp.Add;
            add.RenderTargets[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;
            Add = add;

            var alphaBlend = new BlendStateInfo(1);

            alphaBlend.AlphaToCoverageEnable                  = false;
            alphaBlend.IndependentBlendEnable                 = false;
            alphaBlend.RenderTargets[0].IsBlendEnabled        = true;
            alphaBlend.RenderTargets[0].SrcBlend              = Blend.SrcAlpha;
            alphaBlend.RenderTargets[0].DestBlend             = Blend.InvSrcAlpha;
            alphaBlend.RenderTargets[0].BlendOp               = BlendOp.Add;
            alphaBlend.RenderTargets[0].SrcBlendAlpha         = Blend.SrcAlpha;
            alphaBlend.RenderTargets[0].DestBlendAlpha        = Blend.One;
            alphaBlend.RenderTargets[0].BlendOpAlpha          = BlendOp.Add;
            alphaBlend.RenderTargets[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;

            AlphaBlend = alphaBlend;
        }
Exemplo n.º 3
0
 public IBlendState CreateBlendState(BlendStateInfo info)
 {
     return(new BlendState(graphicsDevice, info));
 }
Exemplo n.º 4
0
 internal BlendState(GraphicsDevice graphicsDevice, BlendStateInfo info)
     : base(graphicsDevice, new StackTrace(1))
 {
     this.Info = info;
 }