public override void Init(Engine.GraphicInfo ginfo, Engine.GraphicFactory factory)
        {
            target = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight);
            target2 = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight);            
            effect = factory.GetEffect("glowPost",false,true);

            gbp = new GaussianBlurPostEffect();
            gbp.Init(ginfo, factory); 


        }
 public override void Init(Engine.GraphicInfo ginfo, Engine.GraphicFactory factory)
 {
     this.toon = factory.GetEffect("toon1",false,true);
     this.line = factory.GetEffect("LineDetection",false,true);
     this.cell = factory.GetTexture2D("Toon",true);            
     target = factory.CreateRenderTarget(ginfo.BackBufferWidth,ginfo.BackBufferHeight,SurfaceFormat.Color,ginfo.UseMipMap,DepthFormat.None,ginfo.MultiSample);
 }
 public override void Init(Engine.GraphicInfo ginfo, Engine.GraphicFactory factory)
 {           
     depht = factory.GetEffect("depth",false,true);
     target = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight,SurfaceFormat.Color,
         ginfo.UseMipMap,DepthFormat.None,ginfo.MultiSample);
     be= new GaussianBlurPostEffect();
     be.Init(ginfo, factory); 
 }
        public void LoadContent(IContentManager manager, Engine.GraphicInfo ginfo, Engine.GraphicFactory factory, bool cullPointLight, bool useFloatingBufferForLightning)
        {
            _lightAddBlendState = new BlendState()
            {
                AlphaSourceBlend = Blend.One,
                ColorSourceBlend = Blend.One,
                AlphaDestinationBlend = Blend.One,
                ColorDestinationBlend = Blend.One,
            };
            this.ginfo = ginfo;
            shadow = new DirectionalShadowRenderer();
            shadow.ShadowFilteringType = filteringType;
            shadow.ShadowMapSize = shadowMapSize;
            shadow.SplitConstant = splitConstant;
            
            shadownBufferSize = ginfo.BackBufferWidth;
            shadowRT = factory.CreateRenderTarget(shadownBufferSize, shadownBufferSize, SurfaceFormat.Single, ginfo.UseMipMap,DepthFormat.Depth24Stencil8,ginfo.MultiSample);

            if (useFloatingBufferForLightning)
                lightRT = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.HdrBlendable, ginfo.UseMipMap, DepthFormat.None, ginfo.MultiSample, RenderTargetUsage.PreserveContents);
            else
                lightRT = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.None, ginfo.MultiSample, RenderTargetUsage.PreserveContents);

            pointLightEffect = factory.GetEffect("PointLight",false,true);
            directionalLightEffect = factory.GetEffect("ShadowDirectionalCascade",false,true);
            spotLightEffect = factory.GetEffect("ShadowSpot",false,true);
            sphereModel = new SimpleModel(factory, "Dsphere", true);
            blank = factory.CreateTexture2DColor(1, 1, Color.White);

            rt = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight,SurfaceFormat.Color,ginfo.UseMipMap,DepthFormat.Depth24Stencil8,ginfo.MultiSample);
            deferredRT = factory.CreateRenderTarget(shadownBufferSize, shadownBufferSize, SurfaceFormat.Single,ginfo.UseMipMap, DepthFormat.Depth24Stencil8, ginfo.MultiSample);
            shadow.Load(factory,ginfo);

            switch (shadowFilterSpot)
            {
                case ShadowFilter.NONE:
                    spotLightEffect.CurrentTechnique = spotLightEffect.Techniques["Technique1"];
                    break;                
                case ShadowFilter.PCF3x3:
                    spotLightEffect.CurrentTechnique = spotLightEffect.Techniques["Technique2"];
                    break;             
                case ShadowFilter.PCF7x7SOFT:
                    spotLightEffect.CurrentTechnique = spotLightEffect.Techniques["Technique3"];
                    break;
                default:
                    break;
            }

        }
        //EffectParameter PcolorMap;
        //EffectParameter PlightMap;

        #endregion

