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


C# RenderHelper.PushRenderTarget方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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)
        {          
            //ssao
            rHelper.PushRenderTarget(RenderTarget2D);
            rHelper.Textures[0] = rHelper[PrincipalConstants.normalRt];
            SamplerState s0 = rHelper.SetSamplerState(SamplerState.LinearClamp, 0);

            rHelper.Textures[1] = rHelper[PrincipalConstants.DephRT];
            SamplerState s1 = rHelper.SetSamplerState(SamplerState.PointClamp, 1);

            rHelper.Textures[2] = tex;
            SamplerState s2 = rHelper.SetSamplerState(SamplerState.LinearWrap, 2);            

            Effect.CurrentTechnique = Effect.Techniques[0];
            Effect.Parameters["random_size"].SetValue(64);
            Effect.Parameters["g_screen_size"].SetValue(new Vector2(GraphicInfo.BackBufferWidth, GraphicInfo.BackBufferHeight));    
            Effect.Parameters["invertViewProj"].SetValue(Matrix.Invert(world.CameraManager.ActiveCamera.Projection));
            Effect.Parameters["View"].SetValue(world.CameraManager.ActiveCamera.View);
            Effect.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);

            //artist parameters
            Effect.Parameters["g_sample_rad"].SetValue(radius);
            Effect.Parameters["g_intensity"].SetValue(intensity);
            Effect.Parameters["g_scale"].SetValue(scale);
            Effect.Parameters["g_bias"].SetValue(bias);
            
            rHelper.RenderFullScreenQuadVertexPixel(Effect);         

            rHelper.PopRenderTarget();
            rHelper.SetSamplerState(s0, 0);
            rHelper.SetSamplerState(s1, 1);
            rHelper.SetSamplerState(s2, 2);

            //blur
            rHelper.PushRenderTarget(RenderTarget2D2);
            sBlurPost.Draw(RenderTarget2D, rHelper, gt, GraphicInfo, world, useFloatBuffer);
            rHelper.PopRenderTarget();            
            
            rHelper[PrincipalConstants.SSAORT] = RenderTarget2D2;

            //Mix
            Effect.CurrentTechnique = Effect.Techniques[1];
            Effect.Parameters["SSAOCombineIntensityity"].SetValue(SSAOCombineIntensityity);
            rHelper.Textures[0] = RenderTarget2D2;
            SamplerState s = useFloatBuffer == true ? SamplerState.PointClamp : SamplerState.LinearClamp;
            s1 = rHelper.SetSamplerState(s, 1);
            rHelper.Textures[1] = ImageToProcess;                        
            rHelper.RenderFullScreenQuadVertexPixel(Effect);
            rHelper.SetSamplerState(s1, 1);           

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

示例4: Draw

        public override void Draw(Texture2D ImageToProcess, RenderHelper rHelper, GameTime gt, Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatingBuffer)
        {
            if (changeColors)
            {
                rHelper.PushRenderTarget(target);                

                toon.Parameters["ColorMap"].SetValue(ImageToProcess);
                toon.Parameters["useLight"].SetValue(useLight);
                toon.Parameters["TexColor"].SetValue(rHelper[PrincipalConstants.colorRT]);
                toon.Parameters["CelMap"].SetValue(cell);
                toon.Parameters["LightMap"].SetValue(rHelper[PrincipalConstants.lightRt]);
                toon.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);
                if (useFloatingBuffer)
                    rHelper.RenderFullScreenQuadVertexPixel(toon, SamplerState.PointClamp);
                else
                    rHelper.RenderFullScreenQuadVertexPixel(toon, GraphicInfo.SamplerState);              

                ImageToProcess = rHelper.PopRenderTargetAsSingleRenderTarget2D();
            }

                line.Parameters["Thickness"].SetValue(1.0f);
                line.Parameters["Threshold"].SetValue(0.2f);                
                if (useFloatingBuffer)
                    rHelper.RenderTextureToFullScreenSpriteBatch(ImageToProcess, line, GraphicInfo.FullScreenRectangle, SamplerState.PointClamp);
            else
                    rHelper.RenderTextureToFullScreenSpriteBatch(ImageToProcess, line, GraphicInfo.FullScreenRectangle, GraphicInfo.SamplerState);
            
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:28,代码来源:ToonPostEffect.cs

示例5: DownColorTexture

 /// <summary>
 /// DownSample a Color Texture (using hardware Linear filtering, cant be used on Single/float Textures)
 /// </summary>
 /// <param name="render">The render.</param>
 /// <param name="Texture2D">The texture2 D.</param>
 /// <param name="SamplerState">State of the sampler.</param>
 /// <returns></returns>
 public Texture2D DownColorTexture(RenderHelper render, Texture2D Texture2D, SamplerState SamplerState)
 {
     render.PushRenderTarget(RenderTarget2D);
     render.RenderTextureComplete(Texture2D, Color.White,
         Rectangle, Matrix.Identity, Texture2D.Bounds,
         true, SpriteSortMode.Deferred, SamplerState);
     return render.PopRenderTargetAsSingleRenderTarget2D();
 }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:15,代码来源:DownSampler.cs

