public DepthStencilStateDescription(bool isDepthEnabled, DepthWriteMask depthWriteMask) { IsDepthEnabled = isDepthEnabled; DepthWriteMask = depthWriteMask; DepthComparison = Comparison.Less; IsStencilEnabled = false; StencilReadMask = 0; StencilWriteMask = 0; FrontFace = new DepthStencilOperationDescription(); BackFace = new DepthStencilOperationDescription(); }
public static DepthStencilState CreateDepthStencilState(Device device, bool depthEnable, DepthWriteMask writeMask) { DepthStencilOperationDescription frontFace = new DepthStencilOperationDescription(); DepthStencilOperationDescription backFace = new DepthStencilOperationDescription(); bool stencil = false;//depthEnable; byte rm = 0; byte wm = 0; if (stencil) { rm = 0xFF; wm = 0xFF; // Stencil operations if pixel is front-facing frontFace.FailOperation = StencilOperation.Keep; // D3D11_STENCIL_OP_KEEP; frontFace.DepthFailOperation = StencilOperation.Increment; // D3D11_STENCIL_OP_INCR; frontFace.PassOperation = StencilOperation.Keep; // D3D11_STENCIL_OP_KEEP; frontFace.Comparison = Comparison.Always; // D3D11_COMPARISON_ALWAYS; // Stencil operations if pixel is back-facing backFace.FailOperation = StencilOperation.Keep; // D3D11_STENCIL_OP_KEEP; backFace.DepthFailOperation = StencilOperation.Decrement; // D3D11_STENCIL_OP_DECR; backFace.PassOperation = StencilOperation.Keep; // D3D11_STENCIL_OP_KEEP; backFace.Comparison = Comparison.Always; // D3D11_COMPARISON_ALWAYS; } return(CreateDepthStencilState(device, depthEnable, writeMask, Comparison.LessEqual, stencil, rm, wm, frontFace, backFace)); }
public static DepthStencilState CreateDepthStencilState(Device device, bool depthEnable, DepthWriteMask writeMask, Comparison func, bool stencilEnable, byte stencilReadMask, byte stencilWriteMask, DepthStencilOperationDescription frontFace, DepthStencilOperationDescription backFace) { DepthStencilStateDescription dsd; dsd.IsDepthEnabled = depthEnable; dsd.DepthWriteMask = writeMask; dsd.DepthComparison = func; dsd.IsStencilEnabled = stencilEnable; dsd.StencilReadMask = stencilReadMask; dsd.StencilWriteMask = stencilWriteMask; dsd.FrontFace = frontFace; dsd.BackFace = backFace; DepthStencilState s = new DepthStencilState(device, dsd); return(s); }