本文整理汇总了C#中RenderDrawContext.PopRenderTargets方法的典型用法代码示例。如果您正苦于以下问题:C# RenderDrawContext.PopRenderTargets方法的具体用法?C# RenderDrawContext.PopRenderTargets怎么用?C# RenderDrawContext.PopRenderTargets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderDrawContext
的用法示例。
在下文中一共展示了RenderDrawContext.PopRenderTargets方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawCore
protected override void DrawCore(RenderDrawContext context)
{
var currentViewport = context.CommandList.Viewport;
// GBuffer
//if (GBuffer)
//{
// context.PushRenderTargets();
//
// var gbuffer = PushScopedResource(Context.Allocator.GetTemporaryTexture2D((int)currentViewport.Width, (int)currentViewport.Height, GBufferRenderStage.Output.RenderTargetFormat0));
// context.CommandList.Clear(gbuffer, Color4.Black);
// context.CommandList.SetDepthAndRenderTarget(context.CommandList.DepthStencilBuffer, gbuffer);
// RenderSystem.Draw(context, mainRenderView, GBufferRenderStage);
//
// context.PopRenderTargets();
//}
// Shadow maps
var shadowMapRenderer = meshPipelinePlugin?.ForwardLightingRenderFeature?.ShadowMapRenderer;
if (Shadows && shadowMapRenderer != null)
{
// Clear atlases
shadowMapRenderer.PrepareAtlasAsRenderTargets(context.CommandList);
context.PushRenderTargets();
// Draw all shadow views generated for the current view
foreach (var renderView in RenderSystem.Views)
{
var shadowmapRenderView = renderView as ShadowMapRenderView;
if (shadowmapRenderView != null && shadowmapRenderView.RenderView == MainRenderView)
{
var shadowMapRectangle = shadowmapRenderView.Rectangle;
shadowmapRenderView.ShadowMapTexture.Atlas.RenderFrame.Activate(context);
shadowmapRenderView.ShadowMapTexture.Atlas.MarkClearNeeded();
context.CommandList.SetViewport(new Viewport(shadowMapRectangle.X, shadowMapRectangle.Y, shadowMapRectangle.Width, shadowMapRectangle.Height));
RenderSystem.Draw(context, shadowmapRenderView, ShadowMapRenderStage);
}
}
context.PopRenderTargets();
shadowMapRenderer.PrepareAtlasAsShaderResourceViews(context.CommandList);
}
// Draw [main view | main stage]
RenderSystem.Draw(context, MainRenderView, MainRenderStage);
// Some transparent shaders will require the depth as a shader resource - resolve it only once and set it here
Texture depthStencilSRV = ResolveDepthAsSRV(context);
// Draw [main view | transparent stage]
RenderSystem.Draw(context, MainRenderView, TransparentRenderStage);
// Free the depth texture since we won't need it anymore
if (depthStencilSRV != null)
{
context.Resolver.ReleaseDepthStenctilAsShaderResource(depthStencilSRV);
}
}
示例2: DrawCore
protected override void DrawCore(RenderDrawContext context)
{
try
{
context.PushRenderTargets();
minMax.SetInput(context.CommandList.DepthStencilBuffer);
((RendererBase)minMax).Draw(context);
IsResultAvailable = minMax.IsResultAvailable;
if (IsResultAvailable)
{
DepthMinMax = minMax.Result;
}
}
finally
{
context.PopRenderTargets();
}
}
示例3: ResolveDepthAsSRV
private Texture ResolveDepthAsSRV(RenderDrawContext context)
{
if (!enableDepthAsShaderResource)
return null;
context.PushRenderTargets();
var currentRenderFrame = context.RenderContext.Tags.Get(RenderFrame.Current);
var depthStencilSRV = context.Resolver.ResolveDepthStencil(currentRenderFrame.DepthStencil);
foreach (var renderFeature in RenderSystem.RenderFeatures)
{
if (!(renderFeature is RootEffectRenderFeature))
continue;
var depthLogicalKey = ((RootEffectRenderFeature)renderFeature).CreateViewLogicalGroup("Depth");
var viewFeature = MainRenderView.Features[renderFeature.Index];
// Copy ViewProjection to PerFrame cbuffer
foreach (var viewLayout in viewFeature.Layouts)
{
var resourceGroup = viewLayout.Entries[MainRenderView.Index].Resources;
var depthLogicalGroup = viewLayout.GetLogicalGroup(depthLogicalKey);
if (depthLogicalGroup.Hash == ObjectId.Empty)
continue;
// Might want to use ProcessLogicalGroup if more than 1 Recource
resourceGroup.DescriptorSet.SetShaderResourceView(depthLogicalGroup.DescriptorSlotStart, depthStencilSRV);
}
}
depthStencilROCached = context.Resolver.GetDepthStencilAsRenderTarget(currentRenderFrame.DepthStencil, depthStencilROCached);
currentRenderFrame.Activate(context, depthStencilROCached);
context.PopRenderTargets();
return depthStencilSRV;
}