コード例 #1
0
        /// <summary>
        /// Basic stencil clipping. Depth disabled.
        /// This assumes the stencil was cleared with 'RenderPassDepthStencilDesc.stencilValue = 1'
        /// </summary>
        /// <param name="stencilClip">True to clip or false to write clipping mask</param>
        /// <param name="doubleSidedFacing">False to only use front-faces or True for both front and back faces</param>
        public static DepthStencilDesc BasicStencilTesting(bool stencilClip, bool doubleSidedFacing)
        {
            var result = new DepthStencilDesc()
            {
                stencilTestEnable  = stencilClip,
                stencilWriteEnable = !stencilClip
            };

            result.stencilFrontFacingDesc.stencilTestFunction       = stencilClip ? DepthStencilTestFunction.LessThan : DepthStencilTestFunction.Always;
            result.stencilFrontFacingDesc.stencilFailOperation      = StencilOperation.Keep;
            result.stencilFrontFacingDesc.stencilDepthFailOperation = StencilOperation.Keep;
            result.stencilFrontFacingDesc.stencilPassOperation      = stencilClip ? StencilOperation.Keep : StencilOperation.Zero;
            if (doubleSidedFacing)
            {
                result.stencilBackFacingDesc = result.stencilFrontFacingDesc;
            }
            else
            {
                result.stencilBackFacingDesc.stencilTestFunction       = DepthStencilTestFunction.Never;
                result.stencilBackFacingDesc.stencilFailOperation      = StencilOperation.Keep;
                result.stencilBackFacingDesc.stencilDepthFailOperation = StencilOperation.Keep;
                result.stencilBackFacingDesc.stencilPassOperation      = StencilOperation.Keep;
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Standard depth testing. Stencil disabled.
        /// </summary>
        public static DepthStencilDesc StandardDepthTesting()
        {
            var result = new DepthStencilDesc()
            {
                depthTestEnable   = true,
                depthWriteEnable  = true,
                depthTestFunction = DepthStencilTestFunction.LessThan
            };

            return(result);
        }