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


C# RenderHelper.SetSamplerStates方法代码示例

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


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

示例1: DrawLights

        public void DrawLights(GameTime gameTime, IWorld world, IDeferredGBuffer deferredGBuffer, RenderHelper render)
        {
            render.Clear(Color.Transparent, ClearOptions.Target);

            foreach (ILight light in world.Lights.Where((a) => a.CastShadown == true && a.Enabled == true))
            {
                switch (light.LightType)
                {
                    case LightType.Deferred_Directional:
                        DirectionalLightPE dl = light as DirectionalLightPE;
                        shadowMap = shadow.Render(gameTime, render, ginfo, dl, world.CameraManager.ActiveCamera, world, deferredGBuffer);

                        render.PushBlendState(_lightAddBlendState);
                        DrawDirectionalLight(render, ginfo, world.CameraManager.ActiveCamera, dl, deferredGBuffer);
                        render.PopBlendState();

                        break;
                    case LightType.Deferred_Point:
#if WINDOWS
                        System.Diagnostics.Debug.Fail("Point Light Shadow not supported, in production no error will be created, the light just wont cast any shadow");
#endif
                        render.PushBlendState(_lightAddBlendState);
                        DrawPointLight(render, ginfo, world.CameraManager.ActiveCamera, light as PointLightPE, deferredGBuffer, true);
                        render.PopBlendState();
                        break;
                    case LightType.Deferred_Spot:
                        SpotLightPE sl = light as SpotLightPE;
                        Matrix v = sl.ViewMatrix;
                        Matrix p =sl.ProjMatrix;
                        RenderShadowMap(gameTime, render, ref v, ref p, world, deferredGBuffer);
                        render.PushBlendState(_lightAddBlendState);
                        DrawnSpotLight(render, ginfo, world.CameraManager.ActiveCamera, sl, deferredGBuffer);
                        render.PopBlendState();
                        break;
                    default:
                        throw new Exception("Light type Unexpected");
                }
            }

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

            render.PushBlendState(_lightAddBlendState);

            foreach (ILight light in world.Lights.Where((a) => a.CastShadown != true && a.Enabled == true))
            {
                switch (light.LightType)
                {
                    case LightType.Deferred_Directional:
                        DirectionalLightPE dl = light as DirectionalLightPE;                        
                        DrawDirectionalLight(render,ginfo, world.CameraManager.ActiveCamera, dl, deferredGBuffer);
                        break;
                    case LightType.Deferred_Point:                        
                        DrawPointLight(render,ginfo, world.CameraManager.ActiveCamera, light as PointLightPE, deferredGBuffer,true);
                        break;
                    case LightType.Deferred_Spot:
                        SpotLightPE sl = light as SpotLightPE;                        
                        DrawnSpotLight(render,ginfo, world.CameraManager.ActiveCamera, sl, deferredGBuffer);
                        break;
                    default:
                        throw new Exception("Light type Unexpected");
                }
            }      
                  
            render.PopBlendState();            
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:66,代码来源:ShadowLightMap.cs

示例2: Draw

        protected override void Draw(GameTime gt, IObject obj, RenderHelper render, ICamera cam, IList<Light.ILight> lights)        
 	    {
            AnimatedModel modelo = obj.Modelo as AnimatedModel;

            for (int i = 0; i < modelo.GetAnimatedModel().Meshes.Count; i++)
            {
                ModelMesh modelMesh = modelo.GetAnimatedModel().Meshes[i];
                for (int j = 0; j < modelMesh.MeshParts.Count; j++)
                {
                    SkinnedModelBasicEffect basicEffect = (SkinnedModelBasicEffect)modelMesh.MeshParts[j].Effect;                    
                    basicEffect.DiffuseMapEnabled = true;
                    basicEffect.CurrentTechnique = basicEffect.Techniques["DEFERRED"];
                    basicEffect.Parameters["diffuseMap0"].SetValue(modelo.getTexture(TextureType.DIFFUSE,i,j));
                    basicEffect.Parameters["diffuseMapEnabled"].SetValue(true);
                    if (followBone)
                    {
                        basicEffect.World = Followed.GetBoneAbsoluteTransform(boneName) * Followobj.WorldMatrix;
                        basicEffect.Bones = modelo.getBonesTransformation();
                    }
                    else
                    {
                        basicEffect.World = WorldMatrix;
                        basicEffect.Bones = ac.GetBoneTransformations();
                    }
                    basicEffect.View = cam.View;
                    basicEffect.Projection = cam.Projection;
                }

                modelMesh.Draw();
            }
            render.SetSamplerStates(ginfo.SamplerState);
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:32,代码来源:DeferredSimpleAnimationShader.cs

示例3: DrawScene

        public void DrawScene(GameTime gameTime, IWorld world, RenderHelper render, GraphicInfo ginfo, List<IObject> objectsToDraw)
        {
            render.ValidateSamplerStates();

            Matrix view = world.CameraManager.ActiveCamera.View;
            Matrix projection = world.CameraManager.ActiveCamera.Projection;

            if (render.RenderPreComponents(gameTime, ref view, ref projection) > 0)
            {
                render.SetSamplerStates(ginfo.SamplerState);                
            }

            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.DettachBindedTextures(5);

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

            render.ValidateSamplerStates();                 

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

示例4: DepthExtractor

        public override void DepthExtractor(GameTime gt, IObject obj, ref Matrix View, ref Matrix projection, RenderHelper render)
        {
            AnimatedModel modelo = obj.Modelo as AnimatedModel;
            foreach (ModelMesh modelMesh in modelo.GetAnimatedModel().Meshes)
            {
                foreach (ModelMeshPart meshPart in modelMesh.MeshParts)
                {                    
                    SkinnedModelBasicEffect basicEffect = (SkinnedModelBasicEffect)meshPart.Effect;                    
                    basicEffect.CurrentTechnique = basicEffect.Techniques["DEPTH"];                    
                    if (followBone)
                    {
                        basicEffect.World = Followed.GetBoneAbsoluteTransform(boneName) * Followobj.WorldMatrix;
                        basicEffect.Bones = modelo.getBonesTransformation();
                    }
                    else
                    {
                        basicEffect.World = WorldMatrix;
                        basicEffect.Bones = ac.GetBoneTransformations();
                    }
                    basicEffect.View = View;
                    basicEffect.Projection = projection;
                }

                modelMesh.Draw();
            }
            render.SetSamplerStates(ginfo.SamplerState);
            
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:28,代码来源:DeferredSimpleAnimationShader.cs

示例5: BasicDraw

        public override void BasicDraw(GameTime gt, IObject obj, ref Matrix view, ref Matrix projection, IList<Light.ILight> lights, RenderHelper render, Plane? clippingPlane, bool useAlphaBlending = false)
        {
            AnimatedModel modelo = obj.Modelo as AnimatedModel;

            for (int i = 0; i < modelo.GetAnimatedModel().Meshes.Count; i++)
            {
                ModelMesh modelMesh = modelo.GetAnimatedModel().Meshes[i];
                for (int j = 0; j < modelMesh.MeshParts.Count; j++)
                {
                    SkinnedModelBasicEffect basicEffect = (SkinnedModelBasicEffect)modelMesh.MeshParts[j].Effect;
                    if (clippingPlane != null)
                    {
                        basicEffect.Parameters["clipenabled"].SetValue(true);
                        basicEffect.Parameters["plane"].SetValue(new Vector4(clippingPlane.Value.Normal,clippingPlane.Value.D));
                    }
                    else
                    {
                        basicEffect.Parameters["clipenabled"].SetValue(false);
                    }
                    basicEffect.DiffuseMapEnabled = true;
                    basicEffect.CurrentTechnique = basicEffect.Techniques["FORWARDCLIP"];
                    basicEffect.Parameters["diffuseMap0"].SetValue(modelo.getTexture(TextureType.DIFFUSE,i,j));
                    basicEffect.Parameters["diffuseMapEnabled"].SetValue(true);
                    if (followBone)
                    {
                        basicEffect.World = Followed.GetBoneAbsoluteTransform(boneName) * Followobj.WorldMatrix;
                        basicEffect.Bones = modelo.getBonesTransformation();
                    }
                    else
                    {
                        basicEffect.World = WorldMatrix;
                        basicEffect.Bones = ac.GetBoneTransformations();
                    }
                    basicEffect.View = view;
                    basicEffect.Projection = projection;
                }

                modelMesh.Draw();
            }
            render.SetSamplerStates(ginfo.SamplerState);
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:41,代码来源:DeferredSimpleAnimationShader.cs

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

示例7: BasicDraw

        public override void BasicDraw(GameTime gt, IObject obj, ref Matrix view, ref Matrix projection, IList<Light.ILight> lights, RenderHelper render, Plane? clippingPlane, bool useAlphaBlending = false)
        {
            isupdated = false;
            Matrix x = Matrix.Invert(view);
            Vector3 camPos = new Vector3(x.M41, x.M42, x.M43);
            QuadTerrain.UpdateTerrain(camPos, new BoundingFrustum(view * projection), LOD);

            WorldMatrix.SetValue(obj.PhysicObject.WorldMatrix);
            ViewMatrix.SetValue(view);
            ProjectionMatrix.SetValue(projection);

            TerrainShader.CurrentTechnique = TerrainShader.Techniques["Technique1"];
            TerrainShader.CurrentTechnique.Passes[0].Apply();
            QuadTerrain.DrawTerrain(TerrainShader, render.device);
            render.SetSamplerStates(ginfo.SamplerState, 8);
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:16,代码来源:DeferredTerrainMaterial.cs

示例8: Draw

        protected override void Draw(GameTime gt, IObject obj, RenderHelper render, ICamera cam, IList<ILight> lights)
        {
                System.Diagnostics.Debug.Assert(obj.Modelo is TerrainModel, "This shader expects a TerrainModel");
                this._shader.Parameters["id"].SetValue(shaderId);                
                this._shader.Parameters["BaseTexture"].SetValue(obj.Modelo.getTexture(TextureType.MULTITEX1,0,0));
                this._shader.Parameters["blendDistance"].SetValue(blendDistance);
                this._shader.Parameters["blendWidth"].SetValue(blendWidth);
                this._shader.Parameters["nearTextureEspalhamento"].SetValue(nearTextureEspalhamento);
                this._shader.Parameters["farTextureEspalhamento"].SetValue(farTextureEspalhamento);
                Matrix World = obj.WorldMatrix;
                this._shader.Parameters["World"].SetValue(World);

                if (terrainType == TerrainType.MULTITEXTURE)
                {
                    this._shader.Parameters["NivelAlto"].SetValue(obj.Modelo.getTexture(TextureType.MULTITEX4, 0, 0));
                    this._shader.Parameters["NivelMedio"].SetValue(obj.Modelo.getTexture(TextureType.MULTITEX3, 0, 0));
                    this._shader.Parameters["NivelBaixo"].SetValue(obj.Modelo.getTexture(TextureType.MULTITEX2, 0, 0));

                    this._shader.Parameters["nivelBaixoAltura"].SetValue(nivelBaixoAltura);
                    this._shader.Parameters["nivelBaixoEspalhamento"].SetValue(nivelBaixoEspalhamento);
                    this._shader.Parameters["nivelMedioAltura"].SetValue(nivelMedioAltura);
                    this._shader.Parameters["nivelMedioEspalhamento"].SetValue(nivelMedioEspalhamento);
                    this._shader.Parameters["nivelAltoAltura"].SetValue(nivelAltoAltura);
                    this._shader.Parameters["nivelAltoEspalhamento"].SetValue(nivelAltoEspalhamento);
                    this._shader.Parameters["nivelBaseAltura"].SetValue(nivelBaseAltura);
                    this._shader.Parameters["nivelBaseEspalhamento"].SetValue(nivelBaseEspalhamento);
                }
                
                this._shader.Parameters["ViewProjection"].SetValue(cam.ViewProjection);
                BatchInformation batchInfo = obj.Modelo.GetBatchInformation(0)[0];

                render.SetSamplerStates(SamplerState.LinearWrap,6);

                //render.PushRasterizerState(RasterizerState.CullNone);
                render.RenderBatch(batchInfo, this._shader);
                //render.PopRasterizerState();

                render.SetSamplerStates(ginfo.SamplerState,6);
      }       
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:39,代码来源:DeferredTerrainShader.cs

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

示例10: 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, CullerComparer.ComparerFrontToBack,world.CameraManager.ActiveCamera.Position);
            List<IObject> ForwardnotCulledObjectsList = world.Culler.GetNotCulledObjectsList(MaterialType.FORWARD, CullerComparer.ComparerBackToFront, world.CameraManager.ActiveCamera.Position);

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

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

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

            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.DettachBindedTextures();
            render.ValidateSamplerStates();            

            deferredLightMap.SetLightMap(render);
            deferredLightMap.DrawLights(gameTime, world, deferredGBuffer, render);
            deferredLightMap.ResolveLightMap(render);

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

            deferredFinalCombination.SetFinalCombination(render);
            deferredFinalCombination.DrawScene(gameTime, world, deferredGBuffer, deferredLightMap,render);

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

            if (desc.ExtraForwardPass)
            {
                render[PrincipalConstants.colorRT] = deferredGBuffer[GBufferTypes.COLOR];
                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.CombinedImage] = deferredFinalCombination[GBufferTypes.FINALIMAGE];
                render[PrincipalConstants.CurrentImage] = deferredFinalCombination[GBufferTypes.FINALIMAGE];

                if (desc.RestoreDepthOption == RestoreDepthOption.BEFORE_POSTEFFECT)
                {
                    restoreDepth.PerformForwardPass(render[PrincipalConstants.CombinedImage], render[PrincipalConstants.DephRT], render,ginfo);

                    render.DettachBindedTextures(2);
                    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();

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

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

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

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

                    render[PrincipalConstants.CurrentImage] = restoreDepth.EndForwardPass(render);
                    render[PrincipalConstants.CombinedImage] = render[PrincipalConstants.CurrentImage];

                    for (int i = 0; i < PostEffects.Count; i++)
//.........这里部分代码省略.........
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:101,代码来源:DeferredRenderTechnic.cs


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