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


C# RenderHelper.SetSamplerState方法代码示例

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


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

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

示例2: Draw

        public override void Draw(Texture2D ImageToProcess, RenderHelper rHelper, GameTime gt, Engine.GraphicInfo GraphicInfo, IWorld world, bool useFloatingBuffer)
        {
                effect.Parameters["weight"].SetValue(weight);
                effect.Parameters["pixel_size"].SetValue(GraphicInfo.HalfPixel * 2 * pixelSizeMultiplier);
                //effect.Parameters["normal"].SetValue(rHelper[PrincipalConstants.normalRt]);
                rHelper.device.Textures[1] = rHelper[PrincipalConstants.normalRt];
                SamplerState s1 = rHelper.SetSamplerState(SamplerState.PointClamp,1);
                
                if (useFloatingBuffer)
                    rHelper.RenderTextureToFullScreenSpriteBatch(ImageToProcess, effect, GraphicInfo.FullScreenRectangle,SamplerState.PointClamp,BlendState.Opaque);
                else
                    rHelper.RenderTextureToFullScreenSpriteBatch(ImageToProcess, effect, GraphicInfo.FullScreenRectangle, GraphicInfo.SamplerState, BlendState.Opaque);

                rHelper.SetSamplerState(s1, 1);
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:15,代码来源:AntiAliasingPostEffect.cs

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

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

示例5: DrawPointLight

        private void DrawPointLight(RenderHelper render, GraphicInfo ginfo, ICamera camera, PointLightPE pl, IDeferredGBuffer DeferredGBuffer,bool cullPointLight)
        {

                    pointLightEffect.Parameters["halfPixel"].SetValue(ginfo.HalfPixel);
                    render.device.Textures[0] = DeferredGBuffer[GBufferTypes.COLOR];
                    render.device.Textures[1] = DeferredGBuffer[GBufferTypes.NORMAL];
                    render.device.Textures[2] = DeferredGBuffer[GBufferTypes.DEPH];
                    SamplerState s2 = render.SetSamplerState(SamplerState.PointClamp, 2);

                    pointLightEffect.Parameters["Projection"].SetValue(camera.Projection);
                    pointLightEffect.Parameters["View"].SetValue(camera.View);
                    pointLightEffect.Parameters["cameraPosition"].SetValue(camera.Position);
                    pointLightEffect.Parameters["InvertViewProjection"].SetValue(Matrix.Invert(camera.ViewProjection));

                    
                    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)
                    {
                        pointLightEffect.Parameters["World"].SetValue(sphereWorldMatrix);
                        pointLightEffect.Parameters["lightPosition"].SetValue(pl.LightPosition);
                        pointLightEffect.Parameters["Color"].SetValue(pl.Color.ToVector3());
                        pointLightEffect.Parameters["lightRadius"].SetValue(pl.LightRadius);
                        pointLightEffect.Parameters["lightIntensity"].SetValue(pl.LightIntensity);
                        pointLightEffect.Parameters["quadratic"].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,代码行数:43,代码来源:ShadowLightMap.cs

示例6: DrawScene

        public void DrawScene(GameTime gameTime, IWorld world, IDeferredGBuffer gbuffer, IDeferredLightMap lightmap, RenderHelper render)
        {
            render.PushDepthStencilState(DepthStencilState.None);

            PambientColor.SetValue(ambientColor.ToVector3());
            render.device.Textures[0] = lightmap[DeferredLightMapType.LIGHTMAP];
            SamplerState s0 = render.SetSamplerState(SamplerState.PointClamp, 0);

            render.device.Textures[1] = gbuffer[GBufferTypes.Extra1];
            render.device.Textures[2] = gbuffer[GBufferTypes.COLOR];
            //PEXTRA1.SetValue(gbuffer[GBufferTypes.Extra1]);            
            //PcolorMap.SetValue(gbuffer[GBufferTypes.COLOR]);
            //PlightMap.SetValue(lightmap[DeferredLightMapType.LIGHTMAP]);            

            render.RenderFullScreenQuadVertexPixel(finalCombineEffect);

            render.SetSamplerState(s0, 0);            

            if (saveToTexture)
            {
                render.PopRenderTarget();                
            }
            render.PopDepthStencilState();
            
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:25,代码来源:FinalCombination.cs

示例7: Draw

            public void Draw(RenderHelper render,ICamera2D cam)
            {
                render.SetSamplerState(SamplerState.AnisotropicWrap,0);
                render.PushRasterizerState(RasterizerState.CullNone);
                _basicEffect.Projection = cam.SimProjection;
                _basicEffect.View = cam.SimView;
                render.RenderUserPrimitive(_basicEffect,PrimitiveType.TriangleList, _borderVerts, 0, 8);

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

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

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

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

示例11: Draw

 protected override void Draw(GameTime gt, IObject obj, RenderHelper render, ICamera cam, IList<ILight> lights)
 {
     _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["xCamPos"].SetValue(cam.Position);
     _shader.Parameters["xAllowedRotDir"].SetValue(allowRotationDirection);
     //_shader.Parameters["xBillboardTexture"].SetValue(obj.Modelo.getTexture(TextureType.DIFFUSE,0,0));
     render.device.Textures[0] = obj.Modelo.getTexture(TextureType.DIFFUSE, 0, 0);
     _shader.Parameters["atenuation"].SetValue(atenuation);
     
     BatchInformation batchInfo = obj.Modelo.GetBatchInformation(0)[0];            
     {                
         _shader.Parameters["alphaTest"].SetValue(alphaTestLimit);
         SamplerState s7 = render.SetSamplerState(SamplerState.LinearClamp, 7);
         render.RenderBatch(batchInfo, _shader);
         render.SetSamplerState(s7, 7);
     }
     
 }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:22,代码来源:DeferredCilindricGPUBilboardShader.cs

示例12: 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)
        {
            rHelper.PushRenderTarget(RenderTarget2D);
            effect.Parameters["blurDepthFalloff"].SetValue(blurDepthFalloff);
            effect.Parameters["weights"].SetValue(kernel);
            effect.Parameters["offsets"].SetValue(offsetsHoriz);
            effect.Parameters["GBufferPixelSize"].SetValue(new Vector2(1f / ImageToProcess.Width, 1f / ImageToProcess.Height));
            effect.Parameters["TempBufferRes"].SetValue(destinySize.Value);
            rHelper.Textures[0] = rHelper[PrincipalConstants.DephRT];
            rHelper.Textures[1] = ImageToProcess;
            SamplerState s0 = rHelper.SetSamplerState(SamplerState.PointClamp, 0);
            SamplerState s1 = rHelper.SetSamplerState(ImageSamplerState, 1);
            rHelper.RenderFullScreenQuadVertexPixel(effect);

            rHelper.PopRenderTarget();
            
            effect.Parameters["offsets"].SetValue(offsetsVert);
            rHelper.Textures[1] = RenderTarget2D;
            rHelper.RenderFullScreenQuadVertexPixel(effect);

            rHelper.SetSamplerState(s0, 0);
            rHelper.SetSamplerState(s1, 1);

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

示例13: DrawDirectionalLight

        protected void DrawDirectionalLight(ICamera camera, IList<ILight> lights, IDeferredGBuffer DeferredGBuffer,RenderHelper render)
        {
            ComputeFrustumCorners(camera);
            ApplyFrustumCorners(directionalLightEffect.Parameters["FrustumCorners"], -Vector2.One, Vector2.One);

            render.Textures[1] = DeferredGBuffer[GBufferTypes.NORMAL];
            render.Textures[2] = DeferredGBuffer[GBufferTypes.DEPH];
            SamplerState s2 = render.SetSamplerState(SamplerState.PointClamp, 2);

            DirectionalhalfPixel.SetValue(ginfo.HalfPixel);
                        
            foreach (ILight item in lights)
            {
                if (item.LightType == LightType.Deferred_Directional && item.Enabled == true)
                {
                    PloobsEngine.Light.DirectionalLightPE dl = item as PloobsEngine.Light.DirectionalLightPE;

                    Vector3 vldir = Vector3.Transform(dl.LightDirection, camera.View);
                    DirectionallightDirection.SetValue(vldir);
                    DirectionalColor.SetValue(dl.Color.ToVector3());
                    DirectionallightIntensity.SetValue(dl.LightIntensity);

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

示例14: DrawnSpotLight

        protected void DrawnSpotLight(ICamera camera, IList<ILight> lights, IDeferredGBuffer DeferredGBuffer,RenderHelper render)
        {
            render.PushRasterizerState(RasterizerState.CullNone);
            render.PushDepthStencilState(DepthStencilState.None);            
                        
            render.Textures[1] = DeferredGBuffer[GBufferTypes.NORMAL];
            render.Textures[2] = DeferredGBuffer[GBufferTypes.DEPH];
            SamplerState s2 = render.SetSamplerState(SamplerState.PointClamp, 2);

            spotLightEffect.Parameters["View"].SetValue(camera.View);
            spotLightEffect.Parameters["Projection"].SetValue(camera.Projection);
            spotLightEffect.Parameters["cameraPosition"].SetValue(camera.Position);

            ApplyFrustumCorners(directionalLightEffect.Parameters["FrustumCorners"], -Vector2.One, Vector2.One);            
            
            foreach (ILight item in lights)
            {
                if (item.LightType == LightType.Deferred_Spot && item.Enabled == true)
                {
                    SpotLightPE sl = item as SpotLightPE;
                    Vector3 viewSpaceLPos = Vector3.Transform(sl.Position, camera.View);
                    Vector3 viewSpaceLDir = Vector3.Transform(sl.Direction, camera.View);

                    spotLightEffect.Parameters["lightPosition"].SetValue(viewSpaceLPos);
                    spotLightEffect.Parameters["lightDirection"].SetValue(viewSpaceLDir);
                    spotLightEffect.Parameters["lightRadius"].SetValue(sl.LightRadius);
                    spotLightEffect.Parameters["lightDecayExponent"].SetValue(sl.ConeDecay);
                    spotLightEffect.Parameters["Color"].SetValue(sl.Color.ToVector3());
                    spotLightEffect.Parameters["lightAngleCosine"].SetValue(sl.LightAngleCosine);
                    spotLightEffect.Parameters["lightIntensity"].SetValue(sl.LightIntensity);                    

                    render.RenderFullScreenQuadVertexPixel(spotLightEffect);                    
                }
            }

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

示例15: DrawnSpotLight

        private void DrawnSpotLight(RenderHelper render, GraphicInfo ginfo, ICamera camera, SpotLightPE sl, IDeferredGBuffer DeferredGBuffer)
        {
                    //if(sl.CastShadown)
                    //    spotLightEffect.Parameters["xShadowMap"].SetValue(shadowMap);
                    //else
                    //    spotLightEffect.Parameters["xShadowMap"].SetValue(blank);

                    if (sl.CastShadown)
                        render.device.Textures[3] = shadowMap;
                    else
                        render.device.Textures[3] = blank;

                    spotLightEffect.Parameters["shadowBufferSize"].SetValue(shadownBufferSize);
                    spotLightEffect.Parameters["BIAS"].SetValue(sl.SHADOWBIAS);                    

                    //spotLightEffect.Parameters["colorMap"].SetValue(DeferredGBuffer[GBufferTypes.COLOR]);
                    //spotLightEffect.Parameters["normalMap"].SetValue(DeferredGBuffer[GBufferTypes.NORMAL]);
                    //spotLightEffect.Parameters["depthMap"].SetValue(DeferredGBuffer[GBufferTypes.DEPH]);            
                    render.device.Textures[0] = DeferredGBuffer[GBufferTypes.COLOR];
                    render.device.Textures[1] = DeferredGBuffer[GBufferTypes.NORMAL];
                    render.device.Textures[2] = DeferredGBuffer[GBufferTypes.DEPH];
                    SamplerState s2 = render.SetSamplerState(SamplerState.PointClamp, 2);
                    SamplerState s3 = render.SetSamplerState(SamplerState.PointClamp, 3);

                    spotLightEffect.Parameters["xLightViewProjection"].SetValue(sl.ViewMatrix * sl.ProjMatrix);
                    spotLightEffect.Parameters["View"].SetValue(camera.View);
                    spotLightEffect.Parameters["Projection"].SetValue(camera.Projection);
                    spotLightEffect.Parameters["cameraPosition"].SetValue(camera.Position);
                    spotLightEffect.Parameters["shadown"].SetValue(sl.CastShadown);
                    spotLightEffect.Parameters["InvertViewProjection"].SetValue(Matrix.Invert(camera.ViewProjection));
                    spotLightEffect.Parameters["halfPixel"].SetValue(ginfo.HalfPixel);
                    spotLightEffect.Parameters["lightPosition"].SetValue(sl.Position);
                    spotLightEffect.Parameters["lightDirection"].SetValue(sl.Direction);
                    spotLightEffect.Parameters["lightRadius"].SetValue(sl.LightRadius);
                    spotLightEffect.Parameters["lightDecayExponent"].SetValue(sl.ConeDecay);
                    spotLightEffect.Parameters["Color"].SetValue(sl.Color.ToVector3());
                    spotLightEffect.Parameters["lightAngleCosine"].SetValue(sl.LightAngleCosine);
                    spotLightEffect.Parameters["lightIntensity"].SetValue(sl.LightIntensity);
                    render.PushDepthStencilState(DepthStencilState.None);     
                    render.RenderFullScreenQuadVertexPixel(spotLightEffect);
                    render.PopDepthStencilState();
                    render.SetSamplerState(s2, 2);
                    render.SetSamplerState(s3, 3);
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:44,代码来源:ShadowLightMap.cs


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