Esempio n. 1
0
 /// <summary>
 /// Create post screen glow
 /// </summary>
 public PostScreenGlow()
     : base(Filename)
 {
     // Final map for glow, used to perform radial blur next step
     radialSceneMapTexture = new RenderToTexture(
         RenderToTexture.SizeType.FullScreen);
 }
        /// <summary>
        /// Create post screen menu. Also used for the constructor of
        /// PostScreenGlow (same RenderToTextures used there).
        /// </summary>
        protected PostScreenMenu(string shaderFilename)
            : base(shaderFilename)
        {
            // Scene map texture
            if (sceneMapTexture == null)
            {
                sceneMapTexture = new RenderToTexture(
                    RenderToTexture.SizeType.FullScreen);
            }
            // Downsample map texture (to 1/4 of the screen)
            if (downsampleMapTexture == null)
            {
                downsampleMapTexture = new RenderToTexture(
                    RenderToTexture.SizeType.QuarterScreen);
            }

            // Blur map texture
            if (blurMap1Texture == null)
            {
                blurMap1Texture = new RenderToTexture(
                    RenderToTexture.SizeType.QuarterScreen);
            }
            // Blur map texture
            if (blurMap2Texture == null)
            {
                blurMap2Texture = new RenderToTexture(
                    RenderToTexture.SizeType.QuarterScreen);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Create post screen glow
 /// </summary>
 public PostScreenGlow()
     : base(Filename)
 {
     // Final map for glow, used to perform radial blur next step
     radialSceneMapTexture = new RenderToTexture(
         RenderToTexture.SizeType.FullScreen);
 }
Esempio n. 4
0
 /// <summary>
 /// Create shadow map screen blur shader.
 /// obs, using full size again: But only use 1/4 of the screen!
 /// </summary>
 public ShadowMapBlur()
     : base(Filename)
 {
     // Scene map texture
     sceneMapTexture = new RenderToTexture(
         //RenderToTexture.SizeType.FullScreen);
         //improve performance:
         RenderToTexture.SizeType.HalfScreen);
     blurMapTexture = new RenderToTexture(
         //RenderToTexture.SizeType.FullScreen);
         //improve performance:
         RenderToTexture.SizeType.HalfScreen);
 }
Esempio n. 5
0
 /// <summary>
 /// Create shadow map screen blur shader.
 /// obs, using full size again: But only use 1/4 of the screen!
 /// </summary>
 public ShadowMapBlur()
     : base(Filename)
 {
     // Scene map texture
     sceneMapTexture = new RenderToTexture(
         //RenderToTexture.SizeType.FullScreen);
         //improve performance:
         RenderToTexture.SizeType.HalfScreen);
     blurMapTexture = new RenderToTexture(
         //RenderToTexture.SizeType.FullScreen);
         //improve performance:
         RenderToTexture.SizeType.HalfScreen);
 }
Esempio n. 6
0
        /// <summary>
        /// Shadow map shader
        /// </summary>
        public ShadowMapShader()
            : base(ShaderFilename)
        {
            // We use R32F, etc. and have a lot of precision
            compareDepthBias = 0.0001f;

            // Ok, time to create the shadow map render target
            shadowMapTexture = new RenderToTexture(
                RenderToTexture.SizeType.ShadowMap);

            CalcShadowMapBiasMatrix();

            shadowMapBlur = new ShadowMapBlur();
        }
Esempio n. 7
0
        /// <summary>
        /// Shadow map shader
        /// </summary>
        public ShadowMapShader()
            : base(ShaderFilename)
        {
            if (BaseGame.CanUsePS20)
                // We use R32F, etc. and have a lot of precision
                compareDepthBias = 0.0001f;
            else
                // A8R8G8B8 isn't very precise, increase comparing depth bias
                compareDepthBias = 0.0075f;// 0.025f;

            // Ok, time to create the shadow map render target
            shadowMapTexture = new RenderToTexture(
                RenderToTexture.SizeType.ShadowMap);

            CalcShadowMapBiasMatrix();

            shadowMapBlur = new ShadowMapBlur();
        }
Esempio n. 8
0
 /// <summary>
 /// Add render to texture instance to allow recreating them all
 /// when DeviceReset is called with help of the remRenderToTextures list. 
 /// </summary>
 public static void AddRemRenderToTexture(RenderToTexture renderToTexture)
 {
     remRenderToTextures.Add(renderToTexture);
 }
Esempio n. 9
0
        /// <summary>
        /// Create post screen menu. Also used for the constructor of
        /// PostScreenGlow (same RenderToTextures used there).
        /// </summary>
        protected PostScreenMenu(string shaderFilename)
            : base(shaderFilename)
        {
            // Scene map texture
            if (sceneMapTexture == null)
                sceneMapTexture = new RenderToTexture(
                    RenderToTexture.SizeType.FullScreen);
            // Downsample map texture (to 1/4 of the screen)
            if (downsampleMapTexture == null)
                downsampleMapTexture = new RenderToTexture(
                    RenderToTexture.SizeType.QuarterScreen);

            // Blur map texture
            if (blurMap1Texture == null)
                blurMap1Texture = new RenderToTexture(
                    RenderToTexture.SizeType.QuarterScreen);
            // Blur map texture
            if (blurMap2Texture == null)
                blurMap2Texture = new RenderToTexture(
                    RenderToTexture.SizeType.QuarterScreen);
        }
Esempio n. 10
0
        /// <summary>
        /// Test create render to texture
        /// </summary>
        public static void TestCreateRenderToTexture()
        {
            Model testPlate = null;
            RenderToTexture renderToTexture = null;

            TestGame.Start(
                delegate
                {
                    testPlate = new Model("CarSelectionPlate");
                    renderToTexture = new RenderToTexture(
                        //SizeType.ShadowMap1024);
                        //.QuarterScreen);
                        SizeType.FullScreen);
                        //SizeType.HalfScreen);
                },
                delegate
                {
                    bool renderToTextureWay =
                        Input.Keyboard.IsKeyUp(Keys.Space) &&
                        Input.GamePadAPressed == false;
                    if (renderToTextureWay)
                    {
                        // Set render target to our texture
                        renderToTexture.SetRenderTarget();

                        // Clear background
                        renderToTexture.Clear(Color.Blue);

                        // Draw background lines
                        BaseGame.DrawLine(new Point(0, 200), new Point(200, 0), Color.Blue);
                        BaseGame.DrawLine(new Point(0, 0), new Point(400, 400), Color.Red);
                        BaseGame.FlushLineManager2D();

                        // And draw object
                        testPlate.Render(Matrix.CreateScale(1.5f));
                        // And flush render manager to draw all objects
                        BaseGame.MeshRenderManager.Render();

                        // Resolve
                        renderToTexture.Resolve(true);

                        // Reset background buffer
                        //obs: RenderToTexture.ResetRenderTarget(true);

                        // Show render target in a rectangle on our screen
                        renderToTexture.RenderOnScreen(
                            //tst:
                            new Rectangle(100, 100, 256, 256));
                            //BaseGame.ResolutionRect);
                    } // if (renderToTextureWay)
                    else
                    {
                        // Copy backbuffer way, render stuff normally first
                        // Clear background
                        BaseGame.Device.Clear(Color.Blue);

                        // Draw background lines
                        BaseGame.DrawLine(new Point(0, 200), new Point(200, 0), Color.Blue);
                        BaseGame.DrawLine(new Point(0, 0), new Point(400, 400), Color.Red);
                        BaseGame.FlushLineManager2D();

                        // And draw object
                        testPlate.Render(Matrix.CreateScale(1.5f));
                    } // else

                    TextureFont.WriteText(2, 30,
                        "renderToTexture.Width=" + renderToTexture.Width);
                    TextureFont.WriteText(2, 60,
                        "renderToTexture.Height=" + renderToTexture.Height);
                    TextureFont.WriteText(2, 90,
                        "renderToTexture.Valid=" + renderToTexture.IsValid);
                    TextureFont.WriteText(2, 120,
                        "renderToTexture.XnaTexture=" + renderToTexture.XnaTexture);
                    TextureFont.WriteText(2, 150,
                        "renderToTexture.ZBufferSurface=" + renderToTexture.ZBufferSurface);
                    TextureFont.WriteText(2, 180,
                        "renderToTexture.Filename=" + renderToTexture.Filename);
                });
        }
        /// <summary>
        /// Shadow map shader
        /// </summary>
        public ShadowMapShader()
            : base(ShaderFilename)
        {
            // We use R32F, etc. and have a lot of precision
            compareDepthBias = 0.0001f;

            // Ok, time to create the shadow map render target
            shadowMapTexture = new RenderToTexture(
                RenderToTexture.SizeType.ShadowMap);

            CalcShadowMapBiasMatrix();

            shadowMapBlur = new ShadowMapBlur();
        }
 /// <summary>
 /// Dispose
 /// </summary>
 /// <param name="someObject">Some object</param>
 public static void Dispose(ref RenderToTexture someObject)
 {
     if (someObject != null)
         someObject.Dispose();
     someObject = null;
 }