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


C# RenderHelper.Clear方法代码示例

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


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

示例1: Draw

        public override void Draw(Texture2D ImageToProcess,RenderHelper rHelper, GameTime gt, Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatingBuffer)
        {            
            rHelper.PushRenderTarget(renderTarget1);
            Saturate.Parameters["current"].SetValue(ImageToProcess);
            Saturate.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
            if(useFloatingBuffer)
                rHelper.RenderFullScreenQuadVertexPixel(Saturate,SamplerState.PointClamp);
            else
                rHelper.RenderFullScreenQuadVertexPixel(Saturate, SamplerState.LinearClamp);

            Texture2D t = rHelper.PopRenderTargetAsSingleRenderTarget2D();

            rHelper.PushRenderTarget(renderTarget0);
            gaussian.Draw(t, rHelper, gt, GraphicInfo, world,useFloatingBuffer);
            Texture2D x = rHelper.PopRenderTargetAsSingleRenderTarget2D();
            rHelper.Clear(Color.Black);

            Combine.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
            Combine.Parameters["base"].SetValue(ImageToProcess);
            Combine.Parameters["last"].SetValue(x);
            if (useFloatingBuffer)
                rHelper.RenderFullScreenQuadVertexPixel(Combine , SamplerState.PointClamp);
            else
                rHelper.RenderFullScreenQuadVertexPixel(Combine, GraphicInfo.SamplerState);
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:25,代码来源:BloomPostEffect.cs

示例2: Draw

        public override void Draw(Microsoft.Xna.Framework.Graphics.Texture2D ImageToProcess, RenderHelper rHelper, Microsoft.Xna.Framework.GameTime gt, PloobsEngine.Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatBuffer)
        {            
            //mix with last frame downsampled
            if (tex != null)
            {
                rHelper.PushRenderTarget(rtend);
                rHelper.RenderTextureComplete(tex, Color.FromNonPremultiplied(255, 255, 255, 255), GraphicInfo.FullScreenRectangle, Matrix.Identity, null, true, SpriteSortMode.Deferred, SamplerState.LinearClamp);
                rHelper.RenderTextureComplete(ImageToProcess, Color.FromNonPremultiplied(255, 255, 255, Amount), GraphicInfo.FullScreenRectangle, Matrix.Identity, null, true, SpriteSortMode.Deferred, SamplerState.LinearClamp, BlendState.AlphaBlend);                
                end = rHelper.PopRenderTargetAsSingleRenderTarget2D();
            }            

            //DownSample
            rHelper.PushRenderTarget(rt);
            rHelper.Clear(Color.Black);
            if (end == null)
            {
                rHelper.RenderTextureComplete(ImageToProcess, Color.White, rt.Bounds, Matrix.Identity, ImageToProcess.Bounds, true, SpriteSortMode.Deferred, SamplerState.AnisotropicClamp);
            }
            else
            {
                rHelper.RenderTextureComplete(end, Color.White, rt.Bounds, Matrix.Identity, ImageToProcess.Bounds, true, SpriteSortMode.Deferred, SamplerState.AnisotropicClamp);
            }
            tex = rHelper.PopRenderTargetAsSingleRenderTarget2D();                        

            if(end!=null)
                rHelper.RenderTextureComplete(end, Color.White, GraphicInfo.FullScreenRectangle, Matrix.Identity, null, true, SpriteSortMode.Deferred, SamplerState.LinearClamp);
            else
                rHelper.RenderTextureComplete(ImageToProcess, Color.White, GraphicInfo.FullScreenRectangle, Matrix.Identity, null, true, SpriteSortMode.Deferred, SamplerState.LinearClamp);
             
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:30,代码来源:MotionBlurPostEffect.cs

示例3: Draw

        public override void Draw(Texture2D ImageToProcess, RenderHelper rHelper, GameTime gt, GraphicInfo GraphicInfo, IWorld world, bool useFloatingBuffer)
        {
            //if (Keyboard.GetState().IsKeyDown(Keys.Space))
            //{
            //    rHelper.RenderTextureComplete(ImageToProcess);
            //    return;
            //}

                rHelper.PushRenderTarget(rt0);
                rHelper.Clear(Color.Transparent);
                if (mLAntiAliasingEdgeDetectionMode == MLAntiAliasingEdgeDetectionMode.Color)
                    effect.CurrentTechnique = effect.Techniques["ColorEdgeDetection"];
                else
                {
                    effect.CurrentTechnique = effect.Techniques["DepthEdgeDetection"];
                    effect.Parameters["depthTex"].SetValue(rHelper[PrincipalConstants.DephRT]);
                }
                effect.Parameters["PIXEL_SIZE"].SetValue(GraphicInfo.HalfPixel * 2);                
                effect.Parameters["colorTex"].SetValue(rHelper[PrincipalConstants.CombinedImage]);
                effect.Parameters["threshold"].SetValue(0.0008f);
                rHelper.RenderFullScreenQuadVertexPixel(effect);
                Texture edges = rHelper.PopRenderTargetAsSingleRenderTarget2D();                
  
                rHelper.PushRenderTarget(rt1);              
                rHelper.Clear(Color.Transparent);
                effect.CurrentTechnique = effect.Techniques["BlendWeightCalculation"];
                effect.Parameters["areaTex"].SetValue(tex);
                effect.Parameters["edgesTex"].SetValue(edges);
                effect.Parameters["MAX_SEARCH_STEPS"].SetValue(16);
                effect.Parameters["MAX_DISTANCE"].SetValue(65);                
            
                rHelper.RenderFullScreenQuadVertexPixel(effect);
                Texture2D tt = rHelper.PopRenderTargetAsSingleRenderTarget2D();
                        
                rHelper.Clear(Color.Transparent);                
                pass.Parameters["cena"].SetValue(ImageToProcess);                
                
                //if (Keyboard.GetState().IsKeyDown(Keys.RightAlt))
                //{
                //    rHelper.RenderTextureComplete(tt);
                //    return;
                //}
                //else
                //{
                    //pass.Parameters["cena"].SetValue(ImageToProcess);
                    rHelper.RenderFullScreenQuadVertexPixel(pass);                 
                //}
                
                effect.CurrentTechnique = effect.Techniques["NeighborhoodBlending"];
                effect.Parameters["colorTex"].SetValue(ImageToProcess);
                effect.Parameters["blendTex"].SetValue(tt);                
                rHelper.RenderFullScreenQuadVertexPixel(effect);            
                
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:54,代码来源:MLAntiAliasingPostEffect.cs

示例4: Draw

        public override void Draw(Texture2D ImageToProcess, RenderHelper rHelper, Microsoft.Xna.Framework.GameTime gt, PloobsEngine.Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatBuffer)
        {
            rHelper.PushRenderTarget(target);
            rHelper.Clear(Color.Black);
            effectdistorcion.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
            effectdistorcion.Parameters["DEPTH"].SetValue(rHelper[PrincipalConstants.DephRT]);
            effectdistorcion.Parameters["DistortionScale"].SetValue(Distortion);
            rHelper.PushDepthStencilState(DepthStencilState.None);

            foreach (var obj in objs)
            {
                IModelo modelo = obj.Modelo;

                for (int i = 0; i < modelo.MeshNumber; i++)
                {
                    BatchInformation[] bi = modelo.GetBatchInformation(i);
                    for (int j = 0; j < bi.Count(); j++)
                    {
                        Matrix w = bi[j].ModelLocalTransformation * obj.WorldMatrix;
                        effectdistorcion.Parameters["WorldViewProjection"].SetValue(w * world.CameraManager.ActiveCamera.View * world.CameraManager.ActiveCamera.Projection);
                        effectdistorcion.Parameters["WorldView"].SetValue(w * world.CameraManager.ActiveCamera.View);                        
                        rHelper.RenderBatch(bi[j], effectdistorcion);
                    }
                }
            }

           rHelper.PopDepthStencilState();

           x = rHelper.PopRenderTargetAsSingleRenderTarget2D();

           rHelper.Clear(Color.Black);
           effect.Parameters["SceneTexture"].SetValue(ImageToProcess);
           effect.Parameters["DistortionMap"].SetValue(x);
           //effect.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);           
           rHelper.RenderTextureToFullScreenSpriteBatch(ImageToProcess,effect,GraphicInfo.FullScreenRectangle);          
         
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:37,代码来源:StealthPostEffect.cs

示例5: Draw

        public override void Draw(Texture2D ImageToProcess, RenderHelper rHelper, GameTime gt, Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatingBuffer)
        {            
            rHelper.PushRenderTarget(target);
            be.Draw(ImageToProcess, rHelper,  gt, GraphicInfo, world,useFloatingBuffer);                                    
            depht.Parameters["BlurScene"].SetValue(rHelper.PopRenderTargetAsSingleRenderTarget2D());
            depht.Parameters["FarPlane"].SetValue(world.CameraManager.ActiveCamera.FarPlane);
            depht.Parameters["D1M"].SetValue(rHelper[PrincipalConstants.DephRT]);

            rHelper.Clear(Color.Black,ClearOptions.Target);
            SetShaderParameters(distance, range, world.CameraManager.ActiveCamera.NearPlane, world.CameraManager.ActiveCamera.FarPlane);
            if (useFloatingBuffer)
                rHelper.RenderTextureToFullScreenSpriteBatch(ImageToProcess, depht, GraphicInfo.FullScreenRectangle, SamplerState.PointClamp);
            else
                rHelper.RenderTextureToFullScreenSpriteBatch(ImageToProcess, depht, GraphicInfo.FullScreenRectangle, GraphicInfo.SamplerState);            
            
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:16,代码来源:DephtOfFieldPostEffect.cs

示例6: Draw

        protected override void Draw(Microsoft.Xna.Framework.GameTime gameTime, RenderHelper render)
        {
            render.Clear(Color.Black);

            int w = render.GetViewPort().Width;
            int h = render.GetViewPort().Height;

            render.RenderTextComplete(texts[state], new Vector2(w / 2, h / 2), Color.DarkRed, Matrix.Identity, arenScript);

            if (interval < maxInterval)
            {
                interval++;
            }
            else
            {
                ChangeState();
                interval = 0;
            }
        }
开发者ID:tubitos,项目名称:1,代码行数:19,代码来源:LoadingScreen.cs

示例7: Draw

        public override void Draw(Texture2D ImageToProcess, RenderHelper rHelper, GameTime gt, GraphicInfo GraphicInfo, IWorld world, bool useFloatingBuffer)
        {


            effect.Parameters["e_barrier"].SetValue(barrier);
            effect.Parameters["e_kernel"].SetValue(kernel);
            effect.Parameters["e_weights"].SetValue(weights);
            effect.Parameters["pixel_size"].SetValue(GraphicInfo.HalfPixel);            
            effect.Parameters["depthTex"].SetValue(rHelper[PrincipalConstants.DephRT]);
            effect.Parameters["normalTex"].SetValue(rHelper[PrincipalConstants.normalRt]);
            effect.Parameters["image"].SetValue(ImageToProcess);                                    
            rHelper.Clear(Color.Transparent);
            //if (Keyboard.GetState().IsKeyDown(Keys.Space))
            //{
            //    rHelper.RenderTextureComplete(ImageToProcess);
            //    return;
            //}
            if (useFloatingBuffer)
                rHelper.RenderFullScreenQuadVertexPixel(effect, SamplerState.PointClamp);
            else
                rHelper.RenderFullScreenQuadVertexPixel(effect, GraphicInfo.SamplerState);
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:22,代码来源:AntiAliasingPostEffectStalker.cs

示例8: Draw

        public override void Draw(Microsoft.Xna.Framework.Graphics.Texture2D ImageToProcess, RenderHelper rHelper, Microsoft.Xna.Framework.GameTime gt, PloobsEngine.Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatBuffer)
        {
            Matrix v = world.CameraManager.ActiveCamera.View;
            Matrix p = world.CameraManager.ActiveCamera.Projection;
                    
            if (firstTime)
            {
                oldViewProjection = world.CameraManager.ActiveCamera.ViewProjection;
                firstTime = false;
            }
            rHelper.PushRenderTarget(rt);
            rHelper.Clear(Color.Black);
            rHelper.RenderSceneWithCustomMaterial(effectvelocity,
                (effect, obj, bi,ti,s,er,wvp) =>
                {                   
                    Matrix w1 = Matrix.Multiply(obj.WorldMatrix, bi.ModelLocalTransformation);
                    effect.Parameters["wvp"].SetValue(w1 * wvp);
                    effect.Parameters["oldwvp"].SetValue(w1 * oldViewProjection);
                }, world, gt, null, ref v, ref p, false, true);

            Texture2D tex = rHelper.PopRenderTargetAsSingleRenderTarget2D();

            eff.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
            eff.Parameters["numSamples"].SetValue(NumSamples);
            eff.Parameters["velocity"].SetValue(tex);
            eff.Parameters["cena"].SetValue(ImageToProcess);
            eff.Parameters["Attenuation"].SetValue(Attenuation);
            

            oldViewProjection = world.CameraManager.ActiveCamera.ViewProjection;                        

            if (useFloatBuffer)
                rHelper.RenderFullScreenQuadVertexPixel(eff, SamplerState.PointClamp);
            else
                rHelper.RenderFullScreenQuadVertexPixel(eff, GraphicInfo.SamplerState);                
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:36,代码来源:MotionBlurCompletePostEffect.cs

示例9: Draw

        protected override void Draw(GameTime gameTime, RenderHelper render)
        {            
            render.Clear(Color.Black);

            render.RenderTextComplete("Welcome to the Ploobs Game Engine Advanced Demos", new Vector2(40, 30), Color.White,Matrix.Identity);
            render.RenderTextComplete("The Focus here were in the funcionalities, not in the visual", new Vector2(40, 50), Color.Red, Matrix.Identity);
            render.RenderTextComplete("As you will see, we need Modelers =P Join us =P", new Vector2(40, 70), Color.Red, Matrix.Identity);
            render.RenderTextComplete("(Press F1 to cycle through demos)", new Vector2(40, 95), Color.White, Matrix.Identity);
            render.RenderTextComplete("(Press Escape to exit)", new Vector2(40, 115), Color.White, Matrix.Identity);           

        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:11,代码来源:DemosHomeScreen.cs

示例10: Draw

        protected override void Draw(GameTime gameTime, RenderHelper render)
        {            
            render.Clear(Color.Black);

            render.RenderTextComplete("Welcome to the Ploobs Game Engine Funcionality Introduction Demos", new Vector2(40, 30), Color.White, Matrix.Identity);
            render.RenderTextComplete("The focus here is not in the visual, it is in the funcionalities (Check the Source Code =P)", new Vector2(40, 50), Color.Red, Matrix.Identity);            
            render.RenderTextComplete("(Press F1 to cycle through demos)", new Vector2(40, 75), Color.White, Matrix.Identity);
            render.RenderTextComplete("(Press Escape to exit)", new Vector2(40, 95), Color.White, Matrix.Identity);
            render.RenderTextComplete("All Demos uses Bepu Physic Engine, For Nvidia Physx See Advanced Demos", new Vector2(40, 115), Color.White, Matrix.Identity);           

        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:11,代码来源:DemosHomeScreen.cs

示例11: Draw

 protected override void Draw(Microsoft.Xna.Framework.GameTime gameTime, RenderHelper render)
 {
     render.Clear(Color.Black);
     render.RenderTextureComplete(tex,Color.White,GraphicInfo.FullScreenRectangle,Matrix.Identity);
 }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:5,代码来源:LoadingScreen.cs

示例12: Draw

            public override void Draw(Texture2D ImageToProcess, RenderHelper rHelper, GameTime gt, PloobsEngine.Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatBuffer)
            {

                Matrix v = world.CameraManager.ActiveCamera.View;
                Matrix p = world.CameraManager.ActiveCamera.Projection;

                rHelper.PushRenderTarget(depthrender);
                rHelper.Clear(Color.Black);
                rHelper.RenderSceneWithCustomMaterial(renderdepth,
                    (effect, obj, bi, ti, s, er, wvp) =>
                    {
                        Matrix w1 = Matrix.Multiply(obj.WorldMatrix, bi.ModelLocalTransformation);
                        effect.Parameters["wvp"].SetValue(w1 * wvp);
                        effect.Parameters["WorldView"].SetValue(w1 * v);
                        effect.Parameters["farPlane"].SetValue(world.CameraManager.ActiveCamera.FarPlane);

                    }, world, gt, null, ref v, ref p, false, true);

                Texture2D depth = rHelper.PopRenderTargetAsSingleRenderTarget2D();


                // Set shader atributes
                //SetNormalTexture(rHelper[PrincipalConstants.normalRt]);
                //shader.Parameters["depthTexture"].SetValue(rHelper[PrincipalConstants.DephRT]);                
                shader.Parameters["depthTexture"].SetValue(depth);                
                //shader.Parameters["InvertViewProjection"].SetValue(Matrix.Invert(world.CameraManager.ActiveCamera.Projection));
                
                NumberSteps = 8;
                NumberDirections = 12;
                Radius = 10f;
                LineAttenuation = 0.75f;
                Contrast = 1.0f;
                AngleBias = 0.00218166653f;
                LineAttenuation = 0.75f;
                
                // It works a the depth texture resolution. Use a downsampled version of the G-Buffer.
                SetResolution(new Vector2(GraphicInfo.BackBufferWidth, GraphicInfo.BackBufferHeight));
                SetInverseResolution(new Vector2(1f / (float)GraphicInfo.BackBufferWidth, 1f / (float)GraphicInfo.BackBufferHeight));
                SetNumberSteps(8);
                SetNumberDirections(12);
                SetContrast(Contrast  / (1.0f - (float)Math.Sin(AngleBias)));
                SetLineAttenuation(LineAttenuation);
                SetRadius(Radius  );
                SetAngleBias(AngleBias);
                SetHalfPixel(GraphicInfo.HalfPixel);

                float _tanFovy = (float)Math.Tan(world.CameraManager.ActiveCamera.FieldOfView / 2);
                Vector2 focalLen = new Vector2
                {
                    X = world.CameraManager.ActiveCamera.AspectRatio / _tanFovy,
                    Y = 1.0f / _tanFovy
                };               
                
                //pointLightEffect.Parameters["farPlane"].SetValue(camera.FarPlane);

                SetFocalLength(focalLen);
                SetInverseFocalLength(new Vector2(_tanFovy * world.CameraManager.ActiveCamera.AspectRatio, -_tanFovy));

                SetSquareRadius(AngleBias * AngleBias);
                SetInverseRadius(1f / AngleBias);
                SetTanAngleBias((float)Math.Tan(AngleBias));                
                
                //rHelper.PushRenderTarget(RenderTarget2D);
                rHelper.SetSamplerStates(SamplerState.PointWrap);
                rHelper.Clear(Color.White);
                rHelper.RenderFullScreenQuadVertexPixel(shader, SamplerState.PointWrap);
                return;

                Texture2D t = rHelper.PopRenderTargetAsSingleRenderTarget2D();
                               
                //rHelper.PushRenderTarget(RenderTarget2D2);
                //rHelper.Clear(Color.Black);
                //g.Draw(t, rHelper, gt, GraphicInfo, world, useFloatBuffer);
                //t = rHelper.PopRenderTargetAsSingleRenderTarget2D();
                
                ssaofinal.Parameters["SSAOTex"].SetValue(t);
                ssaofinal.Parameters["SceneTexture"].SetValue(ImageToProcess);
                ssaofinal.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
                ssaofinal.Parameters["weight"].SetValue(1);
                rHelper.SetSamplerStates(SamplerState.PointClamp);
                if (useFloatBuffer)
                    rHelper.RenderFullScreenQuadVertexPixel(ssaofinal, SamplerState.PointClamp);
                else
                    rHelper.RenderFullScreenQuadVertexPixel(ssaofinal, GraphicInfo.SamplerState);              

            }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:86,代码来源:HBAOPostEffect.cs

示例13: BeginDrawingShadowCasters

 internal void BeginDrawingShadowCasters(RenderHelper render)
 {
     render.PushRenderTarget(RenderTarget);
     render.Clear(Color.Transparent,ClearOptions.Target);
 }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:5,代码来源:Light2D.cs

示例14: DrawScene

        public void DrawScene(GameTime gameTime, IWorld world, RenderHelper render, GraphicInfo ginfo, List<IObject> objs)
        {
            Matrix v = world.CameraManager.ActiveCamera.View;
            Matrix p = world.CameraManager.ActiveCamera.Projection;
                    
            render.PushRenderTarget(colorRT, normalRT, depthRT, lightOclusionRT);
            
            render.RenderPreComponents(gameTime, ref v, ref p);
            System.Diagnostics.Debug.Assert(render.PeekBlendState() == BlendState.Opaque);
            System.Diagnostics.Debug.Assert(render.PeekDepthState() == DepthStencilState.Default);
            System.Diagnostics.Debug.Assert(render.PeekRasterizerState() == RasterizerState.CullCounterClockwise);
                        
            render.SetSamplerState(ginfo.SamplerState, 0);

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

            render.PopRenderTarget();                

            colorRTFINAL = colorRT2;
            render.PushRenderTarget(colorRTFINAL);
            render.Clear(Color.CornflowerBlue);
            effect.Parameters["View"].SetValue(world.CameraManager.ActiveCamera.View);
            effect.Parameters["Projection"].SetValue(world.CameraManager.ActiveCamera.Projection);
            {

                foreach (IObject item in world.Culler.GetNotCulledObjectsList(MaterialType.DEFERRED))
                {                    
                    for (int i = 0; i < item.Modelo.MeshNumber; i++)
                    {
                        BatchInformation[] bi = item.Modelo.GetBatchInformation(i);
                        for (int j = 0; j < bi.Count(); j++)
                        {
                            effect.Parameters["Texture"].SetValue(item.Modelo.getTexture(TextureType.DIFFUSE,i,j));                    
                            effect.Parameters["World"].SetValue(bi[j].ModelLocalTransformation * item.WorldMatrix);
                            render.RenderBatch(bi[j], effect);
                        }
                    }
                }

            }
            render.PopRenderTarget();            

        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:46,代码来源:LightPrePassGBuffer.cs

示例15: Draw

        /// <summary>
        /// Draws the specified game time.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        /// <param name="world">The world.</param>
        /// <param name="render">The render.</param>
        protected void Draw(GameTime gameTime, IWorld world, RenderHelper render)
        {
            Matrix view = world.CameraManager.ActiveCamera.View;
            Matrix projection = world.CameraManager.ActiveCamera.Projection;

            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);

            if (desc.OrderAllObjectsBeforeDraw != null)
                AllnotCulledObjectsList = desc.OrderAllObjectsBeforeDraw(AllnotCulledObjectsList);

            if (desc.OrderDeferredObjectsBeforeDraw != null)
                DeferrednotCulledObjectsList = desc.OrderDeferredObjectsBeforeDraw(DeferrednotCulledObjectsList);

            if (desc.OrderForwardObjectsBeforeDraw != null)
                ForwardnotCulledObjectsList = desc.OrderForwardObjectsBeforeDraw(ForwardnotCulledObjectsList);

            render.SetSamplerStates(ginfo.SamplerState);
            render.DettachBindedTextures();

            deferredGBuffer.PreDrawScene(gameTime, world, render, ginfo, AllnotCulledObjectsList);

            render.SetSamplerStates(ginfo.SamplerState);
            render.DettachBindedTextures();

            deferredGBuffer.SetGBuffer(render);            
            deferredGBuffer.ClearGBuffer(render);
            deferredGBuffer.DrawScene(gameTime, world, render, ginfo, DeferrednotCulledObjectsList);
            deferredGBuffer.ResolveGBuffer(render);

            render[PrincipalConstants.DephRT] = deferredGBuffer[GBufferTypes.DEPH];
            render[PrincipalConstants.normalRt] = deferredGBuffer[GBufferTypes.NORMAL];

            render.DettachBindedTextures();
            render.ValidateSamplerStates();            

            deferredLightMap.SetLightMap(render);
            deferredLightMap.DrawLights(gameTime, world, deferredGBuffer, render);
            deferredLightMap.ResolveLightMap(render);
            render[PrincipalConstants.lightRt] = deferredLightMap[DeferredLightMapType.LIGHTMAP];

            render.DettachBindedTextures(5);
            render.ValidateSamplerStates();

            render.PushRenderTarget(scenerender);
            render.Clear(desc.BackGroundColor);
            foreach (IObject item in AllnotCulledObjectsList)
            {
                if (item.Material.IsVisible)
                    item.Material.PosDrawnPhase(gameTime, item, world.CameraManager.ActiveCamera, world.Lights, render);
            }

            render.DettachBindedTextures(3);
            render.ValidateSamplerStates();
                        
                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();
                    render.SetSamplerStates(ginfo.SamplerState);
                }

                render.DettachBindedTextures(6);
                render.ValidateSamplerStates();            
                
                render.RenderPosWithDepthComponents(gameTime, ref view, ref projection);

                render.DettachBindedTextures(6);
                render.ValidateSamplerStates();

                render[PrincipalConstants.colorRT] = scenerender;
                render[PrincipalConstants.normalRt] = deferredGBuffer[GBufferTypes.NORMAL];
                render[PrincipalConstants.lightRt] = deferredLightMap[DeferredLightMapType.LIGHTMAP];
                render[PrincipalConstants.DephRT] = deferredGBuffer[GBufferTypes.DEPH];
                render[PrincipalConstants.extra1RT] = deferredGBuffer[GBufferTypes.Extra1];
                render[PrincipalConstants.CurrentImage] = render[PrincipalConstants.CombinedImage] = 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;
                        render[PrincipalConstants.CurrentImage] = tex;
                        SwapTargetBuffers();
                    }
//.........这里部分代码省略.........
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:101,代码来源:PreRenderTechnic.cs


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