当前位置: 首页>>代码示例>>C#>>正文


C# RenderDrawContext.PushRenderTargets方法代码示例

本文整理汇总了C#中RenderDrawContext.PushRenderTargets方法的典型用法代码示例。如果您正苦于以下问题:C# RenderDrawContext.PushRenderTargets方法的具体用法?C# RenderDrawContext.PushRenderTargets怎么用?C# RenderDrawContext.PushRenderTargets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RenderDrawContext的用法示例。


在下文中一共展示了RenderDrawContext.PushRenderTargets方法的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);
            }
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:61,代码来源:CameraRendererModeForward.cs

示例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();
                }
            }
开发者ID:cg123,项目名称:xenko,代码行数:19,代码来源:LightDirectionalShadowMapRenderer.cs

示例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;
        }
开发者ID:Kryptos-FR,项目名称:xenko-reloaded,代码行数:39,代码来源:CameraRendererModeForward.cs


注:本文中的RenderDrawContext.PushRenderTargets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。