Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
DepthStencilStateDescription.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.Runtime.InteropServices;
4 
5 using SiliconStudio.Core;
6 
7 namespace SiliconStudio.Paradox.Graphics
8 {
9  /// <summary>
10  /// Describes a depth stencil state.
11  /// </summary>
12  [DataContract]
13  [StructLayout(LayoutKind.Sequential)]
15  {
16  /// <summary>
17  /// Initializes a new instance of the <see cref="DepthStencilStateDescription"/> class.
18  /// </summary>
19  public DepthStencilStateDescription(bool depthEnable, bool depthWriteEnable) : this()
20  {
21  SetDefault();
22  DepthBufferEnable = depthEnable;
23  DepthBufferWriteEnable = depthWriteEnable;
24  }
25 
26  /// <summary>
27  /// Enables or disables depth buffering. The default is true.
28  /// </summary>
29  public bool DepthBufferEnable;
30 
31  /// <summary>
32  /// Gets or sets the comparison function for the depth-buffer test. The default is CompareFunction.LessEqual
33  /// </summary>
35 
36  /// <summary>
37  /// Enables or disables writing to the depth buffer. The default is true.
38  /// </summary>
40 
41  /// <summary>
42  /// Gets or sets stencil enabling. The default is false.
43  /// </summary>
44  public bool StencilEnable;
45 
46  /// <summary>
47  /// Gets or sets the mask applied to the reference value and each stencil buffer entry to determine the significant bits for the stencil test. The default mask is byte.MaxValue.
48  /// </summary>
49  public byte StencilMask;
50 
51  /// <summary>
52  /// Gets or sets the write mask applied to values written into the stencil buffer. The default mask is byte.MaxValue.
53  /// </summary>
54  public byte StencilWriteMask;
55 
56  /// <summary>
57  /// Identify how to use the results of the depth test and the stencil test for pixels whose surface normal is facing towards the camera.
58  /// </summary>
60 
61  /// <summary>
62  /// Identify how to use the results of the depth test and the stencil test for pixels whose surface normal is facing away the camera.
63  /// </summary>
65 
66  /// <summary>
67  /// Sets default values for this instance.
68  /// </summary>
70  {
71  DepthBufferEnable = true;
72  DepthBufferWriteEnable = true;
73  DepthBufferFunction = CompareFunction.LessEqual;
74  StencilEnable = false;
75 
76  FrontFace.StencilFunction = CompareFunction.Always;
77  FrontFace.StencilPass = StencilOperation.Keep;
78  FrontFace.StencilFail = StencilOperation.Keep;
79  FrontFace.StencilDepthBufferFail = StencilOperation.Keep;
80 
81  BackFace.StencilFunction = CompareFunction.Always;
82  BackFace.StencilPass = StencilOperation.Keep;
83  BackFace.StencilFail = StencilOperation.Keep;
84  BackFace.StencilDepthBufferFail = StencilOperation.Keep;
85 
86  StencilMask = byte.MaxValue;
87  StencilWriteMask = byte.MaxValue;
88  return this;
89  }
90 
91  /// <summary>
92  /// Gets default values for this instance.
93  /// </summary>
95  {
96  get
97  {
98  var desc = new DepthStencilStateDescription();
99  desc.SetDefault();
100  return desc;
101  }
102  }
103 
105  {
106  return (DepthStencilStateDescription)MemberwiseClone();
107  }
108  }
109 }
byte StencilWriteMask
Gets or sets the write mask applied to values written into the stencil buffer. The default mask is by...
DepthStencilStencilOpDescription BackFace
Identify how to use the results of the depth test and the stencil test for pixels whose surface norma...
bool DepthBufferEnable
Enables or disables depth buffering. The default is true.
DepthStencilStencilOpDescription FrontFace
Identify how to use the results of the depth test and the stencil test for pixels whose surface norma...
Use the default mode depending on the type of the field/property.
byte StencilMask
Gets or sets the mask applied to the reference value and each stencil buffer entry to determine the s...
bool StencilEnable
Gets or sets stencil enabling. The default is false.
CompareFunction
Comparison options.
bool DepthBufferWriteEnable
Enables or disables writing to the depth buffer. The default is true.
CompareFunction DepthBufferFunction
Gets or sets the comparison function for the depth-buffer test. The default is CompareFunction.LessEqual
DepthStencilStateDescription SetDefault()
Sets default values for this instance.
DepthStencilStateDescription(bool depthEnable, bool depthWriteEnable)
Initializes a new instance of the DepthStencilStateDescription class.