示例6: 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

示例7: DownShaderBilinearTexture

        /// <summary>
        /// DownSample a texture using bilinear filtering implemented in Shader.
        /// </summary>
        /// <param name="render">The render.</param>
        /// <param name="Texture2D">The texture2 D.</param>
        /// <returns></returns>
        public Texture2D DownShaderBilinearTexture(RenderHelper render, Texture2D Texture2D)
        {
            effect.CurrentTechnique = effect.Techniques[1];
            effect.Parameters["PixelSize"].SetValue(new Vector2(1f / Texture2D.Width, 1f / Texture2D.Height));
            effect.Parameters["HalfPixel"].SetValue(new Vector2(0.5f / Rectangle.Width, 0.5f / Rectangle.Height));
            render.Textures[0] = Texture2D;
            SamplerState s0 = render.SetSamplerState(SamplerState.PointClamp, 0);

            render.PushRenderTarget(RenderTarget2D);
            render.RenderFullScreenQuadVertexPixel(effect);
            render.SetSamplerState(s0, 0);
            return render.PopRenderTargetAsSingleRenderTarget2D();
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:19,代码来源:DownSampler.cs

示例8: DownScale

 private Texture2D DownScale(RenderHelper rHelper, Texture2D input, RenderTarget2D downscaleTarget, String technichName, bool useFloatingBuffer)
 {            
     effect.CurrentTechnique = effect.Techniques[technichName];
     effect.Parameters["SourceTexture0"].SetValue(input);
     effect.Parameters["g_vSourceDimensions"].SetValue(new Vector2(input.Width, input.Height));
     effect.Parameters["g_vDestinationDimensions"].SetValue(new Vector2(downscaleTarget.Width, downscaleTarget.Height));
     rHelper.PushRenderTarget(downscaleTarget);            
     if (useFloatingBuffer)
         rHelper.RenderFullScreenQuadVertexPixel(effect, SamplerState.PointClamp);
     else
         rHelper.RenderFullScreenQuadVertexPixel(effect, SamplerState.LinearClamp);
     return rHelper.PopRenderTargetAsSingleRenderTarget2D();            
 }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:13,代码来源:HdrPostEffect.cs

示例9: Draw

        public override void Draw(Texture2D ImageToProcess, RenderHelper rHelper, GameTime gt, Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatingBuffer)
        {         
             rHelper.PushRenderTarget(target);
             gbp.Draw(rHelper[PrincipalConstants.extra1RT], rHelper,  gt, GraphicInfo, world,false);
             x = rHelper.PopRenderTargetAsSingleRenderTarget2D();

             if (doubleBlur)
             {
                 rHelper.PushRenderTarget(target2);
                 gbp.Draw(x, rHelper, gt, GraphicInfo, world, false);
                 x = rHelper.PopRenderTargetAsSingleRenderTarget2D();
             }

             effect.Parameters["intensity"].SetValue(intensity);
             effect.Parameters["glowMapBlurried"].SetValue(x);
             effect.Parameters["colorMap"].SetValue(ImageToProcess);
             effect.Parameters["halfPixel"].SetValue(GraphicInfo.HalfPixel);

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

示例10: 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

示例11: PerformForwardPass

        /// <summary>
        /// Performs the forward pass.
        /// </summary>
        /// <param name="combined">The combined.</param>
        /// <param name="depth">The depth.</param>
        /// <param name="render">The render.</param>
        /// <param name="ginfo">The ginfo.</param>
        public void PerformForwardPass(Texture2D combined, Texture2D depth, RenderHelper render,GraphicInfo ginfo)
        {
            render.PushRenderTarget(target);
            render.device.Textures[0] = combined;
            render.device.Textures[1] = depth;
            SamplerState s1 = render.SetSamplerState(SamplerState.PointClamp, 1);

            //Depth.SetValue(depth);                
            //Color.SetValue(combined);
            SamplerState s0;
            if (usefloatBuffer)
            {
                s0 = render.SetSamplerState(SamplerState.PointClamp, 0);                
            }
            else
            {
                s0 = render.SetSamplerState(ginfo.SamplerState, 0);
            }
            render.RenderFullScreenQuadVertexPixel(restore);
            
            render.SetSamplerState(s1, 1);
            render.SetSamplerState(s0, 0);
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:30,代码来源:RestoreDepth.cs

示例12: 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

示例13: 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

示例14: SetGBuffer

 public void SetGBuffer(RenderHelper render)
 {
     render.PushRenderTarget(normalRT, depthRT);            
 }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:4,代码来源:PreGBuffer.cs

示例15: 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


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