#region IDeferredFinalCombination Members


        public void LoadContent(IContentManager manager, Engine.GraphicInfo ginfo, Engine.GraphicFactory factory, bool useFloatBuffer, bool saveToTexture )
        {
            this.useFloatBuffer = useFloatBuffer;
            this.ginfo = ginfo;
            this.saveToTexture = saveToTexture;
            finalCombineEffect = manager.GetAsset<Effect>("CombineFinal",true);
            PhalfPixel = finalCombineEffect.Parameters["halfPixel"];            
            PambientColor = finalCombineEffect.Parameters["ambientColor"];
            //PEXTRA1 = finalCombineEffect.Parameters["EXTRA1"];
            //PcolorMap = finalCombineEffect.Parameters["colorMap"];
            //PlightMap = finalCombineEffect.Parameters["lightMap"];
            

            PhalfPixel.SetValue(ginfo.HalfPixel);
            if (saveToTexture)
            {
                if (useFloatBuffer)
                    target = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.HdrBlendable, ginfo.UseMipMap, DepthFormat.None, ginfo.MultiSample, RenderTargetUsage.DiscardContents);
                else
                    target = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.None, ginfo.MultiSample, RenderTargetUsage.DiscardContents);
            }                        
        }
        public override void Init(Engine.GraphicInfo ginfo, Engine.GraphicFactory factory)
        {
            target = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.None, ginfo.MultiSample);

            target2 = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.None, ginfo.MultiSample);

            target3 = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.None, ginfo.MultiSample);

            effect = factory.GetEffect("SSAOPOST", false, true);
            ssaofinal = factory.GetEffect("ssaofinal", false, true);

            RandomTexture = factory.GetTexture2D("random", true);
            gbp = new GaussianBlurPostEffect();
            gbp.Init(ginfo, factory);
        }
        public override void Init(Engine.GraphicInfo ginfo, Engine.GraphicFactory factory)
        {
            
            Saturate = factory.GetEffect("Saturate",false,true);
            Saturate.Parameters["BloomThreshold"].SetValue(bloomThreshold);
            Combine = factory.GetEffect("Combine",false,true);

            renderTarget0 = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight,SurfaceFormat.Color,ginfo.UseMipMap,DepthFormat.None,ginfo.MultiSample);
            renderTarget1 = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.None, ginfo.MultiSample);
            
            gaussian = new GaussianBlurPostEffect();            
            gaussian.Init(ginfo,factory); 
            
        }  
        /// <summary>
        /// Initiates the specified Post Effect.
        /// Called by the engine
        /// </summary>
        /// <param name="ginfo">The ginfo.</param>
        /// <param name="factory">The factory.</param>
        public override void Init(Engine.GraphicInfo ginfo, Engine.GraphicFactory factory)
        {
            additiveBlend = new BlendState();
            additiveBlend.AlphaBlendFunction = BlendFunction.Add;
            additiveBlend.AlphaSourceBlend = Blend.One;
            additiveBlend.AlphaDestinationBlend = Blend.One;
            additiveBlend.ColorBlendFunction = BlendFunction.Add;
            additiveBlend.ColorSourceBlend = Blend.One;
            additiveBlend.ColorDestinationBlend = Blend.One;

            subBlend = new BlendState();
            subBlend.AlphaBlendFunction = BlendFunction.Subtract;
            subBlend.AlphaSourceBlend = Blend.One;
            subBlend.AlphaDestinationBlend = Blend.One;
            subBlend.ColorBlendFunction = BlendFunction.Subtract;
            subBlend.ColorSourceBlend = Blend.One;
            subBlend.ColorDestinationBlend = Blend.One;

            rt = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight);
            ginfo.OnGraphicInfoChange += ginfo_OnGraphicInfoChange;
            this.factory = factory;
            this.ginfo = ginfo;
            
        }
 public void LoadContent(IContentManager manager, Engine.GraphicInfo ginfo, Engine.GraphicFactory factory, Color BackGroundColor,bool useFloatBuffer)
 {
     this.useFloatBuffer = useFloatBuffer;                                    
     normalRT = factory.CreateRenderTarget(ginfo.BackBufferWidth , ginfo.BackBufferHeight, SurfaceFormat.Color, false, DepthFormat.Depth24, 0, RenderTargetUsage.DiscardContents);
     depthRT = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Single, false, DepthFormat.Depth24, 0, RenderTargetUsage.DiscardContents);
     //lightOclusionRT = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.None, multisample, RenderTargetUsage.DiscardContents);            
     clearBufferEffect = manager.GetAsset<Effect>("PrePass2/ClearGBuffer");
 }
 public void LoadContent(IContentManager manager, Engine.GraphicInfo ginfo, Engine.GraphicFactory factory, Color BackGroundColor, bool useFloatBuffer)
 {
     this.backGroundColor = BackGroundColor;
     colorRT2 = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.Depth24Stencil8, 8, RenderTargetUsage.DiscardContents);
     colorRT = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.DiscardContents);
     normalRT = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.None, 0, RenderTargetUsage.DiscardContents);
     depthRT = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Single, ginfo.UseMipMap, DepthFormat.None, 0, RenderTargetUsage.DiscardContents);
     lightOclusionRT = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.None, 0, RenderTargetUsage.DiscardContents);            
     clearBufferEffect = manager.GetAsset<Effect>("ClearGBuffer",true);
     effect = factory.GetEffect("Effects//hibe");
     
 }
        public override void Init(Engine.GraphicInfo ginfo, Engine.GraphicFactory factory)
        {
            gblur = factory.GetEffect("gblur",true,true);
            if (useHalfSingleRenderTarget)
            {
                target = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Single, ginfo.UseMipMap, DepthFormat.None, ginfo.MultiSample);
            }
            else
            {
                target = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.None, ginfo.MultiSample);
            }

            Vector2 texelSize = new Vector2(1f / ginfo.BackBufferWidth, 1f / ginfo.BackBufferHeight);
            SetBlurParameters(texelSize.X, 0, ref sampleOffsetsH, ref sampleWeightsH);
            SetBlurParameters(0, texelSize.Y, ref sampleOffsetsV, ref sampleWeightsV);
        }
        public void LoadContent(IContentManager manager, Engine.GraphicInfo ginfo, Engine.GraphicFactory factory, Color BackGroundColor,bool useFloatBuffer)
        {
            this.useFloatBuffer = useFloatBuffer;
            this.backGroundColor = BackGroundColor;
                        
            const int multisample = 0;
            colorRT = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.Depth24Stencil8, multisample, RenderTargetUsage.DiscardContents);
            normalRT = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.None, multisample, RenderTargetUsage.DiscardContents);
            depthRT = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Single, ginfo.UseMipMap, DepthFormat.None, multisample, RenderTargetUsage.DiscardContents);
            lightOclusionRT = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.None, multisample, RenderTargetUsage.DiscardContents);            
            clearBufferEffect = manager.GetAsset<Effect>("ClearGBuffer",true);

            clearBufferEffect.Parameters["BackColor"].SetValue(backGroundColor.ToVector3());
        }
        protected override void  AfterLoadContent(IContentManager manager, Engine.GraphicInfo ginfo, Engine.GraphicFactory factory)
        {
            this.ginfo = ginfo;

            {
                if (ginfo.CheckIfRenderTargetFormatIsSupported(SurfaceFormat.HdrBlendable, DepthFormat.Depth24Stencil8, ginfo.UseMipMap, ginfo.MultiSample) == false)
                {
                    throw new NotSupportedException("The plataform does not support the specified Render target Combination for Deferred Rendering, check the logs for more info");
                }               
            }

            if (ginfo.CheckIfRenderTargetFormatIsSupported(SurfaceFormat.Color, DepthFormat.Depth24Stencil8, ginfo.UseMipMap, ginfo.MultiSample) == false)
            {
                throw new NotSupportedException("The plataform does not support the specified Render target Combination for Deferred Rendering, check the logs for more info");
            }

            if (ginfo.CheckIfRenderTargetFormatIsSupported(SurfaceFormat.Single, DepthFormat.Depth24Stencil8, false, 0) == false)
            {
                throw new NotSupportedException("The plataform does not support the specified Render target Combination for Deferred Rendering, check the logs for more info");
            }

            if (ginfo.CheckIfRenderTargetFormatIsSupported(SurfaceFormat.Single, DepthFormat.Depth24Stencil8, ginfo.UseMipMap, ginfo.MultiSample) == false)
            {
                ActiveLogger.LogMessage("Shadow can behave strange, you dont have the minimum requirements", LogLevel.Warning);
            }


            deferredGBuffer.LoadContent(manager, ginfo, factory, desc.BackGroundColor, true);
            deferredLightMap.LoadContent(manager, ginfo, factory, desc.CullPointLight,true);
            
            target = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.HdrBlendable, ginfo.UseMipMap, DepthFormat.Depth24Stencil8, ginfo.MultiSample);
            target2 = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.HdrBlendable, ginfo.UseMipMap, DepthFormat.Depth24Stencil8, ginfo.MultiSample);
            scenerender = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.HdrBlendable, ginfo.UseMipMap, DepthFormat.Depth24Stencil8, ginfo.MultiSample);

            PostEffectTarget = target;
            halfWidth = ginfo.Viewport.Width / 2;
            halfHeight = ginfo.Viewport.Height / 2;        
        }
        public void LoadContent(IContentManager manager, Engine.GraphicInfo ginfo, Engine.GraphicFactory factory, bool cullPointLight, bool useFloatingBufferForLightning)
        {
            this.ginfo = ginfo;
            this.cullPointLight = cullPointLight;
            if (useFloatingBufferForLightning)
            {
                lightRT = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.HdrBlendable, ginfo.UseMipMap, DepthFormat.None, ginfo.MultiSample, RenderTargetUsage.DiscardContents);
                samplerState = SamplerState.PointClamp;
            }
            else
            {
                lightRT = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.None, ginfo.MultiSample, RenderTargetUsage.DiscardContents);
                samplerState = ginfo.SamplerState;
            }

            directionalLightEffect = manager.GetAsset<Effect>("PrePass2/DirectionalLight");
            pointLightEffect = manager.GetAsset<Effect>("PrePass2/PointLight");
            sphereModel = new SimpleModel(factory, "Models/Dsphere");
            spotLightEffect = manager.GetAsset<Effect>("PrePass2/SpotLight");
            
            spotLightEffect.Parameters["halfPixel"].SetValue(ginfo.HalfPixel);
            pointLightEffect.Parameters["halfPixel"].SetValue(ginfo.HalfPixel);

            DirectionalhalfPixel = directionalLightEffect.Parameters["halfPixel"];
            

            DirectionallightDirection = directionalLightEffect.Parameters["lightDirection"];
            DirectionalColor = directionalLightEffect.Parameters["Color"];
            DirectionallightIntensity = directionalLightEffect.Parameters["lightIntensity"];

            PointWordViewProjection = pointLightEffect.Parameters["wvp"];
            PointlightPosition = pointLightEffect.Parameters["lightPosition"];
            PointColor = pointLightEffect.Parameters["Color"];
            PointlightRadius = pointLightEffect.Parameters["lightRadius"];
            PointlightIntensity = pointLightEffect.Parameters["lightIntensity"];
            Pointquadratic = pointLightEffect.Parameters["quadratic"];
            PointcameraPosition = pointLightEffect.Parameters["cameraPosition"];

            _lightAddBlendState = new BlendState()
            {
                AlphaSourceBlend = Blend.One,
                ColorSourceBlend = Blend.One,
                AlphaDestinationBlend = Blend.One,
                ColorDestinationBlend = Blend.One,
            };
        }