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


C# RenderHelper.RenderBatch方法代码示例

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


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

示例1: Draw

        /// <summary>
        /// Draw
        /// </summary>
        /// <param name="gt">gametime</param>
        /// <param name="obj">the obj</param>
        /// <param name="render">The render.</param>
        /// <param name="cam">The cam.</param>
        /// <param name="lights"></param>
        protected override void Draw(GameTime gt, IObject obj, RenderHelper render, Cameras.ICamera cam, IList<Light.ILight> lights)
        {
            base.Draw(gt, obj, render, cam, lights);
            
            effect.View = cam.View;
            effect.Projection = cam.Projection;

            for (int i = 0; i < obj.Modelo.MeshNumber; i++)
            {
                BatchInformation[] bi = obj.Modelo.GetBatchInformation(i);
                for (int j = 0; j < bi.Count(); j++)
                {
                    effect.Texture = obj.Modelo.getTexture(Modelo.TextureType.DIFFUSE,i,j);
                    effect.Texture2 = obj.Modelo.getTexture(Modelo.TextureType.MULTITEX1, i, j);
                    effect.World = bi[j].ModelLocalTransformation * obj.WorldMatrix;
                    render.RenderBatch(bi[j],effect);
                }
            }
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:27,代码来源:ForwardDualTextureShader.cs

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

示例3: Draw

        protected override void Draw(GameTime gt, IObject obj, RenderHelper render, PloobsEngine.Cameras.ICamera cam, IList<PloobsEngine.Light.ILight> lights)
        {
            //render.PushRenderTarget(rt);

            Effect.Parameters["lightMapping"].SetValue(true);
            Effect.Parameters["projection"].SetValue(cam.Projection);
            Effect.Parameters["view"].SetValue(cam.View);

            for (int i = 0; i < obj.Modelo.MeshNumber; i++)
            {
                BatchInformation[] bi = obj.Modelo.GetBatchInformation(i);
                for (int j = 0; j < bi.Count(); j++)
                {
                    Effect.Parameters["diffuse"].SetValue(obj.Modelo.getTexture(PloobsEngine.Modelo.TextureType.DIFFUSE, i, j));
                    Effect.Parameters["uvcorrection"].SetValue(new Vector2(1,1));
                    Effect.Parameters["world"].SetValue(bi[j].ModelLocalTransformation * obj.WorldMatrix); 
                    render.RenderBatch(bi[j], Effect);
                }
            }

            //render.PopRenderTarget();
            //rt.SaveAsPng(...)
            
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:24,代码来源:BakerShader.cs

示例4: Draw

        protected override void Draw(GameTime gt, IObject obj, RenderHelper render, ICamera cam, IList<ILight> lights)
        {
            _shader.Parameters["amplitude"].SetValue(amplitude);
            _shader.Parameters["gTime"].SetValue((float)gt.TotalGameTime.TotalMilliseconds);
            _shader.Parameters["timeScale"].SetValue(movimentSpeedControl);
            _shader.Parameters["xCamPos"].SetValue(cam.Position);
 	        _shader.Parameters["scaleX"].SetValue(scale.X);
            _shader.Parameters["scaleY"].SetValue(scale.Y);
            _shader.Parameters["xWorld"].SetValue(obj.PhysicObject.WorldMatrix);
            _shader.Parameters["xView"].SetValue(cam.View);
            _shader.Parameters["xProjection"].SetValue(cam.Projection);                        
            //_shader.Parameters["xBillboardTexture"].SetValue(obj.Modelo.getTexture(TextureType.DIFFUSE,0,0));
            render.Textures[0] = obj.Modelo.getTexture(TextureType.DIFFUSE, 0, 0);


            _shader.Parameters["atenuation"].SetValue(atenuation);
            _shader.Parameters["xAllowedRotDir"].SetValue(allowRotDir);

            render.PushRasterizerState(RasterizerState.CullNone);

            BatchInformation batchInfo = obj.Modelo.GetBatchInformation(0)[0];
            {
                _shader.Parameters["alphaTest"].SetValue(alphaTestLimit);
                render.RenderBatch(batchInfo, _shader);
            }

            render.PopRasterizerState();
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:28,代码来源:DeferredProceduralAnimatedBilboardShader.cs

示例5: DepthExtractor

        /// <summary>
        /// Exctract the depth from an object
        /// </summary>
        /// <param name="gt">The gt.</param>
        /// <param name="obj">The obj.</param>
        /// <param name="View">The view.</param>
        /// <param name="projection">The projection.</param>
        /// <param name="render">The render.</param>
        public virtual void DepthExtractor(GameTime gt, IObject obj, ref Matrix View, ref Matrix projection, RenderHelper render)
        {
            Matrix wld = obj.WorldMatrix;            
            for (int i = 0; i < obj.Modelo.MeshNumber; i++)
            {
                BatchInformation[] bi = obj.Modelo.GetBatchInformation(i);
                for (int j = 0; j < bi.Count(); j++)
                {
                    Matrix w1 = Matrix.Multiply(wld, bi[j].ModelLocalTransformation);
                    this.getDepth.Parameters["WVP"].SetValue(w1 * View * projection);

                    render.RenderBatch(bi[j], getDepth);
                }
            }
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:23,代码来源:IShader.cs

示例6: PreDraw

        protected override void PreDraw(RenderHelper render,GameTime gt, ref Matrix activeView, ref Matrix activeProjection)
        {
            if (!enable)
                return;

 	        base.PreDraw(render,gt, ref activeView, ref activeProjection);
            
            Matrix x = Matrix.Invert(activeView);
            Vector3 camPos = new Vector3(x.M41, x.M42, x.M43);
            
            effect.CurrentTechnique = effect.Techniques["RenderScene"];
            effect.Parameters["WorldViewProjection"].SetValue(Matrix.CreateTranslation(camPos) * activeView * activeProjection);
            //effect.Parameters["textureDiffuse"].SetValue(texture);
            render.device.Textures[0] = texture;            

            render.PushDepthStencilState(DepthStencilState.None);
            render.PushRasterizerState(RasterizerState.CullNone);

            render.RenderBatch(bi, effect);

            render.PopRasterizerState();
            render.PopDepthStencilState();

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

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

示例8: Draw

        protected override void Draw(GameTime gt, IObject obj, RenderHelper render, ICamera camera, IList<Light.ILight> lights)
        {
                float time = (float) gt.TotalGameTime.TotalMilliseconds / timeModulation;

                this._shader.Parameters["specularIntensity"].SetValue(specularIntensity);
                this._shader.Parameters["specularPower"].SetValue(specularPower);
                this._shader.Parameters["View"].SetValue(camera.View);
                this._shader.Parameters["camPos"].SetValue(camera.Position);
                this._shader.Parameters["ReflectionView"].SetValue(reflectiveViewMatrix);
                this._shader.Parameters["RefractionView"].SetValue(camera.View);

                //this._shader.Parameters["ReflectionMap"].SetValue(reflectionMap);
                //this._shader.Parameters["RefractionMap"].SetValue(refractionMap);
                //this._shader.Parameters["normalMap0"].SetValue(normal0);
                //this._shader.Parameters["normalMap1"].SetValue(normal1);
                render.Textures[0] = refractionMap;
                render.Textures[1] = reflectionMap;
                render.Textures[2] = normal0;
                render.Textures[3] = normal1;


                this._shader.Parameters["xWaveLength"].SetValue(waveLength);
                this._shader.Parameters["xWaveHeight"].SetValue(waveHeight);
                this._shader.Parameters["Time"].SetValue(time);
                this._shader.Parameters["WindForce"].SetValue(windForce);
                this._shader.Parameters["waterColor"].SetValue(waterColor);
                this._shader.Parameters["WindDirection"].SetValue(windDirection);
                this._shader.Parameters["Projection"].SetValue(camera.Projection);
                this._shader.Parameters["id"].SetValue(shaderId);

                render.PushRasterizerState(RasterizerState.CullNone);

                SamplerState s0 = render.SetSamplerState(SamplerState.LinearWrap, 0);
                SamplerState s1 = render.SetSamplerState(SamplerState.LinearWrap, 1);

                SamplerState s2 = render.SetSamplerState(SamplerState.LinearWrap, 2);
                SamplerState s3 = render.SetSamplerState(SamplerState.LinearWrap, 3);
                
                Matrix wld = obj.WorldMatrix;
                for (int i = 0; i < obj.Modelo.MeshNumber; i++)
                {
                    BatchInformation[] bi = obj.Modelo.GetBatchInformation(i);                    
                    
                    for (int j = 0; j < bi.Count(); j++)
                    {
                        Matrix w1 = Matrix.Multiply(wld, bi[j].ModelLocalTransformation);
                        this._shader.Parameters["World"].SetValue(w1);
                        render.RenderBatch(bi[j], _shader);
                    }
                }
                render.PopRasterizerState();

                render.SetSamplerState(s0, 0);
                render.SetSamplerState(s1, 1);
                render.SetSamplerState(s2, 2);
                render.SetSamplerState(s3, 3);
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:57,代码来源:DeferredWaterCompleteShader.cs

示例9: Draw

        protected override void Draw(GameTime gt, IObject obj, RenderHelper render, ICamera cam, IList<Light.ILight> lights)
        {
            
            Matrix World = obj.WorldMatrix;

            Matrix WVP = World * cam.ViewProjection;
            Matrix WV = World * cam.View;
            Matrix viewI = Matrix.Invert(cam.View);

            render.SetSamplerState(SamplerState.LinearWrap, 0);
            
            effect.Parameters["matWorldViewProj"].SetValue(WVP);
            effect.Parameters["matWorld"].SetValue(World);
            effect.Parameters["matWorldView"].SetValue(WV);
            effect.Parameters["matViewI"].SetValue(viewI);
            effect.Parameters["id"].SetValue(shaderId);
            effect.Parameters["fBumpHeight"].SetValue(bumpHeight);
            effect.Parameters["vTextureScale"].SetValue(textureScale);
            effect.Parameters["vBumpSpeed"].SetValue(bumpSpeed);
            effect.Parameters["fFresnelBias"].SetValue(fresnelBias);
            effect.Parameters["fFresnelPower"].SetValue(fresnelPower);
            effect.Parameters["fHDRMultiplier"].SetValue(hdrMultiplier);
            effect.Parameters["vDeepColor"].SetValue(deepWaterColor.ToVector4());
            effect.Parameters["vShallowColor"].SetValue(shallowWaterColor.ToVector4());
            effect.Parameters["vReflectionColor"].SetValue(reflectionColor.ToVector4());
            effect.Parameters["fReflectionAmount"].SetValue(reflectionAmount);
            effect.Parameters["fWaterAmount"].SetValue(waterAmount);
            effect.Parameters["fWaveAmp"].SetValue(waveAmplitude);
            effect.Parameters["fWaveFreq"].SetValue(waveFrequency);
            effect.Parameters["fTime"].SetValue((float)gt.TotalGameTime.TotalSeconds);
            effect.Parameters["fTimeM"].SetValue((float)gt.TotalGameTime.TotalSeconds % 100);

            render.Textures[0] = normal;
            render.Textures[1] = environmentTexture;
            
            BatchInformation[] bi = obj.Modelo.GetBatchInformation(0);                
            render.RenderBatch(bi[0], effect);                            

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

示例10: Draw

        /// <summary>
        /// Draw
        /// </summary>
        /// <param name="gt"></param>
        /// <param name="obj"></param>
        /// <param name="render">The render.</param>
        /// <param name="cam">The cam.</param>
        /// <param name="lights"></param>
        protected override void  Draw(GameTime gt, IObject obj, RenderHelper render, ICamera cam, IList<Light.ILight> lights)
        {
               this._shader.Parameters["TranslationAmount"].SetValue(translationRate * time);
               this._shader.Parameters["RotationAmount"].SetValue(rotationRate * time);
               this._shader.Parameters["time"].SetValue(time);                        
               this._shader.Parameters["id"].SetValue(shaderId);
               this._shader.Parameters["useParalax"].SetValue(useParalax);
               this._shader.Parameters["useGlow"].SetValue(useGlow);
               this._shader.Parameters["useBump"].SetValue(useBump);
               this._shader.Parameters["useSpecular"].SetValue(useSpecular);                                                   
               this._shader.Parameters["View"].SetValue(cam.View);
               this._shader.Parameters["Projection"].SetValue(cam.Projection);

                if(useParalax)
                    this._shader.Parameters["CameraPos"].SetValue(cam.Position);                               
                
                Matrix wld = obj.WorldMatrix;

                for (int i = 0; i < obj.Modelo.MeshNumber; i++)
                {
                    BatchInformation[] bi = obj.Modelo.GetBatchInformation(i);                    
                    for (int j = 0; j < bi.Count(); j++)
                    {
                        this._shader.Parameters["Texture"].SetValue(obj.Modelo.getTexture(TextureType.DIFFUSE,i,j));
                        if (useBump)
                        {
                            if (useParalax)
                            {
                                this._shader.Parameters["HeightMap"].SetValue(obj.Modelo.getTexture(TextureType.PARALAX,i,j));
                                this._shader.Parameters["scaleBias"].SetValue(scaleBias);
                            }

                            this._shader.Parameters["NormalMap"].SetValue(obj.Modelo.getTexture(TextureType.BUMP,i,j));

                        }
                        if (useSpecular)
                        {
                            this._shader.Parameters["SpecularMap"].SetValue(obj.Modelo.getTexture(TextureType.SPECULAR, i, j));
                        }
                        else
                        {
                            this._shader.Parameters["specularIntensity"].SetValue(specularIntensity);
                            this._shader.Parameters["specularPower"].SetValue(specularPower);
                            this._shader.Parameters["specularIntensityScale"].SetValue(SpecularIntensityMapScale);
                            this._shader.Parameters["specularPowerScale"].SetValue(SpecularPowerMapScale);
                        }

                        if (useGlow)
                            this._shader.Parameters["glow"].SetValue(obj.Modelo.getTexture(TextureType.GLOW, i, j));


                        Matrix w1 = Matrix.Multiply(bi[j].ModelLocalTransformation, wld);                    
                        this._shader.Parameters["World"].SetValue(w1);
                        this._shader.Parameters["WorldInverseTranspose"].SetValue(Matrix.Transpose(Matrix.Invert(w1)));
                        if (time != 0)
                            render.PushRasterizerState(RasterizerState.CullNone);

                        render.RenderBatch(bi[j],_shader);

                        if (time != 0)
                            render.PopRasterizerState();
                    }
                }               
            }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:72,代码来源:DeferredShatterCustomShader.cs

示例11: DrawPointLight

        protected void DrawPointLight(ICamera camera, IList<ILight> lights, IDeferredGBuffer DeferredGBuffer,RenderHelper render)
        {            
            render.Textures[1] = DeferredGBuffer[GBufferTypes.NORMAL];
            render.Textures[2] = DeferredGBuffer[GBufferTypes.DEPH];
            SamplerState s2 = render.SetSamplerState(SamplerState.PointClamp, 2);
            PointcameraPosition.SetValue(camera.Position);
            
            float _tanFovy = (float)Math.Tan(camera.FieldOfView /2);
            pointLightEffect.Parameters["TanAspect"].SetValue(new Vector2(_tanFovy * camera.AspectRatio, -_tanFovy));
            pointLightEffect.Parameters["farPlane"].SetValue(camera.FarPlane);
            
            foreach (ILight item in lights)
            {
                if (item.LightType == LightType.Deferred_Point && item.Enabled == true)
                {
                    PointLightPE pl = item as PointLightPE;
                    Matrix sphereWorldMatrix = Matrix.CreateScale(pl.LightRadius) * Matrix.CreateTranslation(pl.LightPosition);
                    
                    ContainmentType ct = ContainmentType.Contains;
                    if(cullPointLight)
                        ct = camera.BoundingFrustum.Contains(new BoundingSphere(pl.LightPosition, pl.LightRadius ));
                    if (ct == ContainmentType.Contains || ct == ContainmentType.Intersects)
                    {

                        //convert light position into viewspace
                        Vector3 viewSpaceLPos = Vector3.Transform(pl.LightPosition,camera.View);

                        PointWordViewProjection.SetValue(sphereWorldMatrix * camera.ViewProjection);
                        PointlightPosition.SetValue(viewSpaceLPos);
                        PointColor.SetValue(pl.Color.ToVector3());
                        PointlightRadius.SetValue(pl.LightRadius);
                        PointlightIntensity.SetValue(pl.LightIntensity);
                        Pointquadratic.SetValue(pl.UsePointLightQuadraticAttenuation);

                        float cameraToCenter = Vector3.Distance(camera.Position, pl.LightPosition);

                        if (cameraToCenter < pl.LightRadius + camera.NearPlane)
                            render.PushRasterizerState(RasterizerState.CullClockwise);
                        else
                            render.PushRasterizerState(RasterizerState.CullCounterClockwise);

                        render.RenderBatch(sphereModel.GetBatchInformation(0)[0], pointLightEffect);

                        render.PopRasterizerState();
                    }
                  
                }
            }
            render.SetSamplerState(s2, 2);
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:50,代码来源:PreLightMap.cs

示例12: Draw

        /// <summary>
        /// Draws the specified gt.
        /// </summary>
        /// <param name="gt">The gt.</param>
        /// <param name="obj">The obj.</param>
        /// <param name="render">The render.</param>
        /// <param name="camera">The camera.</param>
        /// <param name="lights">The lights.</param>
        protected override void Draw(GameTime gt, IObject obj, RenderHelper render, ICamera camera, IList<ILight> lights)
        {                
                this._shader.Parameters["View"].SetValue(camera.View);
                this._shader.Parameters["Projection"].SetValue(camera.Projection);

                //this._shader.Parameters["Cubemap"].SetValue(texCube);
                render.device.Textures[4] = texCube;

                this._shader.Parameters["id"].SetValue(shaderId);
                
                Matrix wld = obj.WorldMatrix;

                for (int i = 0; i < obj.Modelo.MeshNumber; i++)
                {
                    BatchInformation[] bi = obj.Modelo.GetBatchInformation(i);                    
                    for (int j = 0; j < bi.Count(); j++)
                    {
                        if (rType == ReflectionType.ReflexiveSurface)
                            //this._shader.Parameters["Texture"].SetValue(obj.Modelo.getTexture(TextureType.DIFFUSE, i, j));
                            render.device.Textures[0] = obj.Modelo.getTexture(TextureType.DIFFUSE, i, j);

                        this._shader.Parameters["World"].SetValue(Matrix.Multiply(wld, bi[j].ModelLocalTransformation));
                        render.RenderBatch(bi[j], _shader);
                    }         
                }
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:34,代码来源:DeferredEMReflectiveShader.cs

示例13: RenderLights

        private void RenderLights(ICamera camera, IWorld world, RenderHelper render, GraphicInfo ginfo)
        {
            _lighting.Parameters["halfPixel"].SetValue(ginfo.HalfPixel);
            _lighting.Parameters["DepthBuffer"].SetValue(_depthBuffer);
            _lighting.Parameters["NormalBuffer"].SetValue(_normalBuffer);
            
            ApplyFrustumCorners(_lighting, -Vector2.One, Vector2.One);
            ApplyFrustumCorners(pointLightEffect, -Vector2.One, Vector2.One);  

            for (int i = 0; i < world.Lights.Count; i++)
            {
                if (world.Lights[i].LightType == LightType.Deferred_Directional)
                {
                    DirectionalLightPE dl = (DirectionalLightPE)world.Lights[i];
                    _lighting.Parameters["LightColor"].SetValue(dl.Color.ToVector4());
                    _lighting.Parameters["LightIntensity"].SetValue(dl.LightIntensity);
                    _lighting.Parameters["LightDir"].SetValue(dl.LightDirection);
                    render.RenderFullScreenQuadVertexPixel(_lighting);
                }

                else if (world.Lights[i].LightType == LightType.Deferred_Point)
                {

                    PointLightPE pl = world.Lights[i] as PointLightPE;
                    Matrix sphereWorldMatrix = Matrix.CreateScale(pl.LightRadius) * Matrix.CreateTranslation(pl.LightPosition);
                    ContainmentType ct = camera.BoundingFrustum.Contains(new BoundingSphere(pl.LightPosition, pl.LightRadius));

                    Vector3 viewSpaceLPos = Vector3.Transform(pl.LightPosition,
                                                            camera.View);
                    
                    pointLightEffect.Parameters["cameraPos"].SetValue(camera.Position);
                    pointLightEffect.Parameters["LightColor"].SetValue(pl.Color.ToVector4());
                    pointLightEffect.Parameters["LightPosition"].SetValue(viewSpaceLPos);
                    pointLightEffect.Parameters["lightRadius"].SetValue(pl.LightRadius);                    
                    
                    pointLightEffect.Parameters["WorldViewProjection"].SetValue(sphereWorldMatrix * camera.ViewProjection);
                    //pointLightEffect.Parameters["FarClip"].SetValue(camera.FarPlane);

                    float _tanFovy = (float)Math.Tan(camera.FieldOfView);
                    //pointLightEffect.Parameters["TanAspect"].SetValue(new Vector2(_tanFovy * camera.AspectRatio, -_tanFovy));
                    pointLightEffect.Parameters["GBufferPixelSize"].SetValue(new Vector2(0.5f / _width, 0.5f / _height));                                        
                    
                    pointLightEffect.Parameters["lightIntensity"].SetValue(pl.LightIntensity);
                                        
                    if (ct == ContainmentType.Contains || ct == ContainmentType.Intersects)
                    {   
                        float cameraToCenter = Vector3.Distance(camera.Position, pl.LightPosition);

                        if (cameraToCenter < pl.LightRadius + camera.NearPlane)
                            render.PushRasterizerState(RasterizerState.CullClockwise);
                        else
                            render.PushRasterizerState(RasterizerState.CullCounterClockwise);

                        render.RenderBatch(sphereModel.GetBatchInformation(0)[0], pointLightEffect);

                        render.PopRasterizerState();
                    }

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

示例14: BasicDraw

        /// <summary>
        /// Draw the object in a simple way (WITH MINIMUM EFFECTS,....)
        /// USED IN RELECTIONS, REFRACTION .....
        /// </summary>
        /// <param name="gt">The gt.</param>
        /// <param name="obj">The obj.</param>
        /// <param name="view">The view.</param>
        /// <param name="projection">The projection.</param>
        /// <param name="lights">The lights.</param>
        /// <param name="render">The render.</param>
        /// <param name="clippingPlane">The clipping plane.</param>
        /// <param name="useAlphaBlending">if set to <c>true</c> [use alpha blending].</param>
        public virtual void BasicDraw(GameTime gt, IObject obj, ref Matrix view, ref Matrix projection, IList<ILight> lights, RenderHelper render,Plane? clippingPlane, bool useAlphaBlending = false)
        {
            
            Matrix wld = obj.WorldMatrix;
            if (clippingPlane.HasValue)
            {
                Vector4 plane = new Vector4(clippingPlane.Value.Normal, clippingPlane.Value.D);
                basicDraw.Parameters["clippingPlane"].SetValue(plane);
                basicDraw.Parameters["isClip"].SetValue(true);
            }
            else
            {
                basicDraw.Parameters["isClip"].SetValue(false);
            }            

            if(useAlphaBlending)
                render.PushBlendState(BlendState.AlphaBlend);

            SamplerState s0 =  render.SetSamplerState(BasicDrawSamplerState,0);

            for (int i = 0; i < obj.Modelo.MeshNumber; i++)
            {
                BatchInformation[] bi = obj.Modelo.GetBatchInformation(i);
                for (int j = 0; j < bi.Count(); j++)
                {
                    //basicDraw.Parameters["diffuse"].SetValue(obj.Modelo.getTexture(TextureType.DIFFUSE,i,j));
                    render.device.Textures[0] =  obj.Modelo.getTexture(TextureType.DIFFUSE, i, j);
                    Matrix w1 = Matrix.Multiply(wld, bi[j].ModelLocalTransformation);
                    this.basicDraw.Parameters["WVP"].SetValue(w1 * view * projection);

                    render.RenderBatch(bi[j], basicDraw);
                }
            }

            if(useAlphaBlending)
                render.PopBlendState();

            render.SetSamplerState(s0, 0);
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:51,代码来源:IShader.cs

示例15: Draw

        /// <summary>
        /// Draws the box.
        /// </summary>
        /// <param name="render">The render.</param>
        /// <param name="view">The viewing matrix.</param>
        /// <param name="projection">The projection matrix.</param>
        public void Draw(RenderHelper render, Matrix view, Matrix projection)
        {
            if (Visible)
            {                
                //// Setup the effect.                
                effect.View = view;
                effect.Projection = projection;
                effect.World = Matrix.CreateScale(Radius) * Matrix.CreateTranslation(Position);                
                effect.DiffuseColor = Color.ToVector3();

                if(RasterizerState != null)
                    render.PushRasterizerState(RasterizerState);
                
                render.RenderBatch(sphereModel.GetBatchInformation(0)[0], effect);
                
                if (RasterizerState != null)
                    render.PopRasterizerState();
            }
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:25,代码来源:DebugSphere.cs


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