/// <summary> /// Initializes a new instance of the <see cref="DepthStencilState"/> class. /// </summary> /// <param name="depthEnable">if set to <c>true</c> [depth enable].</param> /// <param name="depthWriteEnable">if set to <c>true</c> [depth write enable].</param> /// <param name="name">The name.</param> private DepthStencilState(GraphicsDevice device, DepthStencilStateDescription depthStencilStateDescription) : base(device) { Description = depthStencilStateDescription; CreateNativeDeviceChild(); }
private DepthStencilState(GraphicsDevice device, DepthStencilStateDescription depthStencilStateDescription) : base(device) { Description = depthStencilStateDescription; depthFunction = Description.DepthBufferFunction.ToOpenGLDepthFunction(); }
internal DepthStencilState(DepthStencilStateDescription depthStencilStateDescription, bool hasDepthStencilBuffer) { state.DepthBufferEnable = depthStencilStateDescription.DepthBufferEnable; state.DepthBufferWriteEnable = depthStencilStateDescription.DepthBufferWriteEnable && hasDepthStencilBuffer; state.StencilEnable = depthStencilStateDescription.StencilEnable; state.StencilMask = depthStencilStateDescription.StencilMask; state.StencilWriteMask = depthStencilStateDescription.StencilWriteMask; state.DepthFunction = depthStencilStateDescription.DepthBufferFunction.ToOpenGLDepthFunction(); state.Faces.FrontFaceStencilFunction = depthStencilStateDescription.FrontFace.StencilFunction.ToOpenGLStencilFunction(); state.Faces.FrontFaceDepthFailOp = depthStencilStateDescription.FrontFace.StencilDepthBufferFail.ToOpenGL(); state.Faces.FrontFaceFailOp = depthStencilStateDescription.FrontFace.StencilFail.ToOpenGL(); state.Faces.FrontFacePassOp = depthStencilStateDescription.FrontFace.StencilPass.ToOpenGL(); state.Faces.BackFaceStencilFunction = depthStencilStateDescription.BackFace.StencilFunction.ToOpenGLStencilFunction(); state.Faces.BackFaceDepthFailOp = depthStencilStateDescription.BackFace.StencilDepthBufferFail.ToOpenGL(); state.Faces.BackFaceFailOp = depthStencilStateDescription.BackFace.StencilFail.ToOpenGL(); state.Faces.BackFacePassOp = depthStencilStateDescription.BackFace.StencilPass.ToOpenGL(); }
protected override void LoadContent() { base.LoadContent(); // create effect and geometric primitives Batch = new UIBatch(GraphicsDevice); // create depth stencil states var depthStencilDescription = new DepthStencilStateDescription(true, true) { StencilEnable = true, FrontFace = new DepthStencilStencilOpDescription { StencilDepthBufferFail = StencilOperation.Keep, StencilFail = StencilOperation.Keep, StencilPass = StencilOperation.Keep, StencilFunction = CompareFunction.Equal }, BackFace = new DepthStencilStencilOpDescription { StencilDepthBufferFail = StencilOperation.Keep, StencilFail = StencilOperation.Keep, StencilPass = StencilOperation.Keep, StencilFunction = CompareFunction.Equal }, }; KeepStencilValueState = depthStencilDescription; depthStencilDescription.FrontFace.StencilPass = StencilOperation.Increment; depthStencilDescription.BackFace.StencilPass = StencilOperation.Increment; IncreaseStencilValueState = depthStencilDescription; depthStencilDescription.FrontFace.StencilPass = StencilOperation.Decrement; depthStencilDescription.BackFace.StencilPass = StencilOperation.Decrement; DecreaseStencilValueState = depthStencilDescription; // set the default design of the UI elements. var designsTexture = TextureExtensions.FromFileData(GraphicsDevice, DefaultDesigns.Designs); DefaultResourceDictionary = new ResourceDictionary { [typeof(Button)] = new Style(typeof(Button)) { Setters = { new Setter<ISpriteProvider>(Button.PressedImagePropertyKey, (SpriteFromTexture)new Sprite("Default button pressed design", designsTexture) { Borders = 8 * Vector4.One, Region = new RectangleF(71, 3, 32, 32) }), new Setter<ISpriteProvider>(Button.NotPressedImagePropertyKey, (SpriteFromTexture)new Sprite("Default button not pressed design", designsTexture) { Borders = 8 * Vector4.One, Region = new RectangleF(3, 3, 32, 32) }), new Setter<ISpriteProvider>(Button.MouseOverImagePropertyKey, (SpriteFromTexture)new Sprite("Default button overred design", designsTexture) { Borders = 8 * Vector4.One, Region = new RectangleF(37, 3, 32, 32) }), } }, [typeof(EditText)] = new Style(typeof(EditText)) { Setters = { new Setter<ISpriteProvider>(EditText.ActiveImagePropertyKey, (SpriteFromTexture)new Sprite("Default edit active design", designsTexture) { Borders = 12 * Vector4.One, Region = new RectangleF(105, 3, 32, 32) }), new Setter<ISpriteProvider>(EditText.InactiveImagePropertyKey, (SpriteFromTexture)new Sprite("Default edit inactive design", designsTexture) { Borders = 12 * Vector4.One, Region = new RectangleF(139, 3, 32, 32) }), new Setter<ISpriteProvider>(EditText.MouseOverImagePropertyKey, (SpriteFromTexture)new Sprite("Default edit overred design", designsTexture) { Borders = 12 * Vector4.One, Region = new RectangleF(173, 3, 32, 32) }), } }, [typeof(ToggleButton)] = new Style(typeof(ToggleButton)) { Setters = { new Setter<ISpriteProvider>(ToggleButton.CheckedImagePropertyKey, (SpriteFromTexture)new Sprite("Default toggle button checked design", designsTexture) { Borders = 8 * Vector4.One, Region = new RectangleF(71, 3, 32, 32) }), new Setter<ISpriteProvider>(ToggleButton.UncheckedImagePropertyKey, (SpriteFromTexture)new Sprite("Default toggle button unchecked design", designsTexture) { Borders = 8 * Vector4.One, Region = new RectangleF(3, 3, 32, 32) }), new Setter<ISpriteProvider>(ToggleButton.IndeterminateImagePropertyKey, (SpriteFromTexture)new Sprite("Default toggle button indeterminate design", designsTexture) { Borders = 8 * Vector4.One, Region = new RectangleF(37, 3, 32, 32) }), } }, [typeof(Slider)] = new Style(typeof(Slider)) { Setters = { new Setter<ISpriteProvider>(Slider.TrackBackgroundImagePropertyKey, (SpriteFromTexture)new Sprite("Default slider track background design", designsTexture) { Borders = 14 * Vector4.One, Region = new RectangleF(207, 3, 32, 32) }), new Setter<ISpriteProvider>(Slider.TrackForegroundImagePropertyKey, (SpriteFromTexture)new Sprite("Default slider track foreground design", designsTexture) { Borders = 0 * Vector4.One, Region = new RectangleF(3, 37, 32, 32) }), new Setter<ISpriteProvider>(Slider.ThumbImagePropertyKey, (SpriteFromTexture)new Sprite("Default slider thumb design", designsTexture) { Borders = 4 * Vector4.One, Region = new RectangleF(37, 37, 16, 32) }), new Setter<ISpriteProvider>(Slider.MouseOverThumbImagePropertyKey, (SpriteFromTexture)new Sprite("Default slider thumb overred design", designsTexture) { Borders = 4 * Vector4.One, Region = new RectangleF(71, 37, 16, 32) }), new Setter<ISpriteProvider>(Slider.TickImagePropertyKey, (SpriteFromTexture)new Sprite("Default slider track foreground design", designsTexture) { Region = new RectangleF(245, 3, 3, 6) }), new Setter<float>(Slider.TickOffsetPropertyKey, 13f), new Setter<Vector2>(Slider.TrackStartingOffsetsrPropertyKey, new Vector2(3)), } }, }; }
public DepthStencilState(GraphicsDevice device, DepthStencilStateDescription description) : base(device) { throw new NotImplementedException(); }
public DefaultModalElementRenderer(IServiceRegistry services) : base(services) { noStencilNoDepth = new DepthStencilStateDescription(false, false); }
private SharpDX.Direct3D12.DepthStencilStateDescription CreateDepthStencilState(DepthStencilStateDescription description) { SharpDX.Direct3D12.DepthStencilStateDescription nativeDescription; nativeDescription.IsDepthEnabled = description.DepthBufferEnable; nativeDescription.DepthComparison = (Comparison)description.DepthBufferFunction; nativeDescription.DepthWriteMask = description.DepthBufferWriteEnable ? SharpDX.Direct3D12.DepthWriteMask.All : SharpDX.Direct3D12.DepthWriteMask.Zero; nativeDescription.IsStencilEnabled = description.StencilEnable; nativeDescription.StencilReadMask = description.StencilMask; nativeDescription.StencilWriteMask = description.StencilWriteMask; nativeDescription.FrontFace.FailOperation = (SharpDX.Direct3D12.StencilOperation)description.FrontFace.StencilFail; nativeDescription.FrontFace.PassOperation = (SharpDX.Direct3D12.StencilOperation)description.FrontFace.StencilPass; nativeDescription.FrontFace.DepthFailOperation = (SharpDX.Direct3D12.StencilOperation)description.FrontFace.StencilDepthBufferFail; nativeDescription.FrontFace.Comparison = (SharpDX.Direct3D12.Comparison)description.FrontFace.StencilFunction; nativeDescription.BackFace.FailOperation = (SharpDX.Direct3D12.StencilOperation)description.BackFace.StencilFail; nativeDescription.BackFace.PassOperation = (SharpDX.Direct3D12.StencilOperation)description.BackFace.StencilPass; nativeDescription.BackFace.DepthFailOperation = (SharpDX.Direct3D12.StencilOperation)description.BackFace.StencilDepthBufferFail; nativeDescription.BackFace.Comparison = (SharpDX.Direct3D12.Comparison)description.BackFace.StencilFunction; return(nativeDescription); }
public override void Load() { base.Load(); skyboxEffect = this.EffectSystemOld.BuildEffect("Skybox") .Using(new StateShaderPlugin() { RenderPassPlugin = this, UseDepthStencilState = true }) .Using(new BasicShaderPlugin( new ShaderMixinSource() { Mixins = new List<ShaderClassSource>() { new ShaderClassSource("SkyBox")}, Compositions = new Dictionary<string, ShaderSource>() { {"color", SkyBoxColor}} }) { RenderPassPlugin = this }) .InstantiatePermutation(); if (OfflineCompilation) return; Parameters.AddSources(MainPlugin.ViewParameters); var zBackgroundValue = MainTargetPlugin.ClearDepth; // Generates a quad for post effect rendering (should be utility function) var vertices = new[] { -1.0f, 1.0f, zBackgroundValue, 1.0f, 1.0f, 1.0f, zBackgroundValue, 1.0f, -1.0f, -1.0f, zBackgroundValue, 1.0f, 1.0f, -1.0f, zBackgroundValue, 1.0f, }; Parameters.RegisterParameter(EffectPlugin.DepthStencilStateKey); Parameters.Set(TexturingKeys.Sampler, GraphicsDevice.SamplerStates.LinearWrap); // Use the quad for this effectMesh var quadData = new Mesh(); quadData.Draw = new MeshDraw { DrawCount = 4, PrimitiveType = PrimitiveType.TriangleStrip, VertexBuffers = new[] { new VertexBufferBinding(Buffer.Vertex.New(GraphicsDevice, vertices), new VertexDeclaration(VertexElement.Position<Vector4>()), 4) } }; RenderPass.StartPass += (context) => { // Setup the Viewport context.GraphicsDevice.SetViewport(MainTargetPlugin.Viewport); // Setup the depth stencil and main render target. context.GraphicsDevice.SetRenderTarget(MainTargetPlugin.DepthStencil, MainTargetPlugin.RenderTarget); }; RenderPass.EndPass += (context) => context.GraphicsDevice.UnsetRenderTargets(); var skyboxMesh = new EffectMesh(skyboxEffect, quadData).KeepAliveBy(this); // If the main target plugin is not clearing anything, we assume that this is the job of the skybox plugin if (!MainTargetPlugin.EnableClearTarget && !MainTargetPlugin.EnableClearDepth) { var description = new DepthStencilStateDescription().Default(); description.DepthBufferFunction = CompareFunction.Always; var alwaysWrite = DepthStencilState.New(GraphicsDevice, description); skyboxMesh.Parameters.Set(EffectPlugin.DepthStencilStateKey, alwaysWrite); } else { skyboxMesh.Parameters.Set(EffectPlugin.DepthStencilStateKey, MainTargetPlugin.DepthStencilState); } skyboxMesh.Parameters.AddSources(this.Parameters); RenderSystem.GlobalMeshes.AddMesh(skyboxMesh); }