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


C# RenderHelper.RenderSceneWithCustomMaterial方法代码示例

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


在下文中一共展示了RenderHelper.RenderSceneWithCustomMaterial方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
        {
            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

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