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


C# RenderHelper.PushRenderTargetBinding方法代码示例

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


在下文中一共展示了RenderHelper.PushRenderTargetBinding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExecuteTechnic

        protected override void ExecuteTechnic(Microsoft.Xna.Framework.GameTime gameTime, RenderHelper render, IWorld world)
        {
            ICamera camera = world.CameraManager.ActiveCamera;
            Matrix view = world.CameraManager.ActiveCamera.View;
            Matrix projection = world.CameraManager.ActiveCamera.Projection;

            ComputeFrustumCorners(camera);

            world.Culler.StartFrame(ref view, ref projection, world.CameraManager.ActiveCamera.BoundingFrustum);
            List<IObject> AllnotCulledObjectsList = world.Culler.GetNotCulledObjectsList(null);
            List<IObject> DeferrednotCulledObjectsList = world.Culler.GetNotCulledObjectsList(MaterialType.DEFERRED);
            List<IObject> ForwardnotCulledObjectsList = world.Culler.GetNotCulledObjectsList(MaterialType.FORWARD);

            foreach (IObject item in AllnotCulledObjectsList)
            {
                if (item.Material.IsVisible)
                    item.Material.PreDrawnPhase(gameTime, world, item, world.CameraManager.ActiveCamera, world.Lights, render);
            }
                        
            render.PushRenderTargetBinding(_gBufferBinding);
            render.Clear(Color.Black,ClearOptions.DepthBuffer | ClearOptions.Stencil, 1.0f, 0);           

            render.PushDepthStencilState(DepthStencilState.None);
            render.PushRasterizerState(RasterizerState.CullNone);
            render.RenderFullScreenQuadVertexPixel(_clearGBuffer);
            render.PopDepthStencilState();
            render.PopRasterizerState();
            

            foreach (IObject item in DeferrednotCulledObjectsList)
            {
                if (item.Material.IsVisible)
                    item.Material.Drawn(gameTime, item, world.CameraManager.ActiveCamera, world.Lights, render);
            }

            render.PopRenderTarget();
            render[PrincipalConstants.DephRT] = _depthBuffer;
            render[PrincipalConstants.normalRt] = _normalBuffer; 
            
            //render.PushRenderTargetBinding(_lightAccumBinding);
            render.Clear(new Color(0, 0, 0, 0));

            render.PushDepthStencilState(DepthStencilState.None);            

            //draw using additive blending. 
            //At first I was using BlendState.additive, but it seems to use alpha channel for modulation, 
            //and as we use alpha channel as the specular intensity, we have to create our own blend state here
            render.PushBlendState(_lightAddBlendState);           
 
            RenderLights(camera,world,render,ginfo);
            
            //render[PrincipalConstants.lightRt] = render.PopRenderTarget()[0].RenderTarget as Texture2D;
            
            render.PopDepthStencilState();
            render.PopBlendState();
            return;
            render.PushRenderTarget(_outputTexture);

            render.Clear(Color.Black);
            
            foreach (IObject item in AllnotCulledObjectsList)
            {
                if (item.Material.IsVisible)
                    item.Material.PosDrawnPhase(gameTime, item, world.CameraManager.ActiveCamera, world.Lights, render);
            }

            if (world.PhysicWorld.isDebugDraw)
            {
                //world.PhysicWorld.iDebugDrawn(render, gameTime, world.CameraManager.ActiveCamera);
            }
            if (world.ParticleManager != null)
            {
                //world.ParticleManager.iDraw(gameTime, world.CameraManager.ActiveCamera.View, world.CameraManager.ActiveCamera.Projection, render);
                //render.ResyncStates();
            }

            ForwardPass.Draw(gameTime, world, render, DeferrednotCulledObjectsList, ForwardnotCulledObjectsList);

            render.RenderPosWithDepthComponents(gameTime, ref view, ref projection);

            render[PrincipalConstants.CurrentImage] = render.PopRenderTargetAsSingleRenderTarget2D();

            for (int i = 0; i < PostEffects.Count; i++)
            {
                if (PostEffects[i].Enabled)
                {
                    render.PushRenderTarget(PostEffectTarget);
                    render.Clear(Color.Black);
                    PostEffects[i].Draw(render[PrincipalConstants.CurrentImage], render, gameTime, ginfo, world, true);
                    Texture2D tex = render.PopRenderTarget()[0].RenderTarget as Texture2D;
                    System.Diagnostics.Debug.Assert(tex != null);
                    render[PrincipalConstants.CurrentImage] = tex;
                    SwapTargetBuffers();
                }
            }

            render.Clear(Color.Black);
            render.RenderTextureComplete(render[PrincipalConstants.CurrentImage], Color.White, ginfo.FullScreenRectangle, Matrix.Identity, null, true, SpriteSortMode.Deferred, SamplerState.PointClamp);                     

            render.RenderPosComponents(gameTime, ref view, ref projection);                        
//.........这里部分代码省略.........
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:101,代码来源:LightPrePassRenderTechnic.cs


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