public void SetNormalDepthRenderTarget(DepthStencilView dsv) { _dc.OutputMerger.SetTargets(dsv, _normalDepthRTV); var clearColor = new Color4(1e5f, 0.0f, 0.0f, -1.0f); _dc.ClearRenderTargetView(_normalDepthRTV, clearColor); }
void UpdateCubeFace(DeviceContext context, int index, int mip) { // Prepare pipeline context.ClearState(); context.Rasterizer.SetViewport(Viewport); context.InputAssembler.InputLayout = CustomInputLayout; context.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(null, 0, 0)); context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip; if (CurrentState == RenderState.IntegrateBRDF) { context.OutputMerger.SetRenderTargets(null, IntegrateBRDFxRTV); context.ClearRenderTargetView(IntegrateBRDFxRTV, Color.CornflowerBlue); context.VertexShader.Set(IntegrateQuadVS); context.PixelShader.Set(IntegrateBRDFxPS); context.Draw(4, 0); UnbindContextRTV(context); return; } int rtvIndex = mip < 0 ? index : (index * PreFilteredMipsCount + mip); context.OutputMerger.SetRenderTargets(null, OutputRTVs[rtvIndex]); // Render the scene using the view, projection, RTV and DSV of this cube face context.ClearRenderTargetView(OutputRTVs[rtvIndex], Color.CornflowerBlue); Matrix[] ViewProj = new Matrix[] { Cameras[index].View, Cameras[index].Projection, }; context.UpdateSubresource(ViewProj, ConstantsBuffer); context.VertexShader.Set(SphereToCubeMapVS); context.VertexShader.SetConstantBuffer(0, ConstantsBuffer); context.PixelShader.SetConstantBuffer(1, BRDFParamsBuffer); context.PixelShader.SetSampler(0, Sampler); switch (CurrentState) { case RenderState.CubeMap: context.PixelShader.Set(SphereToCubeMapPS); context.PixelShader.SetShaderResource(0, InputSRV); break; case RenderState.IrradianceMap: context.PixelShader.Set(IrradiancePS); context.PixelShader.SetShaderResource(1, ConvertedCubeSRV); break; case RenderState.PreFilteredMap: context.PixelShader.Set(PreFilteredPS); context.PixelShader.SetShaderResource(1, ConvertedCubeSRV); break; } context.Draw(14, 0); UnbindContextRTV(context); }
private void ClearTargets() { _immediateContext.ClearDepthStencilView(depthView, DepthStencilClearFlags.Depth, 1.0f, 0); //_immediateContext.ClearRenderTargetView(renderView, ambient); _immediateContext.ClearRenderTargetView(gBufferLightView, Color4.Black); _immediateContext.ClearRenderTargetView(gBufferNormalView, Color4.Black); _immediateContext.ClearRenderTargetView(gBufferDiffuseView, Color4.Black); }
public void Prepare(DeviceContext context, Color color, byte stencil, Action prepareMask) { context.ClearRenderTargetView(AccumTargetView, new Color4(0, 0, 0, 0)); context.ClearRenderTargetView(RevealageTargetView, new Color4(1, 1, 1, 1)); context.ClearDepthStencilView(DepthTargetView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, RenderingConstants.DepthClearValue, stencil); context.OutputMerger.SetTargets(DepthTargetView, AccumTargetView); prepareMask(); }
public void ClearAndSetMainRenderTarget() { deviceContext.ClearDepthStencilView(depthView, DepthStencilClearFlags.Depth, 1.0f, 0); deviceContext.ClearRenderTargetView(renderTargetView, Color.OrangeRed); deviceContext.ClearRenderTargetView(objectIdView, Color.FromRgba(uint.MaxValue)); deviceContext.Rasterizer.SetViewport(m_viewport); deviceContext.OutputMerger.SetTargets(depthView, renderTargetView); }
protected override void DrawPrepare() { base.DrawPrepare(); var highlighted = AmbientShadowHighlight ? (IRenderableObject)CarNode?.AmbientShadowNode : SelectedObject; if (highlighted == null || _outlineBuffer == null) { return; } DeviceContext.ClearDepthStencilView(_outlineDepthBuffer.DepthView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1f, 0); DeviceContext.OutputMerger.SetTargets(_outlineDepthBuffer.DepthView); DeviceContext.Rasterizer.State = DeviceContextHolder.States.DoubleSidedState; highlighted.Draw(DeviceContextHolder, ActualCamera, SpecialRenderMode.Outline); DeviceContext.ClearRenderTargetView(_outlineBuffer.TargetView, Color.Transparent); DeviceContext.OutputMerger.SetTargets(_outlineBuffer.TargetView); var effect = DeviceContextHolder.GetEffect <EffectPpOutline>(); effect.FxDepthMap.SetResource(_outlineDepthBuffer.View); effect.FxScreenSize.Set(new Vector4(ActualWidth, ActualHeight, 1f / ActualWidth, 1f / ActualHeight)); DeviceContextHolder.PrepareQuad(effect.LayoutPT); effect.TechOutline.DrawAllPasses(DeviceContext, 6); }
public void Render(Action immediateDrall = null) { //process resize if (m_needResize) { DoResizeBuffer(); m_needResize = false; } if (immediateDrall != null) { immediateDrall.Invoke(); } EventPreRender.Invoke(); m_context.ClearDepthStencilView(m_depthcStencilView, DepthStencilClearFlags.Depth, 1.0f, 0); m_context.ClearRenderTargetView(m_renderTargetView, Color.Black); //do render { m_commandBuffer[CommandBufferStage.PreRender].ForEach((x) => { x.Render(this); }); m_commandBuffer[CommandBufferStage.Default].ForEach((x) => { x.Render(this); }); m_commandBuffer[CommandBufferStage.PostRender].ForEach((x) => { x.Render(this); }); } m_swapchain.Present(1, PresentFlags.None); }
public void Render(DeviceContext deviceContext, Viewport viewport, RenderTargetView renderTargetView, DepthStencilView depthStencilView) { deviceContext.ClearRenderTargetView(renderTargetView, Constants.CLEAR_COLOR); deviceContext.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0x00); var centerDataSpace = mTileManager.TiledDatasetView.CenterDataSpace; var extentDataSpace = mTileManager.TiledDatasetView.ExtentDataSpace; var camera = new Camera( new Vector3(0, 0, 0), new Vector3(0, 0, 1), new Vector3(0, 1, 0), Matrix.OrthoOffCenterLH( centerDataSpace.X - (extentDataSpace.X / 2f), centerDataSpace.X + (extentDataSpace.X / 2f), centerDataSpace.Y + (extentDataSpace.Y / 2f), centerDataSpace.Y - (extentDataSpace.Y / 2f), 0.1f, 100f)); var datasetExtentDataSpaceX = mTileManager.TiledDatasetDescription.TiledVolumeDescriptions.Get("SourceMap").NumTilesX *Constants.ConstParameters.GetInt("TILE_SIZE_X"); var datasetExtentDataSpaceY = mTileManager.TiledDatasetDescription.TiledVolumeDescriptions.Get("SourceMap").NumTilesY *Constants.ConstParameters.GetInt("TILE_SIZE_Y"); mTileManager.GetTileCache().ToList().ForEach(tileCacheEntry => RenderTileCacheEntry(deviceContext, camera, datasetExtentDataSpaceX, datasetExtentDataSpaceY, tileCacheEntry)); //mTinyTextContext.Print( viewport, "Frame Time: " + FrameTimeString, 10, 10 ); //mTinyTextContext.Print( viewport, "Number of Active Cache Entries: " + mTileManager.GetTileCache().Count, 10, 30 ); //mTinyTextContext.Render(); mStopwatch.Reset(); mStopwatch.Start(); }
public override void ClearRenderTarget(DeviceContext context, Color4 color) { foreach (RenderTargetView view in renderTargetView) { context.ClearRenderTargetView(view, color); } }
private void UseEffect(Action <EffectSpecialPaintShop> fn, TargetResourceTexture tex) { if (_paintShopEffect == null) { _paintShopEffect = DeviceContextHolder.GetEffect <EffectSpecialPaintShop>(); var s = Stopwatch.StartNew(); _paintShopEffect.FxNoiseMap.SetResource(DeviceContextHolder.GetRandomTexture(OptionPaintShopRandomSize, OptionPaintShopRandomSize)); AcToolsLogging.Write($"Random texture: {s.Elapsed.TotalMilliseconds:F1} ms"); } using (DeviceContextHolder.SaveRenderTargetAndViewport()) { DeviceContextHolder.PrepareQuad(_paintShopEffect.LayoutPT); DeviceContext.Rasterizer.SetViewports(tex.Viewport); DeviceContext.OutputMerger.SetTargets(tex.TargetView); DeviceContext.ClearRenderTargetView(tex.TargetView, new Color4(0f, 0f, 0f, 0f)); DeviceContext.OutputMerger.BlendState = null; DeviceContext.OutputMerger.DepthStencilState = null; DeviceContext.Rasterizer.State = null; _paintShopEffect.FxNoiseMultipler.Set((float)Math.Max(tex.Width, tex.Height) / OptionPaintShopRandomSize); _paintShopEffect.FxSize.Set(new Vector4(tex.Width, tex.Height, 1f / tex.Width, 1f / tex.Height)); fn?.Invoke(_paintShopEffect); } }
internal static void ClearBackbuffer(ColorBGRA clearColor) { if (Backbuffer != null) { DeviceContext.ClearRenderTargetView((Backbuffer as IRenderTargetBindable).RTV, new Color4(0.005f, 0, 0.01f, 1)); } }
public void BeginScene(Color4 color) { // Clear the back buffer. DeviceContext.ClearRenderTargetView(RenderTargetView, color); // Clear the depth buffer. DeviceContext.ClearDepthStencilView(DepthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0); }
public void BeginScene(float red, float green, float blue, float alpha) { // Clear the depth buffer. DeviceContext.ClearDepthStencilView(DepthStencilView, DepthStencilClearFlags.Depth, 1, 0); // Clear the back buffer. DeviceContext.ClearRenderTargetView(_renderTargetView, new Color4(red, green, blue, alpha)); }
public override void RenderScene() { if ((!IsInitialized) || IsDisposed) { return; } _deviceContext.ClearRenderTargetView(_renderTargetView, ClearColor); _deviceContext.ClearDepthStencilView(_depthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0); foreach (var shape in _shapes) { var SRT = Matrix4x4.CreateScale(shape.Size) * shape.Transform; var model = ToSlimDXMatrix(SRT); if (shape.GetType() == typeof(Box)) { DrawBox(model); } else if (shape.GetType() == typeof(Quad)) { DrawQuad(model); } } _swapChain.Present(0, PresentFlags.None); }
internal void InternalRebuildCommandList(GraphicsContext context) { if (m_commandData.Count == 0) { return; } var deferred = new DeviceContext(context.Device); foreach (var cmd in m_commandData) { switch (cmd.Type) { case CommandDataType.ClearRenderTarget: deferred.ClearRenderTargetView(cmd.ParamRTId.GetRawRenderTexture <RenderTargetView>(context), new SharpDX.Color(0, 0, 0, 0)); break; case CommandDataType.Draw: break; } } m_commandList = deferred.FinishCommandList(false); deferred.Dispose(); deferred = null; }
public void Prepare(DeviceContext context, Color color, byte stencil, Action prepareMask) { context.ClearRenderTargetView(RenderTargetView, color); context.ClearDepthStencilView(DepthTargetView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, RenderingConstants.DepthClearValue, stencil); SetAsTarget(context); prepareMask(); }
public void BindComponents(DeviceContext deviceContext) { deviceContext.Rasterizer.SetViewport(viewport); // deviceContext.OutputMerger.SetRenderTargets(RenderTargetView); deviceContext.ClearDepthStencilView(DepthMapDsv, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1f, 0); deviceContext.ClearRenderTargetView(RenderTargetViews[0], Color.White); }
/// <summary> /// Clears the targets. /// </summary> /// <param name="context">The context.</param> /// <param name="c">The c.</param> public void ClearTargets(DeviceContext context, Color c) { foreach (var target in renderTargetBlur) { context.ClearRenderTargetView(target, c); } }
protected override void BeginRenderPassCore(RenderPassDescriptor descriptor) { // Setup color attachments. int renderTargetCount = 0; for (var i = 0; i < descriptor.ColorAttachments.Length; ++i) { ref var colorAttachment = ref descriptor.ColorAttachments[i]; var textureView = (D3D11TextureView)colorAttachment.Attachment; RenderTargetViews[i] = textureView.RenderTargetView; switch (colorAttachment.LoadAction) { case LoadAction.Clear: _context.ClearRenderTargetView( RenderTargetViews[i], D3DConvert.Convert(colorAttachment.ClearColor) ); break; default: break; } renderTargetCount++; }
internal void OnOpenedCommandList(DeviceContext context) { var depthStencilView = _depthStencilBuffer?.DeviceDepthStencilView; context.OutputMerger.SetRenderTargets( depthStencilView, _renderTargetDescriptor.RenderTarget.DeviceRenderTargetView); switch (_renderTargetDescriptor.LoadAction) { case LoadAction.DontCare: break; case LoadAction.Load: throw new NotSupportedException(); case LoadAction.Clear: context.ClearRenderTargetView( _renderTargetDescriptor.RenderTarget.DeviceRenderTargetView, _renderTargetDescriptor.ClearColor); break; default: throw new InvalidOperationException(); } if (depthStencilView != null) { context.ClearDepthStencilView( depthStencilView, DepthStencilClearFlags.Depth, _depthStencilBuffer.ClearValue, 0); } }
protected override void DrawPrepare() { base.DrawPrepare(); if (Sun != null && UseShadows) { _sunShadows.Update(Sun.Direction, Camera); _sunShadows.DrawScene(DeviceContextHolder, this); } if (UseCubemapReflections) { _reflectionCubemap.Update(ReflectionCubemapPosition); _reflectionCubemap.DrawScene(DeviceContextHolder, this); } DeviceContext.OutputMerger.SetTargets(_gDepthBuffer.DepthView, _gBufferBase.TargetView, _gBufferNormal.TargetView, _gBufferMaps.TargetView); DeviceContext.ClearDepthStencilView(_gDepthBuffer.DepthView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1f, 0); DeviceContext.ClearRenderTargetView(_gBufferBase.TargetView, ColorTransparent); DeviceContext.ClearRenderTargetView(_gBufferNormal.TargetView, ColorTransparent); DeviceContext.ClearRenderTargetView(_gBufferMaps.TargetView, ColorTransparent); DeviceContext.OutputMerger.BlendState = null; }
private void Draw(float time) { _dx11DeviceContext.ClearRenderTargetView(_renderView, Color); _dx11DeviceContext.ClearDepthStencilView(_depthView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0); OnDraw?.Invoke(time); _swapChain.Present(0, PresentFlags.None); }
protected override void DrawOverride() { using (var rasterizerState = RasterizerState.FromDescription(Device, new RasterizerStateDescription { FillMode = FillMode.Wireframe, CullMode = CullMode.None, IsAntialiasedLineEnabled = UseAntialiazing, IsFrontCounterclockwise = false, IsDepthClipEnabled = true })) { DeviceContext.OutputMerger.BlendState = null; DeviceContext.Rasterizer.State = rasterizerState; DeviceContext.ClearRenderTargetView(RenderTargetView, Color.Transparent); using (var buffer = TargetResourceTexture.Create(Format.R8G8B8A8_UNorm)) { buffer.Resize(DeviceContextHolder, Width, Height, null); DeviceContext.ClearRenderTargetView(buffer.TargetView, Color.Transparent); DeviceContext.OutputMerger.SetTargets(buffer.TargetView); RenderUv(); DeviceContext.Rasterizer.State = null; PrepareForFinalPass(); if (UseFxaa) { DeviceContextHolder.GetHelper <FxaaHelper>().Draw(DeviceContextHolder, buffer.View, RenderTargetView); } else { DeviceContextHolder.GetHelper <CopyHelper>().Draw(DeviceContextHolder, buffer.View, RenderTargetView); } } } }
private void AddShadow() { DeviceContext.OutputMerger.BlendState = _bakedBlendState; DeviceContext.OutputMerger.DepthStencilState = null; DeviceContext.Rasterizer.State = null; DeviceContext.Rasterizer.SetViewports(Viewport); DeviceContext.OutputMerger.SetTargets(_bufferF1.TargetView); DeviceContext.ClearRenderTargetView(_bufferF1.TargetView, new Color4(0f, 0f, 0f, 0f)); _effect.FxDepthMap.SetResource(_shadowBuffer.View); _effect.FxShadowViewProj.SetMatrix(_shadowCamera.ViewProj * new Matrix { M11 = 0.5f, M22 = -0.5f, M33 = 1.0f, M41 = 0.5f, M42 = 0.5f, M44 = 1.0f }); RenderPieces(); // DeviceContext.Rasterizer.State = null; // copy to summary buffer DeviceContext.OutputMerger.BlendState = _summBlendState; DeviceContextHolder.GetHelper <CopyHelper>().Draw(DeviceContextHolder, _bufferF1.View, _bufferFSumm.TargetView); }
public void RunFrame() { // clear the render target to a soothing blue context.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0); context.ClearRenderTargetView(renderTarget, new Color4(0.0f, 0.5f, 1.0f)); var view = Matrix.LookAtLH(camera.Position, camera.LookAtPosition, camera.UpVector); var proj = Matrix.PerspectiveFovLH(DegToRad(45.0f), (float)this.ClientSize.Width / (float)this.ClientSize.Height, 0.1f, 100.0f); ConstantBuffer constantData = new ConstantBuffer { worldMatrix = Matrix.Identity, viewMatrix = Matrix.Transpose(view), projectionMatrix = proj, colour = new Color4(0.5f, 1.0f, 0.0f) }; using (var data = new DataStream(Marshal.SizeOf(constantData), true, true)) { data.Write(constantData); data.Position = 0; context.UpdateSubresource(new DataBox(0, 0, data), constantBuffer, 0); } context.VertexShader.SetConstantBuffer(constantBuffer, 0); context.PixelShader.SetConstantBuffer(constantBuffer, 0); // draw the triangle context.Draw(triangleCount * 3, 0); swapChain.Present(0, PresentFlags.None); }
public static void RenderFrame() { if (Update != null) { Update(); } context.ClearRenderTargetView(renderTarget, new Color4(0.17f, 0.47f, 0.79f)); context.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0); viewMatrix = camera.GetViewMatrix(); SetWVP(Matrix.Identity); if (ActiveModel != null) { ActiveModel.Draw(); } SetWVP(Matrix.Identity); grid.Draw(); if (ActiveEditor != null) { SetWVP(Matrix.Identity); ActiveEditor.DrawUI(); } swapChain.Present(0, PresentFlags.None); }
public void Render(DeviceContext deviceContext, Viewport viewport, RenderTargetView renderTargetView, DepthStencilView depthStencilView) { deviceContext.ClearRenderTargetView(renderTargetView, CLEAR_COLOR); if (mSegmenter.DatasetLoaded) { deviceContext.InputAssembler.InputLayout = mInputLayout; deviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip; deviceContext.InputAssembler.SetVertexBuffers(POSITION_SLOT, new VertexBufferBinding(mPositionVertexBuffer, POSITION_NUM_COMPONENTS_PER_VERTEX * POSITION_NUM_BYTES_PER_COMPONENT, 0)); deviceContext.InputAssembler.SetVertexBuffers(TEXCOORD_SLOT, new VertexBufferBinding(mTexCoordVertexBuffer, TEXCOORD_NUM_COMPONENTS_PER_VERTEX * TEXCOORD_NUM_BYTES_PER_COMPONENT, 0)); mEffect.GetVariableByName(CurrentTextureName).AsResource().SetResource(mSegmenter.D3D11CudaTextureEnumerator.Current.Value); mEffect.GetVariableByName("gSourceMapTexture3D").AsResource().SetResource(mSegmenter.Interop.D3D11CudaTextures.Get("SourceMap")); mEffect.GetVariableByName("gPrimalMapTexture3D").AsResource().SetResource(mSegmenter.Interop.D3D11CudaTextures.Get("PrimalMap")); mEffect.GetVariableByName("gColorMapTexture3D").AsResource().SetResource(mSegmenter.Interop.D3D11CudaTextures.Get("ColorMap")); mEffect.GetVariableByName("gConstraintMapTexture3D").AsResource().SetResource(mSegmenter.Interop.D3D11CudaTextures.Get("ConstraintMap")); mEffect.GetVariableByName("gPrimalMapThreshold").AsScalar().Set(Constants.Parameters.GetFloat("PRIMAL_MAP_THRESHOLD")); mEffect.GetVariableByName("gRecordingMode").AsScalar().Set((int)Constants.RECORDING_MODE); mEffect.GetVariableByName("gSplitMode").AsScalar().Set(SplitMode); mEffect.GetVariableByName("gCurrentSliceCoordinate").AsScalar().Set(CurrentSliceCoordinate); mEffect.GetVariableByName("gCurrentTextureIndex").AsScalar().Set(CurrentTextureIndex); mEffect.GetVariableByName("gCurrentTextureDimensions").AsScalar().Set(CurrentTextureDimensions); mEffect.GetVariableByName("gCurrentNeuralProcessColor").AsVector().Set(CurrentNeuralProcessColor); mEffect.GetVariableByName("gSplitNeuralProcessColor").AsVector().Set(SplitNeuralProcessColor); mPass.Apply(deviceContext); deviceContext.Draw(NUM_VERTICES, 0); if (Constants.RECORDING_MODE == RecordingMode.NotRecording) { mTinyTextContext.Print(viewport, "Current Z Slice Coordinate: " + CurrentSliceCoordinate + " (slice " + mSegmenter.CurrentSlice + ")", 10, 10); mTinyTextContext.Print(viewport, "Current Texture: " + mSegmenter.D3D11CudaTextureEnumerator.Current.Key, 10, 30); mTinyTextContext.Print(viewport, "Frame Time: " + FrameTimeString, 10, 50); mTinyTextContext.Print(viewport, "Primal Dual Energy Gap: " + mSegmenter.Interop.ConvergenceGap, 10, 70); mTinyTextContext.Print(viewport, "Primal Dual Energy Gap Delta: " + mSegmenter.Interop.ConvergenceGapDelta, 10, 90); mTinyTextContext.Print(viewport, "Current Neural Process: " + CurrentNeuralProcessString, 10, 110); mTinyTextContext.Print(viewport, "Segmenter Dimension Mode: " + mSegmenter.DimensionMode, 10, 130); mTinyTextContext.Print(viewport, "Segmenter Max Foreground Cost Delta: " + mSegmenter.Interop.MaxForegroundCostDelta, 10, 150); mTinyTextContext.Render(); } mStopwatch.Reset(); } else { mTinyTextContext.Print(viewport, "No dataset loaded.", 10, 10); mTinyTextContext.Render(); } }
internal static void ClearBackbuffer(VRageMath.Color clearColor) { if (Backbuffer != null) { var v3 = clearColor.ToVector3(); DeviceContext.ClearRenderTargetView((Backbuffer as IRenderTargetBindable).RTV, new Color4(v3.X, v3.Y, v3.Z, 1)); } }
private void Clear(Color4 color) { // Clear the back buffer deviceContext.ClearRenderTargetView(backBufferView, color); // Clear the depth buffer DeviceContext.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0); }
public override void Draw(Device device, DeviceContext context, RenderTargetView renderTargetView) { // We just clear the render target view context.ClearRenderTargetView(renderTargetView, Color.CornflowerBlue); // Ask the DrawingSurface to call us back host.RequestAdditionalFrame(); }
public void ClearRenderTarget(DeviceContext deviceContext, DepthStencilView depthStencilView, Color4 color) { deviceContext.ClearRenderTargetView(_renderTargetView, color); deviceContext.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0); return; }
private void BeginScene(Color4 givenColour) { // Clear the depth buffer. DeviceContext.ClearDepthStencilView(DepthStencilView, DepthStencilClearFlags.Depth, 1, 0); // Clear the back buffer. DeviceContext.ClearRenderTargetView(RenderTargetView, givenColour); }
/// <summary> /// Clears the instance /// </summary> /// <param name="context"></param> public override void Clear(DeviceContext context) { base.Clear(context); if (RenderTargetClearSettings.IsClearRenderTarget) { context.ClearRenderTargetView(RenderTargetView, RenderTargetClearSettings.ClearColor); } }
public void Render( DeviceContext deviceContext, Viewport viewport, RenderTargetView renderTargetView, DepthStencilView depthStencilView ) { deviceContext.ClearRenderTargetView( renderTargetView, Constants.CLEAR_COLOR ); deviceContext.ClearDepthStencilView( depthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0x00 ); //mTinyTextContext.Print( viewport, "Frame Time: " + FrameTimeString, 10, 10 ); //mTinyTextContext.Render(); mStopwatch.Reset(); mStopwatch.Start(); }
public void ClearRenderTarget(DeviceContext context, DepthStencilView depthStencilView, float red, float green, float blue, float alpha) { // Setup the color the buffer to. var color = new Color4(red, green, blue, alpha); // Clear the back buffer. context.ClearRenderTargetView(RenderTargetView, color); // Clear the depth buffer. context.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0); }
/// <summary> /// Clears the instance /// </summary> /// <param name="context"></param> public override void Clear(DeviceContext context) { base.Clear(context); if (!RenderTargetClearSettings.IsClearRenderTarget) return; Device11Mutex.Acquire(0, -1); { context.ClearRenderTargetView(RenderTargetView11, RenderTargetClearSettings.ClearColor); } Device11Mutex.Release(0); }
/// <summary> /// Enable the rendering in this viewport /// </summary> public void EnableViewport(DeviceContext devCont) { // Set the render target to the specific viewport devCont.OutputMerger.SetTargets( m_DepthStencilView, m_RenderTarget ); /// Clear or fill the Render target with a single color devCont.ClearRenderTargetView( m_RenderTarget, new Color4( 0.0f, 0.0f, 0.0f, 1.0f ) ); //m_RenderTarget, new Color4( 0.0f, 0.125f, 0.3f, 1.0f ) ); /// clear the depth buffer to 1.0 (max depth) devCont.ClearDepthStencilView( m_DepthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0 ); /// Set the selected camera to the /// camera of the selected viewport Engine.g_RenderCamera = m_Camera; /// Apply the viewport the rasterizer /// (the thing that actually draws the triangle) devCont.Rasterizer.SetViewport( m_Viewport.X, m_Viewport.Y, m_Viewport.Width, m_Viewport.Height, m_Viewport.MinZ, m_Viewport.MaxZ); if ( m_RasterizerState.Description.FillMode != Settings.FillMode || m_RasterizerState.Description.CullMode != Settings.CullMode) { m_RasterizerStateDesc = new RasterizerStateDescription(); m_RasterizerStateDesc.CullMode = Settings.CullMode; m_RasterizerStateDesc.FillMode = Settings.FillMode; m_RasterizerStateDesc.IsDepthClipEnabled = true; m_RasterizerStateDesc.IsScissorEnabled = false; m_RasterizerStateDesc.IsMultisampleEnabled = false; m_RasterizerStateDesc.IsAntialiasedLineEnabled = false; m_RasterizerStateDesc.SlopeScaledDepthBias = 0.0f; m_RasterizerStateDesc.DepthBiasClamp = 0.0f; m_RasterizerStateDesc.DepthBias = 0; m_RasterizerState = new RasterizerState( Engine.g_device, m_RasterizerStateDesc ); } /// set the rasterizer state devCont.Rasterizer.State = m_RasterizerState; }
public void ClearRenderTarget(DeviceContext context, DepthStencilView depthStencilView, float red, float green, float blue, float alpha) { context.ClearRenderTargetView(_renderTargetView, new Color4(red, green, blue, alpha)); context.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0); }
public override void ClearRenderTarget(DeviceContext context, Color4 color) { context.ClearRenderTargetView(renderTargetView, color); }
public void Render( DeviceContext deviceContext, Viewport viewport, RenderTargetView renderTargetView, DepthStencilView depthStencilView ) { deviceContext.ClearRenderTargetView( renderTargetView, Constants.CLEAR_COLOR ); deviceContext.ClearDepthStencilView( depthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, 1.0f, 0x00 ); var centerDataSpace = mTileManager.TiledDatasetView.CenterDataSpace; var extentDataSpace = mTileManager.TiledDatasetView.ExtentDataSpace; var camera = new Camera( new Vector3( 0, 0, 0 ), new Vector3( 0, 0, 1 ), new Vector3( 0, 1, 0 ), Matrix.OrthoOffCenterLH( centerDataSpace.X - ( extentDataSpace.X / 2f ), centerDataSpace.X + ( extentDataSpace.X / 2f ), centerDataSpace.Y + ( extentDataSpace.Y / 2f ), centerDataSpace.Y - ( extentDataSpace.Y / 2f ), 0.1f, 100f ) ); var datasetExtentDataSpaceX = mTileManager.TiledDatasetDescription.TiledVolumeDescriptions.Get( "SourceMap" ).NumTilesX * Constants.ConstParameters.GetInt( "TILE_SIZE_X" ); var datasetExtentDataSpaceY = mTileManager.TiledDatasetDescription.TiledVolumeDescriptions.Get( "SourceMap" ).NumTilesY * Constants.ConstParameters.GetInt( "TILE_SIZE_Y" ); mTileManager.GetTileCache().ToList().ForEach( tileCacheEntry => RenderTileCacheEntry( deviceContext, camera, datasetExtentDataSpaceX, datasetExtentDataSpaceY, tileCacheEntry, viewport ) ); //mTinyTextContext.Print( viewport, "Frame Time: " + FrameTimeString, 10, 10 ); //mTinyTextContext.Print( viewport, "Number of Active Cache Entries: " + mTileManager.GetTileCache().Count, 10, 30 ); //mTinyTextContext.Render(); mStopwatch.Reset(); mStopwatch.Start(); }
/// <summary> /// Composes an aperture. /// </summary> /// <param name="context">The device context.</param> /// <param name="output">The output render target.</param> /// <param name="profile">The optical profile to use.</param> /// <param name="pass">A SurfacePass instance to use.</param> /// <param name="time">The elapsed time.</param> /// <param name="dt">The time since last call.</param> public void Compose(DeviceContext context, GraphicsResource output, OpticalProfile profile, SurfacePass pass, double time, double dt) { context.ClearRenderTargetView(output.RTV, Color4.White); context.OutputMerger.SetBlendState(blendState); foreach (ApertureLayer layer in layers) layer.ApplyLayer(context, output, profile, pass, time, dt); context.OutputMerger.SetBlendState(null); }
public void SetRenderTarget(DeviceContext context, DepthStencilView depthStencilView) { // Bind the render target view and depth stencil buffer to the output pipeline. context.OutputMerger.SetTargets(depthStencilView, texRenderTargetView); // Setup the color the buffer to. var color = new Color4(0.0f, 0.0f, 1.0f, 1.0f); // Clear the render to texture buffer. context.ClearRenderTargetView(texRenderTargetView, color); // Clear the depth buffer. context.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0); }
public static void RenderCubemap(DeviceContext context, TextureObject targetTexture, TextureObject targetDepth, SimpleSceneWrapper sceneWrapper, Vector3 position, float range, bool depthOnly = false, Color4 clearColor = new Color4()) { //using (new GpuProfilePoint(context, "CubemapRendering")) { // some hardcoded near plane Matrix projectionMatrix = Matrix.PerspectiveFovLH((float)Math.PI / 2.0f, 1.0f, 0.05f, range); ContextHelper.SetDepthStencilState(context, ContextHelper.DepthConfigurationType.DepthCompare); // set the shaders context.VertexShader.Set(ShaderManager.GetVertexShader("VertexScene")); context.PixelShader.Set(depthOnly ? null : ShaderManager.GetPixelShader("PixelSceneSimple")); dynamic cvpb = m_CurrentViewportBuffer; for (int i = 0; i < 6; ++i) { Vector3 lookAt = new Vector3(); Vector3 upVec = new Vector3(); switch (i) { case 0: lookAt = new Vector3(1.0f, 0.0f, 0.0f); upVec = new Vector3(0.0f, 1.0f, 0.0f); break; case 1: lookAt = new Vector3(-1.0f, 0.0f, 0.0f); upVec = new Vector3(0.0f, 1.0f, 0.0f); break; case 2: lookAt = new Vector3(0.0f, 1.0f, 0.0f); upVec = new Vector3(0.0f, 0.0f, -1.0f); break; case 3: lookAt = new Vector3(0.0f, -1.0f, 0.0f); upVec = new Vector3(0.0f, 0.0f, 1.0f); break; case 4: lookAt = new Vector3(0.0f, 0.0f, 1.0f); upVec = new Vector3(0.0f, 1.0f, 0.0f); break; case 5: lookAt = new Vector3(0.0f, 0.0f, -1.0f); upVec = new Vector3(0.0f, 1.0f, 0.0f); break; } Matrix viewMatrix = Matrix.LookAtLH(position, position + lookAt, upVec); cvpb.g_ProjMatrix = projectionMatrix; cvpb.g_ViewMatrix = viewMatrix; cvpb.g_ViewProjMatrix = viewMatrix * projectionMatrix; { context.ClearRenderTargetView(targetTexture.m_ArrayRenderTargetViews[i], clearColor); context.ClearDepthStencilView(targetDepth.m_ArrayDepthStencilViews[i], DepthStencilClearFlags.Depth, 1.0f, 0); RenderTargetSet.BindTextureAsRenderTarget(context, targetTexture.m_ArrayRenderTargetViews[i], targetDepth.m_ArrayDepthStencilViews[i], targetTexture.m_Width, targetTexture.m_Height); m_CurrentViewportBuffer.CompileAndBind(context); // render triangles sceneWrapper.Render(context); RenderTargetSet.BindNull(context); } } ContextHelper.SetDepthStencilState(context, ContextHelper.DepthConfigurationType.NoDepth); } }
public void Render(RenderTargetView renderTargetView, DeviceContext context, SurfacePass pass) { // TODO: generate sky envmap here, with custom params pass.Pass(context, @" struct PS_IN { float4 pos : SV_POSITION; float2 tex : TEXCOORD; }; float3 main(PS_IN input) : SV_Target { float phi = 2 * 3.14159265 * input.tex.x; float theta = 3.14159265 * input.tex.y; float3 p = float3(sin(theta) * cos(phi), cos(theta), sin(theta) * sin(phi)); float brightness = 500; if (p.y < 0) return lerp(float3(1, 1, 1), float3(0, 0, 0), -p.y) * brightness; /* TEMPORARY */ float sunBrightness = (dot(p, normalize(float3(-0.5f, 0.8f, 0.9f))) > 0.9995f) ? 1 : 0; return lerp(float3(1, 1, 1), float3(0.7f, 0.7f, 1), p.y) * brightness + sunBrightness * 50000; } ", skyEnvMap.Dimensions, skyEnvMap.RTV, null, null); context.OutputMerger.SetRenderTargets((RenderTargetView)null); context.ClearDepthStencilView(depthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0); context.ClearRenderTargetView(renderTargetView, new Color4(0.5f, 0, 1, 1)); context.Rasterizer.State = rasterizerState; context.OutputMerger.DepthStencilState = depthStencilState; context.OutputMerger.SetTargets(depthStencilView, renderTargetView); context.Rasterizer.SetViewports(new[] { new ViewportF(0, 0, RenderDimensions.Width, RenderDimensions.Height) }); context.Rasterizer.SetScissorRectangles(new[] { new SharpDX.Rectangle(0, 0, RenderDimensions.Width, RenderDimensions.Height) }); context.VertexShader.Set(vertexShader); context.InputAssembler.InputLayout = inputLayout; context.PixelShader.SetShaderResource(0, skyEnvMap.SRV); context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; { DataStream cameraStream; context.MapSubresource(cameraBuffer, MapMode.WriteDiscard, MapFlags.None, out cameraStream); camera.WriteTo(cameraStream); context.UnmapSubresource(cameraBuffer, 0); cameraStream.Dispose(); } context.VertexShader.SetConstantBuffer(0, cameraBuffer); context.PixelShader.SetConstantBuffer(0, cameraBuffer); foreach (Model model in models.Values) model.Render(context, camera, materials, proxy); }
public void ClearRenderTarget(DeviceContext context, int arrayIndex, Color4 color) { context.ClearRenderTargetView(renderTargetView[arrayIndex], color); }
/**************************************************************************************************** * ****************************************************************************************************/ public void Clear(DeviceContext context, Color4 color4) { context.ClearRenderTargetView(RenderTargetView, color4); }
public void Clear(DeviceContext context, Color4 color, bool depth = false) { for (int i = 0; i < m_NumRTs; ++i) { context.ClearRenderTargetView(m_RenderTargets[i].m_RenderTargetView, color); } if (depth && m_DepthStencil.m_DepthStencilView != null) { context.ClearDepthStencilView(m_DepthStencil.m_DepthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0); } }
public void Draw(float TimeMili, Device device, DeviceContext context) { if (RebderCube) { RebderCube = false; SkyBox.RenderCubemap(); } Random R = new Random(2); for (int i = 0; i < 0; i+=2) { DVector3 t = new DVector3(R.NextDouble(-500, 500), R.NextDouble(-500, 500), R.NextDouble(-500, 500)); LensBatching.DrawLens(t, new Vector2(5, 5), new Vector2(0, 0), new Vector2(1, 1), new Vector4(1, 0, 0, 1), TC1); t = new DVector3(R.NextDouble(-500, 500), R.NextDouble(-500, 500), R.NextDouble(-500, 500)); LensBatching.DrawLens(t, new Vector2(5, 5), new Vector2(0, 0), new Vector2(1, 1), new Vector4(0, 0, 1, 1), TC2); } LensBatching.DrawLens(Camera.position + Conversion.ToDoubleVector(-LightDirection)*Camera.farClip*0.95f, new Vector2(1000, 1000), new Vector2(0, 0), new Vector2(1, 1), new Vector4(1, 0, 0, 1), TC1); KDtree KDT = new KDtree(20, AllObjects); List<GameObject> InCam = KDT.GetBodyInCamera(Camera.position, Camera.LcameraFrustum); DebugDraw.ResetLine(); //Depth device.ImmediateContext.OutputMerger.SetTargets(DepthMapStencilView, DepthTarget); device.ImmediateContext.ClearDepthStencilView(DepthMapStencilView, DepthStencilClearFlags.Depth, 1.0f, 0); context.ClearRenderTargetView(DepthTarget, new Color4(1.0f, 0.0f, 0.0f, 1.0f)); for (int i = 0; i < InCam.Count; i++) if (InCam[i] != null) InCam[i].DrawDepth(device, Camera); PSSMsHelper.RenderAllSplits(device, Camera, Conversion.ToDoubleVector(LightDirection), KDT, InCam); // DrawHelper.OcclusionTest(device, Camera, DepthSRV); // context.Rasterizer.SetViewports(Program.viewport); context.OutputMerger.SetTargets(DepthStencilView, HDRTarget); context.ClearRenderTargetView(HDRTarget, new Color4(0.5f, 0.5f, 1.0f, 1.0f)); context.ClearDepthStencilView(DepthStencilView, DepthStencilClearFlags.Depth, 1.0f, 0); //DebugDraw.AddLine(new DebugLine(KDT.Root.AA, KDT.Root.BB, new Vector3(1, 0, 0))); //DebugDraw.DrawAABB(KDT.Root.AA, KDT.Root.BB, new Vector3(1, 0, 0)); //DebugDraw.DrawKDTree(KDT, new Vector3(1, 0, 0)); //DebugDraw.DrawLocator(new DVector3(50, 50, 0), 5, new Vector3(0, 1, 0)); SkyBox.Draw(TimeMili, device, context, Camera); /* for (int i = 0; i < InCam.Count; i++) if (InCam[i] != null) InCam[i].Draw(device, Camera, Light, LightDirection); */ PSSMsHelper.RenderObj(TimeMili, device, Camera, LightDirection, Light.Color, InCam); for (int i = 0; i < InCam.Count; i++) if (InCam[i] != null) InCam[i].DrawEffects(device, Camera); LensBatching.BatchingDrawLens(device, Camera, DepthSRV); DebugDraw.Draw(device, Camera); /* foreach (GSSprite TS_ in TS) { TS_.Render(device, Camera, DepthSRV); } */ //context.OutputMerger.SetTargets(renderTarget); //HDRSRV //DepthSRV QuadScreen.FinalRender(device, TimeMili, context, HDRSRV, DepthSRV, renderTarget); /* Int64 TStart = Program.HiTimer.Value; Int64 TStop = Program.HiTimer.Value; float Time = Program.HiTimer.Tick2Mili(TStop - TStart); Program.form.Text = Time.ToString();*/ }