/// <summary> /// デバイスを初期化します. /// </summary> public new void Load() { base.Load(false, D3D.DeviceCreationFlags.BgraSupport, DeviceCreationFlags.BgraSupport); //ラスタライザの設定を上書き var blendDesc = new D3D.BlendStateDescription(); blendDesc.AlphaToCoverageEnable = true; // Alpha to Coverage を有効にする blendDesc.IndependentBlendEnable = false; for (int i = 0; i < blendDesc.RenderTargets.Length; i++) { blendDesc.RenderTargets[i].BlendEnable = true; blendDesc.RenderTargets[i].SourceBlend = D3D.BlendOption.SourceAlpha; blendDesc.RenderTargets[i].DestinationBlend = D3D.BlendOption.InverseSourceAlpha; blendDesc.RenderTargets[i].BlendOperation = D3D.BlendOperation.Add; blendDesc.RenderTargets[i].SourceBlendAlpha = D3D.BlendOption.One; blendDesc.RenderTargets[i].DestinationBlendAlpha = D3D.BlendOption.One; // ここを1にしないとアルファの合成が変 blendDesc.RenderTargets[i].BlendOperationAlpha = D3D.BlendOperation.Add; blendDesc.RenderTargets[i].RenderTargetWriteMask = D3D.ColorWriteMaskFlags.All; } customBlendState = Context.OutputMerger.BlendState = D3D.BlendState.FromDescription(Device, blendDesc); d2dFactory = new D2D.Factory(D2D.FactoryType.Multithreaded); dwFactory = new DW.Factory(DW.FactoryType.Shared); }
private void InitializeBlend() { var blend = new Dx11.BlendStateDescription() { AlphaToCoverageEnable = false, IndependentBlendEnable = false }; for (int i = 0; i < 8; i++) { blend.RenderTargets[i] = new Dx11.RenderTargetBlendDescription(); blend.RenderTargets[i].BlendEnable = true; blend.RenderTargets[i].BlendOperation = Dx11.BlendOperation.Add; blend.RenderTargets[i].BlendOperationAlpha = Dx11.BlendOperation.Add; blend.RenderTargets[i].DestinationBlend = Dx11.BlendOption.InverseSourceAlpha; blend.RenderTargets[i].DestinationBlendAlpha = Dx11.BlendOption.Zero; blend.RenderTargets[i].RenderTargetWriteMask = Dx11.ColorWriteMaskFlags.All; blend.RenderTargets[i].SourceBlend = Dx11.BlendOption.SourceAlpha; blend.RenderTargets[i].SourceBlendAlpha = Dx11.BlendOption.One; } device.ImmediateContext.OutputMerger.BlendFactor = new Color4(0, 0, 0, 0); device.ImmediateContext.OutputMerger.BlendSampleMask = 0xffffff; device.ImmediateContext.OutputMerger.BlendState = Dx11.BlendState.FromDescription(device, blend); }