Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
BlendStateDescription.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Runtime.InteropServices;
5 
6 using SiliconStudio.Core;
7 using SiliconStudio.Core.Mathematics;
8 
9 namespace SiliconStudio.Paradox.Graphics
10 {
11  /// <summary>
12  /// Describes a blend state.
13  /// </summary>
14  [DataContract]
15  [StructLayout(LayoutKind.Sequential)]
16  public struct BlendStateDescription
17  {
18  /// <summary>
19  /// Initializes a new instance of the <see cref="BlendStateDescription"/> class.
20  /// </summary>
21  /// <param name="sourceBlend">The source blend.</param>
22  /// <param name="destinationBlend">The destination blend.</param>
23  public BlendStateDescription(Blend sourceBlend, Blend destinationBlend) : this()
24  {
25  SetDefaults();
26  RenderTargets[0].BlendEnable = true;
27  RenderTargets[0].ColorSourceBlend = sourceBlend;
28  RenderTargets[0].ColorDestinationBlend = destinationBlend;
29  RenderTargets[0].AlphaSourceBlend = sourceBlend;
30  RenderTargets[0].AlphaDestinationBlend = destinationBlend;
31  }
32 
33  /// <summary>
34  /// Setup this blend description with defaults value.
35  /// </summary>
36  public void SetDefaults()
37  {
38  RenderTargets = new BlendStateRenderTargetDescription[8];
39 
40  AlphaToCoverageEnable = false;
41  IndependentBlendEnable = false;
42 
43  for (int i = 0; i < RenderTargets.Length; i++)
44  {
45  RenderTargets[i].BlendEnable = false;
46  RenderTargets[i].ColorSourceBlend = Blend.One;
47  RenderTargets[i].ColorDestinationBlend = Blend.Zero;
48  RenderTargets[i].ColorBlendFunction = BlendFunction.Add;
49 
50  RenderTargets[i].AlphaSourceBlend = Blend.One;
51  RenderTargets[i].AlphaDestinationBlend = Blend.Zero;
52  RenderTargets[i].AlphaBlendFunction = BlendFunction.Add;
53 
54  RenderTargets[i].ColorWriteChannels = ColorWriteChannels.All;
55  }
56  }
57 
58  /// <summary>
59  /// Gets default values for this instance.
60  /// </summary>
61  public static BlendStateDescription Default
62  {
63  get
64  {
65  var desc = new BlendStateDescription();
66  desc.SetDefaults();
67  return desc;
68  }
69  }
70 
71  /// <summary>
72  /// Determines whether or not to use alpha-to-coverage as a multisampling technique when setting a pixel to a rendertarget.
73  /// </summary>
74  public bool AlphaToCoverageEnable;
75 
76  /// <summary>
77  /// Set to true to enable independent blending in simultaneous render targets. If set to false, only the RenderTarget[0] members are used. RenderTarget[1..7] are ignored.
78  /// </summary>
80 
81  /// <summary>
82  /// An array of render-target-blend descriptions (see <see cref="BlendStateRenderTargetDescription"/>); these correspond to the eight rendertargets that can be set to the output-merger stage at one time.
83  /// </summary>
85  }
86 }
BlendStateRenderTargetDescription[] RenderTargets
An array of render-target-blend descriptions (see BlendStateRenderTargetDescription); these correspon...
bool IndependentBlendEnable
Set to true to enable independent blending in simultaneous render targets. If set to false...
Use the default mode depending on the type of the field/property.
bool AlphaToCoverageEnable
Determines whether or not to use alpha-to-coverage as a multisampling technique when setting a pixel ...
ColorWriteChannels
Identify which components of each pixel of a render target are writable during blending.
void SetDefaults()
Setup this blend description with defaults value.
Blend
Blend option. A blend option identifies the data source and an optional pre-blend operation...
Definition: Blend.cs:14
BlendStateDescription(Blend sourceBlend, Blend destinationBlend)
Initializes a new instance of the BlendStateDescription class.