Ejemplo n.º 1
0
        /// <summary>
        /// Load's the graphics related content required to draw light maps
        /// </summary>
        protected override void LoadContent()
        {
            // This needs to better handle content loading...
            // if the window is resized, Krypton needs to notice.
            _effect      = Game.Content.Load <Effect>(_effectAssetName);
            RenderHelper = new KryptonRenderHelper(GraphicsDevice, _effect);

            CreateRenderTargets();
        }
Ejemplo n.º 2
0
        public void BlurTextureToTarget(Texture2D texture, LightMapSize mapSize, BlurTechnique blurTechnique, float bluriness)
        {
            // Get the pass to use
            string passName = "";

            switch (blurTechnique)
            {
            case (BlurTechnique.Horizontal):
                this.mEffect.Parameters["BlurFactorU"].SetValue(1f / this.GraphicsDevice.PresentationParameters.BackBufferWidth);
                passName = "HorizontalBlur";
                break;

            case (BlurTechnique.Vertical):
                this.mEffect.Parameters["BlurFactorV"].SetValue(1f / this.mGraphicsDevice.PresentationParameters.BackBufferHeight);
                passName = "VerticalBlur";
                break;
            }

            var biasFactor = KryptonRenderHelper.BiasFactorFromLightMapSize(mapSize);

            // Calculate the texel bias
            Vector2 texelBias = new Vector2()
            {
                X = biasFactor / this.mGraphicsDevice.Viewport.Width,
                Y = biasFactor / this.mGraphicsDevice.Viewport.Height,
            };


            this.mEffect.Parameters["Texture0"].SetValue(texture);
            this.mEffect.Parameters["TexelBias"].SetValue(texelBias);
            this.mEffect.Parameters["Bluriness"].SetValue(bluriness);
            this.mEffect.CurrentTechnique = this.mEffect.Techniques["Blur"];

            mEffect.CurrentTechnique.Passes[passName].Apply();
            this.mGraphicsDevice.DrawUserPrimitives <VertexPositionTexture>(PrimitiveType.TriangleStrip, KryptonRenderHelper.UnitQuad, 0, 2);
        }
Ejemplo n.º 3
0
        public void DrawTextureToTarget(Texture2D texture, LightMapSize mapSize, BlendTechnique blend)
        {
            // Get the technique to use
            string techniqueName = "";

            switch (blend)
            {
            case (BlendTechnique.Add):
                techniqueName = "TextureToTarget_Add";
                break;

            case (BlendTechnique.Multiply):
                techniqueName = "TextureToTarget_Multiply";
                break;
            }

            var biasFactor = KryptonRenderHelper.BiasFactorFromLightMapSize(mapSize);

            // Calculate the texel bias
            Vector2 texelBias = new Vector2()
            {
                X = biasFactor / this.mGraphicsDevice.ScissorRectangle.Width,
                Y = biasFactor / this.mGraphicsDevice.ScissorRectangle.Height,
            };

            this.mEffect.Parameters["Texture0"].SetValue(texture);
            this.mEffect.Parameters["TexelBias"].SetValue(texelBias);
            this.mEffect.CurrentTechnique = this.mEffect.Techniques[techniqueName];

            // Draw the quad
            foreach (var effectPass in this.mEffect.CurrentTechnique.Passes)
            {
                effectPass.Apply();
                this.mGraphicsDevice.DrawUserPrimitives <VertexPositionTexture>(PrimitiveType.TriangleStrip, KryptonRenderHelper.UnitQuad, 0, 2);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Load's the graphics related content required to draw light maps
        /// </summary>
        protected override void LoadContent()
        {
            // This needs to better handle content loading...
            // if the window is resized, Krypton needs to notice.
            effect = Game.Content.Load<Effect>(effectAssetName);
            RenderHelper = new KryptonRenderHelper(GraphicsDevice, effect);

            CreateRenderTargets();
        }